mirror of
https://github.com/containers/podman.git
synced 2025-05-22 01:27:07 +08:00
Merge pull request #14560 from rhatdan/remote
podman-remote push --remove-signatures support
This commit is contained in:
@ -117,7 +117,6 @@ func pushFlags(cmd *cobra.Command) {
|
|||||||
_ = flags.MarkHidden("compress")
|
_ = flags.MarkHidden("compress")
|
||||||
_ = flags.MarkHidden("digestfile")
|
_ = flags.MarkHidden("digestfile")
|
||||||
_ = flags.MarkHidden("quiet")
|
_ = flags.MarkHidden("quiet")
|
||||||
_ = flags.MarkHidden("remove-signatures")
|
|
||||||
_ = flags.MarkHidden("sign-by")
|
_ = flags.MarkHidden("sign-by")
|
||||||
}
|
}
|
||||||
if !registry.IsRemote() {
|
if !registry.IsRemote() {
|
||||||
|
@ -95,7 +95,7 @@ When writing the output image, suppress progress output
|
|||||||
|
|
||||||
#### **--remove-signatures**
|
#### **--remove-signatures**
|
||||||
|
|
||||||
Discard any pre-existing signatures in the image. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
|
Discard any pre-existing signatures in the image.
|
||||||
|
|
||||||
#### **--sign-by**=*key*
|
#### **--sign-by**=*key*
|
||||||
|
|
||||||
|
@ -422,10 +422,11 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||||
|
|
||||||
query := struct {
|
query := struct {
|
||||||
Destination string `schema:"destination"`
|
All bool `schema:"all"`
|
||||||
TLSVerify bool `schema:"tlsVerify"`
|
Destination string `schema:"destination"`
|
||||||
Format string `schema:"format"`
|
Format string `schema:"format"`
|
||||||
All bool `schema:"all"`
|
RemoveSignatures bool `schema:"removeSignatures"`
|
||||||
|
TLSVerify bool `schema:"tlsVerify"`
|
||||||
}{
|
}{
|
||||||
// This is where you can override the golang default value for one of fields
|
// This is where you can override the golang default value for one of fields
|
||||||
}
|
}
|
||||||
@ -462,12 +463,13 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
password = authconf.Password
|
password = authconf.Password
|
||||||
}
|
}
|
||||||
options := entities.ImagePushOptions{
|
options := entities.ImagePushOptions{
|
||||||
Authfile: authfile,
|
All: query.All,
|
||||||
Username: username,
|
Authfile: authfile,
|
||||||
Password: password,
|
Format: query.Format,
|
||||||
Format: query.Format,
|
Password: password,
|
||||||
All: query.All,
|
Quiet: true,
|
||||||
Quiet: true,
|
RemoveSignatures: query.RemoveSignatures,
|
||||||
|
Username: username,
|
||||||
}
|
}
|
||||||
if _, found := r.URL.Query()["tlsVerify"]; found {
|
if _, found := r.URL.Query()["tlsVerify"]; found {
|
||||||
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
|
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
|
||||||
|
@ -247,9 +247,10 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||||
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
||||||
query := struct {
|
query := struct {
|
||||||
All bool `schema:"all"`
|
All bool `schema:"all"`
|
||||||
Destination string `schema:"destination"`
|
Destination string `schema:"destination"`
|
||||||
TLSVerify bool `schema:"tlsVerify"`
|
RemoveSignatures bool `schema:"removeSignatures"`
|
||||||
|
TLSVerify bool `schema:"tlsVerify"`
|
||||||
}{
|
}{
|
||||||
// Add defaults here once needed.
|
// Add defaults here once needed.
|
||||||
}
|
}
|
||||||
@ -276,10 +277,11 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) {
|
|||||||
password = authconf.Password
|
password = authconf.Password
|
||||||
}
|
}
|
||||||
options := entities.ImagePushOptions{
|
options := entities.ImagePushOptions{
|
||||||
Authfile: authfile,
|
All: query.All,
|
||||||
Username: username,
|
Authfile: authfile,
|
||||||
Password: password,
|
Password: password,
|
||||||
All: query.All,
|
RemoveSignatures: query.RemoveSignatures,
|
||||||
|
Username: username,
|
||||||
}
|
}
|
||||||
if sys := runtime.SystemContext(); sys != nil {
|
if sys := runtime.SystemContext(); sys != nil {
|
||||||
options.CertDir = sys.DockerCertPath
|
options.CertDir = sys.DockerCertPath
|
||||||
|
@ -127,6 +127,8 @@ type PushOptions struct {
|
|||||||
Password *string
|
Password *string
|
||||||
// SkipTLSVerify to skip HTTPS and certificate verification.
|
// SkipTLSVerify to skip HTTPS and certificate verification.
|
||||||
SkipTLSVerify *bool
|
SkipTLSVerify *bool
|
||||||
|
// RemoveSignatures Discard any pre-existing signatures in the image.
|
||||||
|
RemoveSignatures *bool
|
||||||
// Username for authenticating against the registry.
|
// Username for authenticating against the registry.
|
||||||
Username *string
|
Username *string
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,21 @@ func (o *PushOptions) GetSkipTLSVerify() bool {
|
|||||||
return *o.SkipTLSVerify
|
return *o.SkipTLSVerify
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithRemoveSignatures set field RemoveSignatures to given value
|
||||||
|
func (o *PushOptions) WithRemoveSignatures(value bool) *PushOptions {
|
||||||
|
o.RemoveSignatures = &value
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRemoveSignatures returns value of field RemoveSignatures
|
||||||
|
func (o *PushOptions) GetRemoveSignatures() bool {
|
||||||
|
if o.RemoveSignatures == nil {
|
||||||
|
var z bool
|
||||||
|
return z
|
||||||
|
}
|
||||||
|
return *o.RemoveSignatures
|
||||||
|
}
|
||||||
|
|
||||||
// WithUsername set field Username to given value
|
// WithUsername set field Username to given value
|
||||||
func (o *PushOptions) WithUsername(value string) *PushOptions {
|
func (o *PushOptions) WithUsername(value string) *PushOptions {
|
||||||
o.Username = &value
|
o.Username = &value
|
||||||
|
@ -244,7 +244,7 @@ func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOpti
|
|||||||
|
|
||||||
func (ir *ImageEngine) Push(ctx context.Context, source string, destination string, opts entities.ImagePushOptions) error {
|
func (ir *ImageEngine) Push(ctx context.Context, source string, destination string, opts entities.ImagePushOptions) error {
|
||||||
options := new(images.PushOptions)
|
options := new(images.PushOptions)
|
||||||
options.WithAll(opts.All).WithCompress(opts.Compress).WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithFormat(opts.Format)
|
options.WithAll(opts.All).WithCompress(opts.Compress).WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithFormat(opts.Format).WithRemoveSignatures(opts.RemoveSignatures)
|
||||||
|
|
||||||
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
||||||
if s == types.OptionalBoolTrue {
|
if s == types.OptionalBoolTrue {
|
||||||
|
@ -99,7 +99,7 @@ func (ir *ImageEngine) ManifestRm(ctx context.Context, names []string) (*entitie
|
|||||||
// ManifestPush pushes a manifest list or image index to the destination
|
// ManifestPush pushes a manifest list or image index to the destination
|
||||||
func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination string, opts entities.ImagePushOptions) (string, error) {
|
func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination string, opts entities.ImagePushOptions) (string, error) {
|
||||||
options := new(images.PushOptions)
|
options := new(images.PushOptions)
|
||||||
options.WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile)
|
options.WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithRemoveSignatures(opts.RemoveSignatures)
|
||||||
options.WithAll(opts.All)
|
options.WithAll(opts.All)
|
||||||
|
|
||||||
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
||||||
|
@ -96,7 +96,6 @@ var _ = Describe("Podman push", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman push to local registry", func() {
|
It("podman push to local registry", func() {
|
||||||
SkipIfRemote("Remote does not support --digestfile or --remove-signatures")
|
|
||||||
if podmanTest.Host.Arch == "ppc64le" {
|
if podmanTest.Host.Arch == "ppc64le" {
|
||||||
Skip("No registry image for ppc64le")
|
Skip("No registry image for ppc64le")
|
||||||
}
|
}
|
||||||
@ -118,6 +117,7 @@ var _ = Describe("Podman push", func() {
|
|||||||
push.WaitWithDefaultTimeout()
|
push.WaitWithDefaultTimeout()
|
||||||
Expect(push).Should(Exit(0))
|
Expect(push).Should(Exit(0))
|
||||||
|
|
||||||
|
SkipIfRemote("Remote does not support --digestfile")
|
||||||
// Test --digestfile option
|
// Test --digestfile option
|
||||||
push2 := podmanTest.Podman([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
|
push2 := podmanTest.Podman([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
|
||||||
push2.WaitWithDefaultTimeout()
|
push2.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user