From 7aaa1be89e0e605ee18c8e663cc1fa575c0145c1 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 18 Aug 2022 18:50:48 +0200 Subject: [PATCH 1/2] limitador version as env var --- config/deploy/manfiests.yaml | 3 +++ config/manager/manager.yaml | 3 +++ pkg/limitador/image.go | 15 +++++++++++++++ pkg/limitador/image_test.go | 11 +++++++++++ pkg/limitador/k8s_objects.go | 12 ++++++------ pkg/limitador/k8s_objects_test.go | 4 +--- 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 pkg/limitador/image.go create mode 100644 pkg/limitador/image_test.go diff --git a/config/deploy/manfiests.yaml b/config/deploy/manfiests.yaml index 14a51b00..96c5dd8f 100644 --- a/config/deploy/manfiests.yaml +++ b/config/deploy/manfiests.yaml @@ -372,6 +372,9 @@ spec: - --leader-elect command: - /manager + env: + - name: RELATED_IMAGE_LIMITADOR + value: quay.io/3scale/limitador:latest image: quay.io/kuadrant/limitador-operator:latest livenessProbe: httpGet: diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 79adfe72..273598ff 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -29,6 +29,9 @@ spec: - /manager args: - --leader-elect + env: + - name: RELATED_IMAGE_LIMITADOR + value: "quay.io/3scale/limitador:latest" image: controller:latest name: manager securityContext: diff --git a/pkg/limitador/image.go b/pkg/limitador/image.go new file mode 100644 index 00000000..f88fe135 --- /dev/null +++ b/pkg/limitador/image.go @@ -0,0 +1,15 @@ +package limitador + +import ( + "fmt" + + "github.com/kuadrant/limitador-operator/pkg/helpers" +) + +var ( + defaultImageVersion = fmt.Sprintf("%s:%s", LimitadorRepository, "latest") +) + +func GetLimitadorImageVersion() string { + return helpers.FetchEnv("RELATED_IMAGE_LIMITADOR", defaultImageVersion) +} diff --git a/pkg/limitador/image_test.go b/pkg/limitador/image_test.go new file mode 100644 index 00000000..c17681c6 --- /dev/null +++ b/pkg/limitador/image_test.go @@ -0,0 +1,11 @@ +package limitador + +import ( + "testing" + + "gotest.tools/assert" +) + +func TestLimitadorDefaulImage(t *testing.T) { + assert.Equal(t, GetLimitadorImageVersion(), "quay.io/3scale/limitador:latest") +} diff --git a/pkg/limitador/k8s_objects.go b/pkg/limitador/k8s_objects.go index 52899c5c..b8a61633 100644 --- a/pkg/limitador/k8s_objects.go +++ b/pkg/limitador/k8s_objects.go @@ -4,18 +4,18 @@ import ( "crypto/md5" "fmt" - limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/yaml" + + limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1" ) const ( - DefaultVersion = "latest" DefaultReplicas = 1 - Image = "quay.io/3scale/limitador" + LimitadorRepository = "quay.io/3scale/limitador" StatusEndpoint = "/status" LimitadorConfigFileName = "limitador-config.yaml" LimitadorCMHash = "hash" @@ -64,9 +64,9 @@ func LimitadorDeployment(limitador *limitadorv1alpha1.Limitador) *appsv1.Deploym replicas = int32(*limitador.Spec.Replicas) } - version := DefaultVersion + image := GetLimitadorImageVersion() if limitador.Spec.Version != nil { - version = *limitador.Spec.Version + image = fmt.Sprintf("%s:%s", LimitadorRepository, *limitador.Spec.Version) } return &appsv1.Deployment{ @@ -93,7 +93,7 @@ func LimitadorDeployment(limitador *limitadorv1alpha1.Limitador) *appsv1.Deploym Containers: []v1.Container{ { Name: "limitador", - Image: Image + ":" + version, + Image: image, Ports: []v1.ContainerPort{ { Name: "http", diff --git a/pkg/limitador/k8s_objects_test.go b/pkg/limitador/k8s_objects_test.go index e6bd9efb..bb1955c8 100644 --- a/pkg/limitador/k8s_objects_test.go +++ b/pkg/limitador/k8s_objects_test.go @@ -9,9 +9,8 @@ import ( ) func TestConstants(t *testing.T) { - assert.Check(t, "latest" == DefaultVersion) assert.Check(t, 1 == DefaultReplicas) - assert.Check(t, "quay.io/3scale/limitador" == Image) + assert.Check(t, "quay.io/3scale/limitador" == LimitadorRepository) assert.Check(t, "/status" == StatusEndpoint) assert.Check(t, "limitador-config.yaml" == LimitadorConfigFileName) assert.Check(t, "hash" == LimitadorCMHash) @@ -47,7 +46,6 @@ func newTestLimitadorObj(name, namespace string, limits []limitadorv1alpha1.Rate Limits: limits, }, } - } func TestServiceName(t *testing.T) { From cd8c7f749b31a8f8923e7ba833073020a7d1c9c7 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 18 Aug 2022 19:13:04 +0200 Subject: [PATCH 2/2] update bundles --- .../manifests/limitador-operator.clusterserviceversion.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundle/manifests/limitador-operator.clusterserviceversion.yaml b/bundle/manifests/limitador-operator.clusterserviceversion.yaml index 68805532..40f92ba1 100644 --- a/bundle/manifests/limitador-operator.clusterserviceversion.yaml +++ b/bundle/manifests/limitador-operator.clusterserviceversion.yaml @@ -135,6 +135,9 @@ spec: - --leader-elect command: - /manager + env: + - name: RELATED_IMAGE_LIMITADOR + value: quay.io/3scale/limitador:latest image: quay.io/kuadrant/limitador-operator:latest livenessProbe: httpGet: @@ -212,4 +215,7 @@ spec: provider: name: Red Hat url: https://github.com/Kuadrant/limitador-operator + relatedImages: + - image: quay.io/3scale/limitador:latest + name: limitador version: 0.0.0