diff --git a/internal/pkg/skuba/addons/addons.go b/internal/pkg/skuba/addons/addons.go index 57a5b9c3ee..018653eef4 100644 --- a/internal/pkg/skuba/addons/addons.go +++ b/internal/pkg/skuba/addons/addons.go @@ -470,7 +470,10 @@ func (addon Addon) Apply(client clientset.Interface, addonConfiguration AddonCon func (addon Addon) Images(imageTag string) []string { images := []string{} for _, cb := range addon.getImageCallbacks { - images = append(images, cb(imageTag)) + image := cb(imageTag) + if image != "" { + images = append(images, image) + } } return images } diff --git a/internal/pkg/skuba/addons/cilium.go b/internal/pkg/skuba/addons/cilium.go index 3e0b6cffcf..a2ba90b754 100644 --- a/internal/pkg/skuba/addons/cilium.go +++ b/internal/pkg/skuba/addons/cilium.go @@ -24,6 +24,7 @@ import ( "github.com/SUSE/skuba/internal/pkg/skuba/cni" "github.com/SUSE/skuba/internal/pkg/skuba/kubernetes" "github.com/SUSE/skuba/internal/pkg/skuba/skuba" + "github.com/SUSE/skuba/internal/pkg/skuba/util" skubaconstants "github.com/SUSE/skuba/pkg/skuba" "github.com/pkg/errors" clientset "k8s.io/client-go/kubernetes" @@ -35,6 +36,10 @@ func init() { } func GetCiliumInitImage(imageTag string) string { + // A separate cilium-init image exists only for Cilium < 1.6. + if util.VersionCompare(imageTag, ">=1.6.0") { + return "" + } return images.GetGenericImage(skubaconstants.ImageRepository, "cilium-init", imageTag) } diff --git a/internal/pkg/skuba/addons/cilium_test.go b/internal/pkg/skuba/addons/cilium_test.go index f67f5ca892..f90626e9b1 100644 --- a/internal/pkg/skuba/addons/cilium_test.go +++ b/internal/pkg/skuba/addons/cilium_test.go @@ -36,13 +36,18 @@ func TestGetCiliumInitImage(t *testing.T) { }{ { name: "get cilium init image without revision", - imageTag: "1.6.6", - want: img.ImageRepository + "/cilium-init:1.6.6", + imageTag: "1.5.3", + want: img.ImageRepository + "/cilium-init:1.5.3", }, { name: "get cilium init image with revision", - imageTag: "1.6.6-rev2", - want: img.ImageRepository + "/cilium-init:1.6.6-rev2", + imageTag: "1.5.3-rev1", + want: img.ImageRepository + "/cilium-init:1.5.3-rev1", + }, + { + name: "get newer cilium version which does not ship cilium-init image", + imageTag: "1.6.6", + want: "", }, } for _, tt := range tests { @@ -129,6 +134,11 @@ func Test_renderContext_CiliumInitImage(t *testing.T) { } t.Run(tt.name, func(t *testing.T) { got := tt.renderContext.CiliumInitImage() + // Skip empty results, which mean that Cilium >= 1.6 is checked and thus + // the cilium-init image is not shipped. + if got == "" { + return + } matched, err := regexp.Match(tt.want, []byte(got)) if err != nil { t.Error(err) diff --git a/internal/pkg/skuba/util/versioncheck_test.go b/internal/pkg/skuba/util/versioncheck_test.go index 8730c2729c..cf05712fe8 100644 --- a/internal/pkg/skuba/util/versioncheck_test.go +++ b/internal/pkg/skuba/util/versioncheck_test.go @@ -94,6 +94,12 @@ func TestVersionCompare(t *testing.T) { constraint: "<=1.5.0", exp: false, }, + { + name: "greater, with rev", + version: "1.6.6-rev5", + constraint: ">1.6.0", + exp: true, + }, } for _, tt := range tests { tt := tt