From 34121d415ba93bf724402280c99803297ddd554a Mon Sep 17 00:00:00 2001 From: Grzegorz Szczepanczyk Date: Fri, 19 Jun 2026 13:25:07 +0200 Subject: [PATCH] fix: rename ManifestAddArtifactOptions.Annotations to ArtifactAnnotations The swagger:model ManifestAddArtifactOptions (pkg/domain/entities) embeds ManifestAnnotateOptions, which already has an Annotations field, and also declared its own Annotations field. The generated swagger therefore emitted two members with the same x-go-name, so Go clients generated from the spec failed to compile (the reproducer on the issue). Rename the field in the entities struct to ArtifactAnnotations, matching the sibling ManifestModifyOptions. The json/schema tags stay "artifact_annotations", so the REST API wire format is unchanged. pkg/bindings is intentionally left untouched: it is part of the public client API used by third parties, so its option/field names must stay stable. swagger.yaml is generated by make swagger from these annotations and is left for CI to regenerate. Fixes: #22966 Signed-off-by: Grzegorz Szczepanczyk --- pkg/api/handlers/libpod/manifests.go | 16 ++++++++-------- pkg/domain/entities/manifest.go | 17 +++++++++-------- pkg/domain/infra/abi/manifest.go | 2 +- pkg/domain/infra/tunnel/manifest.go | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go index ea79944136a..dded9e5835a 100644 --- a/pkg/api/handlers/libpod/manifests.go +++ b/pkg/api/handlers/libpod/manifests.go @@ -674,14 +674,14 @@ func ManifestModify(w http.ResponseWriter, r *http.Request) { // We waited until after the extraction goroutine finished to ensure // that we'd pick up its changes to the ArtifactFiles list. manifestAddArtifactOptions := entities.ManifestAddArtifactOptions{ - Type: body.ArtifactType, - LayerType: body.ArtifactLayerType, - ConfigType: body.ArtifactConfigType, - Config: body.ArtifactConfig, - ExcludeTitles: body.ArtifactExcludeTitles, - Annotations: body.ArtifactAnnotations, - Subject: body.ArtifactSubject, - Files: body.ArtifactFiles, + Type: body.ArtifactType, + LayerType: body.ArtifactLayerType, + ConfigType: body.ArtifactConfigType, + Config: body.ArtifactConfig, + ExcludeTitles: body.ArtifactExcludeTitles, + ArtifactAnnotations: body.ArtifactAnnotations, + Subject: body.ArtifactSubject, + Files: body.ArtifactFiles, } id, err := imageEngine.ManifestAddArtifact(r.Context(), name, body.ArtifactFiles, manifestAddArtifactOptions) if err != nil { diff --git a/pkg/domain/entities/manifest.go b/pkg/domain/entities/manifest.go index 79ee4776bab..d629d08776e 100644 --- a/pkg/domain/entities/manifest.go +++ b/pkg/domain/entities/manifest.go @@ -53,14 +53,15 @@ type ManifestAddOptions struct { type ManifestAddArtifactOptions struct { ManifestAnnotateOptions // Note to future maintainers: keep these fields synchronized with ManifestModifyOptions! - Type *string `json:"artifact_type" schema:"artifact_type"` - LayerType string `json:"artifact_layer_type" schema:"artifact_layer_type"` - ConfigType string `json:"artifact_config_type" schema:"artifact_config_type"` - Config string `json:"artifact_config" schema:"artifact_config"` - ExcludeTitles bool `json:"artifact_exclude_titles" schema:"artifact_exclude_titles"` - Annotations map[string]string `json:"artifact_annotations" schema:"artifact_annotations"` - Subject string `json:"artifact_subject" schema:"artifact_subject"` - Files []string `json:"artifact_files" schema:"-"` + Type *string `json:"artifact_type" schema:"artifact_type"` + LayerType string `json:"artifact_layer_type" schema:"artifact_layer_type"` + ConfigType string `json:"artifact_config_type" schema:"artifact_config_type"` + Config string `json:"artifact_config" schema:"artifact_config"` + ExcludeTitles bool `json:"artifact_exclude_titles" schema:"artifact_exclude_titles"` + // ArtifactAnnotations has a distinct Go name (the tag is unchanged) to avoid a swagger x-go-name collision with the embedded ManifestAnnotateOptions.Annotations. + ArtifactAnnotations map[string]string `json:"artifact_annotations" schema:"artifact_annotations"` + Subject string `json:"artifact_subject" schema:"artifact_subject"` + Files []string `json:"artifact_files" schema:"-"` } // ManifestAnnotateOptions provides model for annotating manifest list diff --git a/pkg/domain/infra/abi/manifest.go b/pkg/domain/infra/abi/manifest.go index 21ef9d2a970..4b3f520fd60 100644 --- a/pkg/domain/infra/abi/manifest.go +++ b/pkg/domain/infra/abi/manifest.go @@ -361,7 +361,7 @@ func (ir *ImageEngine) ManifestAddArtifact(ctx context.Context, name string, fil Config: opts.Config, LayerType: opts.LayerType, ExcludeTitles: opts.ExcludeTitles, - Annotations: opts.Annotations, + Annotations: opts.ArtifactAnnotations, Subject: opts.Subject, } diff --git a/pkg/domain/infra/tunnel/manifest.go b/pkg/domain/infra/tunnel/manifest.go index 58546cd7d73..dd95bc000fe 100644 --- a/pkg/domain/infra/tunnel/manifest.go +++ b/pkg/domain/infra/tunnel/manifest.go @@ -117,7 +117,7 @@ func (ir *ImageEngine) ManifestAddArtifact(_ context.Context, name string, files options.WithType(opts.Type).WithConfigType(opts.ConfigType).WithLayerType(opts.LayerType) options.WithConfig(opts.Config) options.WithExcludeTitles(opts.ExcludeTitles).WithSubject(opts.Subject) - options.WithAnnotations(opts.Annotations) + options.WithAnnotations(opts.ArtifactAnnotations) options.WithFiles(files) id, err := manifests.AddArtifact(ir.ClientCtx, name, options) if err != nil {