From f1f2d2166abbf4b51616eb4b73e7ff9b0fa02f55 Mon Sep 17 00:00:00 2001 From: Cyril Corbon Date: Wed, 30 Oct 2024 09:32:01 +0100 Subject: [PATCH] feat: allow user to modify imagePullPolicy (#252) Signed-off-by: Cyril Corbon --- api/v1alpha1/dragonfly_types.go | 6 ++++++ api/v1alpha1/zz_generated.deepcopy.go | 2 +- config/crd/bases/dragonflydb.io_dragonflies.yaml | 5 +++++ internal/resources/resources.go | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/dragonfly_types.go b/api/v1alpha1/dragonfly_types.go index b1afd5b..d19b36c 100644 --- a/api/v1alpha1/dragonfly_types.go +++ b/api/v1alpha1/dragonfly_types.go @@ -35,6 +35,12 @@ type DragonflySpec struct { // Image is the Dragonfly image to use Image string `json:"image,omitempty"` + // (Optional) imagePullPolicy to set to Dragonfly, default is Always + // +optional + // +kubebuilder:validation:Optional + // +kubebuilder:default:="Always" + ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` + // (Optional) Dragonfly container args to pass to the container // Refer to the Dragonfly documentation for the list of supported args // +optional diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index ff1ebee..a29946c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -21,7 +21,7 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/config/crd/bases/dragonflydb.io_dragonflies.yaml b/config/crd/bases/dragonflydb.io_dragonflies.yaml index d97c657..fcc5328 100644 --- a/config/crd/bases/dragonflydb.io_dragonflies.yaml +++ b/config/crd/bases/dragonflydb.io_dragonflies.yaml @@ -1180,6 +1180,11 @@ spec: image: description: Image is the Dragonfly image to use type: string + imagePullPolicy: + default: Always + description: (Optional) imagePullPolicy to set to Dragonfly, default + is Always + type: string labels: additionalProperties: type: string diff --git a/internal/resources/resources.go b/internal/resources/resources.go index 3eb1608..547cc2c 100644 --- a/internal/resources/resources.go +++ b/internal/resources/resources.go @@ -148,7 +148,7 @@ func GetDragonflyResources(ctx context.Context, df *resourcesv1.Dragonfly) ([]cl SuccessThreshold: 1, TimeoutSeconds: 5, }, - ImagePullPolicy: corev1.PullAlways, + ImagePullPolicy: df.Spec.ImagePullPolicy, }, }, },