diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-03 18:11:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 18:11:54 +0200 |
commit | a89d62ac3a445a5d76bd72d4b8e1bb9262ba74c6 (patch) | |
tree | 9567b9174dc22e944fffcecad626baed326ccc49 /pkg/bindings/images | |
parent | a168dcc39cfa7335610663d4496b712a478abd69 (diff) | |
parent | 44a515015c3766809089d260917a508bf94a73fd (diff) | |
download | podman-a89d62ac3a445a5d76bd72d4b8e1bb9262ba74c6.tar.gz podman-a89d62ac3a445a5d76bd72d4b8e1bb9262ba74c6.tar.bz2 podman-a89d62ac3a445a5d76bd72d4b8e1bb9262ba74c6.zip |
Merge pull request #5701 from vrothberg/v2-push
podmanV2: implement push
Diffstat (limited to 'pkg/bindings/images')
-rw-r--r-- | pkg/bindings/images/images.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 470ce546c..dcb568d6b 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -3,6 +3,7 @@ package images import ( "context" "errors" + "fmt" "io" "net/http" "net/url" @@ -283,3 +284,26 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption return pulledImages, nil } + +// Push is the binding for libpod's v2 endpoints for push images. Note that +// `source` must be a refering to an image in the remote's container storage. +// The destination must be a reference to a registry (i.e., of docker transport +// or be normalized to one). Other transports are rejected as they do not make +// sense in a remote context. +func Push(ctx context.Context, source string, destination string, options entities.ImagePushOptions) error { + conn, err := bindings.GetClient(ctx) + if err != nil { + return err + } + params := url.Values{} + params.Set("credentials", options.Credentials) + params.Set("destination", destination) + if options.TLSVerify != types.OptionalBoolUndefined { + val := bool(options.TLSVerify == types.OptionalBoolTrue) + params.Set("tlsVerify", strconv.FormatBool(val)) + } + + path := fmt.Sprintf("/images/%s/push", source) + _, err = conn.DoRequest(nil, http.MethodPost, path, params) + return err +} |