From c113c2043fdc342f091abd3a316bc98942f4dbb8 Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Tue, 8 Sep 2020 21:46:56 +0200 Subject: [PATCH] Change SourceRef to use CrossNamespaceSourceReference --- api/v1alpha1/kustomization_types.go | 5 ++--- api/v1alpha1/reference_types.go | 21 +++++++++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 15 +++++++++++++ ...mize.toolkit.fluxcd.io_kustomizations.yaml | 2 ++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/kustomization_types.go b/api/v1alpha1/kustomization_types.go index f47e671..c168e7d 100644 --- a/api/v1alpha1/kustomization_types.go +++ b/api/v1alpha1/kustomization_types.go @@ -50,8 +50,7 @@ type KustomizationSpec struct { // +required Prune bool `json:"prune"` - // A list of workloads (Deployments, DaemonSets and StatefulSets) - // to be included in the health assessment. + // A list of resources to be included in the health assessment. // +optional HealthChecks []CrossNamespaceObjectReference `json:"healthChecks,omitempty"` @@ -61,7 +60,7 @@ type KustomizationSpec struct { // Reference of the source where the kustomization file is. // +required - SourceRef CrossNamespaceObjectReference `json:"sourceRef"` + SourceRef CrossNamespaceSourceReference `json:"sourceRef"` // This flag tells the controller to suspend subsequent kustomize executions, // it does not apply to already started executions. Defaults to false. diff --git a/api/v1alpha1/reference_types.go b/api/v1alpha1/reference_types.go index 9efe4ad..32e327e 100644 --- a/api/v1alpha1/reference_types.go +++ b/api/v1alpha1/reference_types.go @@ -35,3 +35,24 @@ type CrossNamespaceObjectReference struct { // +optional Namespace string `json:"namespace,omitempty"` } + +// CrossNamespaceSourceReference contains enough information to let you locate the +// typed referenced object at cluster level +type CrossNamespaceSourceReference struct { + // API version of the referent + // +optional + APIVersion string `json:"apiVersion,omitempty"` + + // Kind of the referent + // +kubebuilder:validation:Enum=GitRepository + // +required + Kind string `json:"kind"` + + // Name of the referent + // +required + Name string `json:"name"` + + // Namespace of the referent + // +optional + Namespace string `json:"namespace,omitempty"` +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index fc974b6..952c45a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -57,6 +57,21 @@ func (in *CrossNamespaceObjectReference) DeepCopy() *CrossNamespaceObjectReferen return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CrossNamespaceSourceReference) DeepCopyInto(out *CrossNamespaceSourceReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossNamespaceSourceReference. +func (in *CrossNamespaceSourceReference) DeepCopy() *CrossNamespaceSourceReference { + if in == nil { + return nil + } + out := new(CrossNamespaceSourceReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Decryption) DeepCopyInto(out *Decryption) { *out = *in diff --git a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml index 953a307..1622238 100644 --- a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml +++ b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml @@ -133,6 +133,8 @@ spec: type: string kind: description: Kind of the referent + enum: + - GitRepository type: string name: description: Name of the referent