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:
grzlusandClaude Opus 5.5 committed 2026-10-21 18:57:40 +02:00
1 parent e002cdf170
commit 2d45ce3af8
6 files changed
+282 -100

No files matched your search

+16
View File
@@ -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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.