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

Limitador CRD new field: image #133

Merged
merged 2 commits into from
May 13, 2024
Merged
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
6 changes: 6 additions & 0 deletions api/v1alpha1/limitador_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type LimitadorSpec struct {
// +optional
Replicas *int `json:"replicas,omitempty"`

// [Deprecated] Use spec.image instead.
// Docker tag used as limitador image. The repo is hardcoded to quay.io/kuadrant/limitador
// +deprecated
// +optional
Version *string `json:"version,omitempty"`

Expand Down Expand Up @@ -101,6 +104,9 @@ type LimitadorSpec struct {
// Sets the level of verbosity
// +optional
Verbosity *VerbosityLevel `json:"verbosity,omitempty"`

// +optional
Image *string `json:"image,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/limitador-operator:latest
createdAt: "2024-04-15T10:48:14Z"
createdAt: "2024-05-03T10:11:12Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/Kuadrant/limitador-operator
Expand Down
4 changes: 4 additions & 0 deletions bundle/manifests/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ spec:
type: array
type: object
type: object
image:
type: string
limits:
items:
description: RateLimit defines the desired Limitador limit
Expand Down Expand Up @@ -1096,6 +1098,8 @@ spec:
minimum: 1
type: integer
version:
description: '[Deprecated] Use spec.image instead. Docker tag used
as limitador image. The repo is hardcoded to quay.io/kuadrant/limitador'
type: string
type: object
x-kubernetes-validations:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ spec:
type: array
type: object
type: object
image:
type: string
limits:
items:
description: RateLimit defines the desired Limitador limit
Expand Down Expand Up @@ -1097,6 +1099,8 @@ spec:
minimum: 1
type: integer
version:
description: '[Deprecated] Use spec.image instead. Docker tag used
as limitador image. The repo is hardcoded to quay.io/kuadrant/limitador'
type: string
type: object
x-kubernetes-validations:
Expand Down
10 changes: 7 additions & 3 deletions pkg/limitador/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import (
"k8s.io/utils/env"
)

const (
LimitadorRepository = "quay.io/kuadrant/limitador"
)

var (
defaultImageVersion = fmt.Sprintf("%s:%s", LimitadorRepository, "latest")
defaultImage = fmt.Sprintf("%s:%s", LimitadorRepository, "latest")
)

func GetLimitadorImageVersion() string {
return env.GetString("RELATED_IMAGE_LIMITADOR", defaultImageVersion)
func GetLimitadorImage() string {
return env.GetString("RELATED_IMAGE_LIMITADOR", defaultImage)
}
2 changes: 1 addition & 1 deletion pkg/limitador/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
)

func TestLimitadorDefaultImage(t *testing.T) {
assert.Equal(t, GetLimitadorImageVersion(), "quay.io/kuadrant/limitador:latest")
assert.Equal(t, GetLimitadorImage(), "quay.io/kuadrant/limitador:latest")
}
11 changes: 8 additions & 3 deletions pkg/limitador/k8s_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

const (
LimitadorRepository = "quay.io/kuadrant/limitador"
StatusEndpoint = "/status"
StatusEndpoint = "/status"
)

func Service(limitador *limitadorv1alpha1.Limitador) *v1.Service {
Expand Down Expand Up @@ -56,11 +55,17 @@ func Service(limitador *limitadorv1alpha1.Limitador) *v1.Service {
func Deployment(limitador *limitadorv1alpha1.Limitador, deploymentOptions DeploymentOptions) *appsv1.Deployment {
replicas := limitador.GetReplicas()

image := GetLimitadorImageVersion()
image := GetLimitadorImage()

// deprecated
if limitador.Spec.Version != nil {
image = fmt.Sprintf("%s:%s", LimitadorRepository, *limitador.Spec.Version)
}

if limitador.Spec.Image != nil {
image = *limitador.Spec.Image
}

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
Expand Down
Loading