From d0b87ccb63df87b27e5913d0c386e4ee9c8d0fd5 Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Wed, 9 Dec 2020 14:37:38 +0100 Subject: [PATCH] Add image type to API spec Signed-off-by: Somtochi Onyekwere --- api/v1beta1/kustomization_types.go | 19 +++++ api/v1beta1/zz_generated.deepcopy.go | 20 +++++ ...mize.toolkit.fluxcd.io_kustomizations.yaml | 24 ++++++ docs/api/kustomize.md | 82 +++++++++++++++++++ 4 files changed, 145 insertions(+) diff --git a/api/v1beta1/kustomization_types.go b/api/v1beta1/kustomization_types.go index 2f61d806c..0b058942e 100644 --- a/api/v1beta1/kustomization_types.go +++ b/api/v1beta1/kustomization_types.go @@ -67,6 +67,10 @@ type KustomizationSpec struct { // +optional HealthChecks []CrossNamespaceObjectReference `json:"healthChecks,omitempty"` + // A list of images that is used for changing the image name/tag in the kustomization yaml. + // +optional + Images []Image `json:"images,omitempty"` + // The name of the Kubernetes service account to impersonate // when reconciling this Kustomization. // +optional @@ -113,6 +117,21 @@ type Decryption struct { SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` } +// Image contains the name, new name and new tag that will replace the original image. +type Image struct { + // Name of the image to be replaced. + // +required + Name string `json:"name"` + + // NewName is the name of the image used to replace the original one. + // +required + NewName string `json:"newName"` + + // NewTag is the tag used to replace the original tag. + // +required + NewTag string `json:"newTag"` +} + // KubeConfig references a Kubernetes secret that contains a kubeconfig file. type KubeConfig struct { // SecretRef holds the name to a secret that contains a 'value' key with diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index eb2187637..70ff6e3e8 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -77,6 +77,21 @@ func (in *Decryption) DeepCopy() *Decryption { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Image) DeepCopyInto(out *Image) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. +func (in *Image) DeepCopy() *Image { + if in == nil { + return nil + } + out := new(Image) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeConfig) DeepCopyInto(out *KubeConfig) { *out = *in @@ -176,6 +191,11 @@ func (in *KustomizationSpec) DeepCopyInto(out *KustomizationSpec) { *out = make([]CrossNamespaceObjectReference, len(*in)) copy(*out, *in) } + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make([]Image, len(*in)) + copy(*out, *in) + } out.SourceRef = in.SourceRef if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout diff --git a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml index 030fdee4f..6c956bfb2 100644 --- a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml +++ b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml @@ -110,6 +110,30 @@ spec: - name type: object type: array + images: + description: A list of images that is used for changing the image + name/tag in the kustomization yaml. + items: + description: Image contains the name, new name and new tag that + will replace the original image. + properties: + name: + description: Name of the image to be replaced. + type: string + newName: + description: NewName is the name of the image used to replace + the original one. + type: string + newTag: + description: NewTag is the tag used to replace the original + tag. + type: string + required: + - name + - newName + - newTag + type: object + type: array interval: description: The interval at which to reconcile the kustomization. type: string diff --git a/docs/api/kustomize.md b/docs/api/kustomize.md index 168fce115..bdf8eced4 100644 --- a/docs/api/kustomize.md +++ b/docs/api/kustomize.md @@ -164,6 +164,20 @@ bool +images
+ + +[]Image + + + + +(Optional) +

A list of images that is used for changing the image name/tag in the kustomization yaml.

+ + + + serviceAccountName
string @@ -443,6 +457,60 @@ Kubernetes core/v1.LocalObjectReference +

Image +

+

+(Appears on: +KustomizationSpec) +

+

Image contains the name, new name and new tag that will replace the original image.

+
+
+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name of the image to be replaced.

+
+newName
+ +string + +
+

NewName is the name of the image used to replace the original one.

+
+newTag
+ +string + +
+

NewTag is the tag used to replace the original tag.

+
+
+

KubeConfig

@@ -597,6 +665,20 @@ bool +images
+ + +[]Image + + + + +(Optional) +

A list of images that is used for changing the image name/tag in the kustomization yaml.

+ + + + serviceAccountName
string