Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.15] OCPBUGS-43931: Return the right tagReference on Catalogs ImageStream #5187

Open
wants to merge 1 commit into
base: release-4.15
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func reconcileCatalogDeployment(deployment *appsv1.Deployment, ownerRef config.O
}

func findTagReference(tags []imagev1.TagReference, name string) *imagev1.TagReference {
for _, tag := range tags {
for i, tag := range tags {
if tag.Name == name {
return &tag
return &tags[i]
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package olm

import (
"testing"

. "github.com/onsi/gomega"
)

func TestGetCatalogToImageWithISImageRegistryOverrides(t *testing.T) {
tests := []struct {
name string
catalogToImage map[string]string
isImageRegistryOverrides map[string][]string
expected map[string]string
}{
{
name: "No overrides",
catalogToImage: map[string]string{
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.16",
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.16",
},
isImageRegistryOverrides: map[string][]string{},
expected: map[string]string{
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.16",
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.16",
},
},
{
name: "Single override and different tag",
catalogToImage: map[string]string{
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.17",
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.17",
},
isImageRegistryOverrides: map[string][]string{
"registry.redhat.io": {"custom.registry.io"},
},
expected: map[string]string{
"certified-operators": "custom.registry.io/redhat/certified-operator-index:v4.17",
"community-operators": "custom.registry.io/redhat/community-operator-index:v4.17",
},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
result := getCatalogToImageWithISImageRegistryOverrides(tt.catalogToImage, tt.isImageRegistryOverrides)
g.Expect(result).To(Equal(tt.expected), "Expected %d entries, but got %d", len(tt.expected), len(result))
for key, expectedValue := range tt.expected {
g.Expect(expectedValue).To(Equal(result[key]), "For key %s, expected %s, but got %s", key, expectedValue, result[key])
}
})
}
}