Merge pull request #16549 from sstosh/remote-manifest-annotation

Add support for podman-remote manifest annotate
This commit is contained in:
OpenShift Merge Robot
2022-12-12 09:29:06 -05:00
committed by GitHub
5 changed files with 46 additions and 11 deletions

View File

@ -530,13 +530,13 @@ func ManifestModify(w http.ResponseWriter, r *http.Request) {
}
case strings.EqualFold("annotate", body.Operation):
options := entities.ManifestAnnotateOptions{
Annotation: body.Annotation,
Arch: body.Arch,
Features: body.Features,
OS: body.OS,
OSFeatures: body.OSFeatures,
OSVersion: body.OSVersion,
Variant: body.Variant,
Annotations: body.Annotations,
Arch: body.Arch,
Features: body.Features,
OS: body.OS,
OSFeatures: body.OSFeatures,
OSVersion: body.OSVersion,
Variant: body.Variant,
}
for _, image := range body.Images {
id, err := imageEngine.ManifestAnnotate(r.Context(), name, image, options)

View File

@ -3,7 +3,6 @@ package tunnel
import (
"context"
"encoding/json"
"errors"
"fmt"
"strings"
@ -92,7 +91,27 @@ func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames []
// ManifestAnnotate updates an entry of the manifest list
func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, name, images string, opts entities.ManifestAnnotateOptions) (string, error) {
return "", errors.New("not implemented")
options := new(manifests.ModifyOptions).WithArch(opts.Arch).WithVariant(opts.Variant)
options.WithFeatures(opts.Features).WithOS(opts.OS).WithOSVersion(opts.OSVersion)
if len(opts.Annotation) != 0 {
annotations := make(map[string]string)
for _, annotationSpec := range opts.Annotation {
spec := strings.SplitN(annotationSpec, "=", 2)
if len(spec) != 2 {
return "", fmt.Errorf("no value given for annotation %q", spec[0])
}
annotations[spec[0]] = spec[1]
}
opts.Annotations = envLib.Join(opts.Annotations, annotations)
}
options.WithAnnotations(opts.Annotations)
id, err := manifests.Annotate(ir.ClientCtx, name, []string{images}, options)
if err != nil {
return id, fmt.Errorf("annotating to manifest list %s: %w", name, err)
}
return id, nil
}
// ManifestRemoveDigest removes the digest from manifest list