From 934707bea649f9565a7f961e5f6779a537fedd9e Mon Sep 17 00:00:00 2001 From: Nir Dothan Date: Fri, 8 May 2026 16:50:23 +0300 Subject: [PATCH] csv-generator: Populate name field in relatedImages entries The relatedImages section was generating entries with only the image field populated, leaving the name field empty. This caused issues when merging CSVs in the HCO bundle build pipeline, where entries appeared with 'name: ""' in the final CSV. The HCO CSV format expects both image and name fields to be set to the same value for each relatedImages entry. This ensures consistency across all operator CSVs and prevents empty name fields in the merged output. Assisted by: Claude Sonnet 4.5 Signed-off-by: Nir Dothan --- cmd/csv-generator/main.go | 6 +++- cmd/csv-generator/related_images_test.go | 40 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/cmd/csv-generator/main.go b/cmd/csv-generator/main.go index 0b96fd5..689dfba 100644 --- a/cmd/csv-generator/main.go +++ b/cmd/csv-generator/main.go @@ -412,12 +412,16 @@ func buildClusterPermissions(rules []rbac.Rule) []StrategyDeploymentPermissions // and any additional images passed via --additional-images. func buildRelatedImages(operatorImage string, additionalImageEnvVars []parser.EnvVar) []RelatedImage { relatedImages := []RelatedImage{ - {Image: operatorImage}, + { + Name: operatorImage, + Image: operatorImage, + }, } // Add all additional images to relatedImages. for _, envVar := range additionalImageEnvVars { relatedImages = append(relatedImages, RelatedImage{ + Name: envVar.Value, Image: envVar.Value, }) } diff --git a/cmd/csv-generator/related_images_test.go b/cmd/csv-generator/related_images_test.go index cf08ff8..88dab4a 100644 --- a/cmd/csv-generator/related_images_test.go +++ b/cmd/csv-generator/related_images_test.go @@ -35,7 +35,10 @@ func TestBuildRelatedImages(t *testing.T) { operatorImage: "quay.io/test/autopilot@sha256:abc123", additionalImageEnvVars: nil, expected: []RelatedImage{ - {Image: "quay.io/test/autopilot@sha256:abc123"}, + { + Name: "quay.io/test/autopilot@sha256:abc123", + Image: "quay.io/test/autopilot@sha256:abc123", + }, }, }, { @@ -43,7 +46,10 @@ func TestBuildRelatedImages(t *testing.T) { operatorImage: "quay.io/test/autopilot@sha256:abc123", additionalImageEnvVars: []parser.EnvVar{}, expected: []RelatedImage{ - {Image: "quay.io/test/autopilot@sha256:abc123"}, + { + Name: "quay.io/test/autopilot@sha256:abc123", + Image: "quay.io/test/autopilot@sha256:abc123", + }, }, }, { @@ -53,8 +59,14 @@ func TestBuildRelatedImages(t *testing.T) { {Name: "NETWORK_RESOURCES_INJECTOR_IMAGE", Value: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456"}, }, expected: []RelatedImage{ - {Image: "quay.io/test/autopilot@sha256:abc123"}, - {Image: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456"}, + { + Name: "quay.io/test/autopilot@sha256:abc123", + Image: "quay.io/test/autopilot@sha256:abc123", + }, + { + Name: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456", + Image: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456", + }, }, }, { @@ -66,10 +78,22 @@ func TestBuildRelatedImages(t *testing.T) { {Name: "THIRD_IMAGE", Value: "registry.example.com/test/third:v1.0"}, }, expected: []RelatedImage{ - {Image: "quay.io/test/autopilot@sha256:abc123"}, - {Image: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456"}, - {Image: "quay.io/test/another@sha256:xyz789"}, - {Image: "registry.example.com/test/third:v1.0"}, + { + Name: "quay.io/test/autopilot@sha256:abc123", + Image: "quay.io/test/autopilot@sha256:abc123", + }, + { + Name: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456", + Image: "registry.redhat.io/openshift4/ose-sriov-dp-admission-controller-rhel9@sha256:def456", + }, + { + Name: "quay.io/test/another@sha256:xyz789", + Image: "quay.io/test/another@sha256:xyz789", + }, + { + Name: "registry.example.com/test/third:v1.0", + Image: "registry.example.com/test/third:v1.0", + }, }, }, }