Merge pull request #16004 from sstosh/remote-manifest-annotate

remote: fix manifest add --annotation
This commit is contained in:
OpenShift Merge Robot
2022-11-10 09:02:10 +00:00
committed by GitHub
7 changed files with 101 additions and 7 deletions

View File

@ -43,6 +43,8 @@ type ManifestAddOptions struct {
type ManifestAnnotateOptions struct {
// Annotation to add to manifest list
Annotation []string `json:"annotation" schema:"annotation"`
// Annotations to add to manifest list by a map which is prefferred over Annotation
Annotations map[string]string `json:"annotations" schema:"annotations"`
// Arch overrides the architecture for the image
Arch string `json:"arch" schema:"arch"`
// Feature list for the image

View File

@ -19,6 +19,7 @@ import (
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v4/pkg/domain/entities"
envLib "github.com/containers/podman/v4/pkg/env"
"github.com/containers/storage"
"github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
@ -231,8 +232,9 @@ func (ir *ImageEngine) ManifestAdd(ctx context.Context, name string, images []st
}
annotations[spec[0]] = spec[1]
}
annotateOptions.Annotations = annotations
opts.Annotations = envLib.Join(opts.Annotations, annotations)
}
annotateOptions.Annotations = opts.Annotations
if err := manifestList.AnnotateInstance(instanceDigest, annotateOptions); err != nil {
return "", err
@ -269,8 +271,9 @@ func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, name, image string,
}
annotations[spec[0]] = spec[1]
}
annotateOptions.Annotations = annotations
opts.Annotations = envLib.Join(opts.Annotations, annotations)
}
annotateOptions.Annotations = opts.Annotations
if err := manifestList.AnnotateInstance(instanceDigest, annotateOptions); err != nil {
return "", err

View File

@ -11,6 +11,7 @@ import (
"github.com/containers/podman/v4/pkg/bindings/images"
"github.com/containers/podman/v4/pkg/bindings/manifests"
"github.com/containers/podman/v4/pkg/domain/entities"
envLib "github.com/containers/podman/v4/pkg/env"
)
// ManifestCreate implements manifest create via ImageEngine
@ -43,7 +44,7 @@ func (ir *ImageEngine) ManifestInspect(ctx context.Context, name string, opts en
}
}
list, err := manifests.Inspect(ir.ClientCtx, name, options)
list, err := manifests.InspectListData(ir.ClientCtx, name, options)
if err != nil {
return nil, fmt.Errorf("getting content of manifest list or image %s: %w", name, err)
}
@ -60,6 +61,7 @@ func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames []
options := new(manifests.AddOptions).WithAll(opts.All).WithArch(opts.Arch).WithVariant(opts.Variant)
options.WithFeatures(opts.Features).WithImages(imageNames).WithOS(opts.OS).WithOSVersion(opts.OSVersion)
options.WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile)
if len(opts.Annotation) != 0 {
annotations := make(map[string]string)
for _, annotationSpec := range opts.Annotation {
@ -69,8 +71,10 @@ func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames []
}
annotations[spec[0]] = spec[1]
}
options.WithAnnotation(annotations)
opts.Annotations = envLib.Join(opts.Annotations, annotations)
}
options.WithAnnotation(opts.Annotations)
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
if s == types.OptionalBoolTrue {
options.WithSkipTLSVerify(true)