Skip to content

Commit

Permalink
addons: List cilium-init image only for Cilium < 1.6
Browse files Browse the repository at this point in the history
We don't ship a separate cilium-init image anymore. The cilium-init
script is included in the main cilium container image.

Fixes: SUSE/avant-garde#1923

Signed-off-by: Michal Rostecki <[email protected]>
  • Loading branch information
vadorovsky committed Dec 11, 2020
1 parent 97c3865 commit a792046
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
5 changes: 4 additions & 1 deletion internal/pkg/skuba/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/skuba/addons/cilium.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}

Expand Down
18 changes: 14 additions & 4 deletions internal/pkg/skuba/addons/cilium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/skuba/util/versioncheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a792046

Please sign in to comment.