aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-09-29 14:15:37 +0200
committerPaul Holzinger <pholzing@redhat.com>2022-09-29 14:16:42 +0200
commite2fe9eabac61c4d5e1e9095c2cac1982409371d4 (patch)
tree8da0d9ff7a7a985f3ecd9de5c13190186c1f6839
parentf52feded3ce6c1ad2af046ab774fbc2b9c832487 (diff)
downloadpodman-e2fe9eabac61c4d5e1e9095c2cac1982409371d4.tar.gz
podman-e2fe9eabac61c4d5e1e9095c2cac1982409371d4.tar.bz2
podman-e2fe9eabac61c4d5e1e9095c2cac1982409371d4.zip
Revert "remote: fix manifest add --annotation"
This reverts commit 32f54a81ed797597827123b671b6e73194354327. `pkg/bindings` is supported outside of podman and we have to keep it stable. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--pkg/api/handlers/libpod/manifests.go4
-rw-r--r--pkg/bindings/manifests/manifests.go6
-rw-r--r--pkg/bindings/manifests/types.go14
-rw-r--r--pkg/bindings/manifests/types_add_options.go6
-rw-r--r--pkg/bindings/manifests/types_modify_options.go6
-rw-r--r--pkg/domain/entities/manifest.go2
-rw-r--r--pkg/domain/infra/tunnel/manifest.go18
-rw-r--r--test/e2e/manifest_test.go14
8 files changed, 34 insertions, 36 deletions
diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go
index f50bfd360..c96e4936b 100644
--- a/pkg/api/handlers/libpod/manifests.go
+++ b/pkg/api/handlers/libpod/manifests.go
@@ -11,8 +11,8 @@ import (
"strconv"
"strings"
- "github.com/containers/common/libimage"
"github.com/containers/image/v5/docker/reference"
+ "github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/pkg/api/handlers"
@@ -148,7 +148,7 @@ func ManifestInspect(w http.ResponseWriter, r *http.Request) {
return
}
- var schema2List libimage.ManifestListData
+ var schema2List manifest.Schema2List
if err := json.Unmarshal(rawManifest, &schema2List); err != nil {
utils.Error(w, http.StatusInternalServerError, err)
return
diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go
index 0da8df709..d987e51d8 100644
--- a/pkg/bindings/manifests/manifests.go
+++ b/pkg/bindings/manifests/manifests.go
@@ -11,7 +11,7 @@ import (
"strconv"
"strings"
- "github.com/containers/common/libimage"
+ "github.com/containers/image/v5/manifest"
imageTypes "github.com/containers/image/v5/types"
"github.com/containers/podman/v4/pkg/auth"
"github.com/containers/podman/v4/pkg/bindings"
@@ -71,7 +71,7 @@ func Exists(ctx context.Context, name string, options *ExistsOptions) (bool, err
}
// Inspect returns a manifest list for a given name.
-func Inspect(ctx context.Context, name string, _ *InspectOptions) (*libimage.ManifestListData, error) {
+func Inspect(ctx context.Context, name string, _ *InspectOptions) (*manifest.Schema2List, error) {
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
@@ -83,7 +83,7 @@ func Inspect(ctx context.Context, name string, _ *InspectOptions) (*libimage.Man
}
defer response.Body.Close()
- var list libimage.ManifestListData
+ var list manifest.Schema2List
return &list, response.Process(&list)
}
diff --git a/pkg/bindings/manifests/types.go b/pkg/bindings/manifests/types.go
index 501feb5a1..fec3f9d13 100644
--- a/pkg/bindings/manifests/types.go
+++ b/pkg/bindings/manifests/types.go
@@ -22,7 +22,7 @@ type ExistsOptions struct {
// AddOptions are optional options for adding manifest lists
type AddOptions struct {
All *bool
- Annotation []string
+ Annotation map[string]string
Arch *string
Features []string
Images []string
@@ -46,12 +46,12 @@ type ModifyOptions struct {
// Operation values are "update", "remove" and "annotate". This allows the service to
// efficiently perform each update on a manifest list.
Operation *string
- All *bool // All when true, operate on all images in a manifest list that may be included in Images
- Annotations []string // Annotations to add to manifest list
- Arch *string // Arch overrides the architecture for the image
- Features []string // Feature list for the image
- Images []string // Images is an optional list of images to add/remove to/from manifest list depending on operation
- OS *string // OS overrides the operating system for the image
+ All *bool // All when true, operate on all images in a manifest list that may be included in Images
+ Annotations map[string]string // Annotations to add to manifest list
+ Arch *string // Arch overrides the architecture for the image
+ Features []string // Feature list for the image
+ Images []string // Images is an optional list of images to add/remove to/from manifest list depending on operation
+ OS *string // OS overrides the operating system for the image
// OS features for the image
OSFeatures []string `json:"os_features" schema:"os_features"`
// OSVersion overrides the operating system for the image
diff --git a/pkg/bindings/manifests/types_add_options.go b/pkg/bindings/manifests/types_add_options.go
index b3e8b8134..5ba1cc5fa 100644
--- a/pkg/bindings/manifests/types_add_options.go
+++ b/pkg/bindings/manifests/types_add_options.go
@@ -33,15 +33,15 @@ func (o *AddOptions) GetAll() bool {
}
// WithAnnotation set field Annotation to given value
-func (o *AddOptions) WithAnnotation(value []string) *AddOptions {
+func (o *AddOptions) WithAnnotation(value map[string]string) *AddOptions {
o.Annotation = value
return o
}
// GetAnnotation returns value of field Annotation
-func (o *AddOptions) GetAnnotation() []string {
+func (o *AddOptions) GetAnnotation() map[string]string {
if o.Annotation == nil {
- var z []string
+ var z map[string]string
return z
}
return o.Annotation
diff --git a/pkg/bindings/manifests/types_modify_options.go b/pkg/bindings/manifests/types_modify_options.go
index 12f549577..ab00cb2c5 100644
--- a/pkg/bindings/manifests/types_modify_options.go
+++ b/pkg/bindings/manifests/types_modify_options.go
@@ -48,15 +48,15 @@ func (o *ModifyOptions) GetAll() bool {
}
// WithAnnotations set annotations to add to manifest list
-func (o *ModifyOptions) WithAnnotations(value []string) *ModifyOptions {
+func (o *ModifyOptions) WithAnnotations(value map[string]string) *ModifyOptions {
o.Annotations = value
return o
}
// GetAnnotations returns value of annotations to add to manifest list
-func (o *ModifyOptions) GetAnnotations() []string {
+func (o *ModifyOptions) GetAnnotations() map[string]string {
if o.Annotations == nil {
- var z []string
+ var z map[string]string
return z
}
return o.Annotations
diff --git a/pkg/domain/entities/manifest.go b/pkg/domain/entities/manifest.go
index 7f4b6c25f..f17079271 100644
--- a/pkg/domain/entities/manifest.go
+++ b/pkg/domain/entities/manifest.go
@@ -36,7 +36,7 @@ type ManifestAddOptions struct {
// ManifestAnnotateOptions provides model for annotating manifest list
type ManifestAnnotateOptions struct {
// Annotation to add to manifest list
- Annotation []string `json:"annotations" schema:"annotations"`
+ Annotation []string `json:"annotation" schema:"annotation"`
// Arch overrides the architecture for the image
Arch string `json:"arch" schema:"arch"`
// Feature list for the image
diff --git a/pkg/domain/infra/tunnel/manifest.go b/pkg/domain/infra/tunnel/manifest.go
index 2fe43aad0..696d0a963 100644
--- a/pkg/domain/infra/tunnel/manifest.go
+++ b/pkg/domain/infra/tunnel/manifest.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "strings"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v4/pkg/bindings/images"
@@ -47,9 +48,20 @@ func (ir *ImageEngine) ManifestInspect(_ context.Context, name string) ([]byte,
// ManifestAdd adds images to the manifest list
func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames []string, opts entities.ManifestAddOptions) (string, error) {
- options := new(manifests.AddOptions).WithAll(opts.All).WithAnnotation(opts.Annotation).WithArch(opts.Arch)
- options.WithVariant(opts.Variant).WithFeatures(opts.Features).WithImages(imageNames).WithOS(opts.OS)
- options.WithOSVersion(opts.OSVersion).WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile)
+ 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 {
+ 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]
+ }
+ options.WithAnnotation(annotations)
+ }
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
if s == types.OptionalBoolTrue {
options.WithSkipTLSVerify(true)
diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go
index 404f2cd3a..b0a5e7d03 100644
--- a/test/e2e/manifest_test.go
+++ b/test/e2e/manifest_test.go
@@ -165,20 +165,6 @@ var _ = Describe("Podman manifest", func() {
))
})
- It("add --annotation", func() {
- session := podmanTest.Podman([]string{"manifest", "create", "foo"})
- session.WaitWithDefaultTimeout()
- Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"manifest", "add", "--annotation", "hoge=fuga", "foo", imageList})
- session.WaitWithDefaultTimeout()
- Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"manifest", "inspect", "foo"})
- session.WaitWithDefaultTimeout()
- Expect(session).Should(Exit(0))
- Expect(session.OutputToString()).To(ContainSubstring(`"annotations"`))
- Expect(session.OutputToString()).To(ContainSubstring(`"hoge": "fuga"`))
- })
-
It("add --os", func() {
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
session.WaitWithDefaultTimeout()