Skip to content

Commit

Permalink
Merge pull request #133 from Kuadrant/image
Browse files Browse the repository at this point in the history
Limitador CRD new field: image
  • Loading branch information
eguzki authored May 13, 2024
2 parents dab1824 + 10eab26 commit 190eea1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
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 @@ -1088,6 +1090,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 @@ -1089,6 +1091,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

0 comments on commit 190eea1

Please sign in to comment.