-
Notifications
You must be signed in to change notification settings - Fork 14
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
limitador version from env var #37
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you are thinking on having extra capabilities for the image and repository, but if not we could simply use image := helpers.FetchEnv(RELATED_IMAGE_LIMITADOR, fmt.Sprintf("%s:%s", LimitadorRepository, DefaultVersion) ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only included the logic in a method to be testable in image_test.go |
||
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", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename it to something like
LIMITADOR_SERVICE_IMAGE
orLIMITADOR_INSTANCE_IMAGE
or justLIMITADOR_IMAGE
... regarding the last one, we could make the distinction withLIMITADOR_OPERATOR_IMAGE
if neededThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RELATED_IMAGE prefix is commonly in OSBS for productization purposes.
I am preparing it for the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the
relatedImages
section in the bundle is automatically created because of that prefix is being used.