Add cp command to copy files out of containers, binary-safe
`portainer-cli cp <stack> <container>:<path> <dest>` goes through Docker's archive API, so unlike `console --run "cat …"` there's no TTY in between and binary files (database dumps) arrive intact. Works like `docker cp` for files and directories; a dest of "-" writes a single file to stdout. Stack and container lookup moves from Console into a shared Resolver module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
6 files changed
+282
-100
No files matched your search
@@ -32,6 +32,22 @@ module PortainerCli
|
||||
request(:delete, path)
|
||||
end
|
||||
|
||||
# GET a raw (non-JSON) body, yielding it in chunks as it arrives
|
||||
def stream(path, params = {}, &block)
|
||||
uri = http_uri(path)
|
||||
uri.query = URI.encode_www_form(params) unless params.empty?
|
||||
|
||||
req = Net::HTTP::Get.new(uri)
|
||||
@config.auth_header.each { |k, v| req[k] = v }
|
||||
|
||||
build_http(uri).request(req) do |resp|
|
||||
code = resp.code.to_i
|
||||
raise ApiError.new("HTTP #{code}: #{resp.body}", code) if code >= 400
|
||||
|
||||
resp.read_body(&block)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the raw websocket URL (ws:// or wss://) for exec sessions
|
||||
def websocket_url(path, params = {})
|
||||
uri = ws_uri(path)
|
||||
|
||||