diff --git a/api/go.mod b/api/go.mod index f7aef580..fccd5c16 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,8 +3,8 @@ module github.com/fluxcd/kustomize-controller/api go 1.15 require ( - github.com/fluxcd/pkg/apis/meta v0.6.0 - github.com/fluxcd/pkg/runtime v0.7.0 + github.com/fluxcd/pkg/apis/meta v0.7.0 + github.com/fluxcd/pkg/runtime v0.8.0 k8s.io/api v0.20.2 k8s.io/apimachinery v0.20.2 sigs.k8s.io/controller-runtime v0.8.0 diff --git a/api/go.sum b/api/go.sum index eed88ed3..435ae817 100644 --- a/api/go.sum +++ b/api/go.sum @@ -88,10 +88,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fluxcd/pkg/apis/meta v0.6.0 h1:3ETc/Yz4qXGKLj+Iti6vKFwVE024WX+Jr+jIHlxj7zs= -github.com/fluxcd/pkg/apis/meta v0.6.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po= -github.com/fluxcd/pkg/runtime v0.7.0 h1:AMzqHGae0zqDQAmKwa1htjStk2wphwWF0xQw/zD3FY4= -github.com/fluxcd/pkg/runtime v0.7.0/go.mod h1:1dzGFwtowST5AIW5i9f0Pn0fMhCmOHFyBizuPJSKX+s= +github.com/fluxcd/pkg/apis/meta v0.7.0 h1:5e8gm4OLqjuKWdrOIY5DEEsjcwzyJFK8rCDesJ+V8IY= +github.com/fluxcd/pkg/apis/meta v0.7.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po= +github.com/fluxcd/pkg/runtime v0.8.0 h1:cnSBZJLcXlKgjXpFFFExu+4ZncIxmPgNIx+ErLcCLnA= +github.com/fluxcd/pkg/runtime v0.8.0/go.mod h1:tQwEN+RESjJmtwSSv7I+6bkNM9raIXpGsCjruaIVX6A= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= diff --git a/api/v1beta1/kustomization_types.go b/api/v1beta1/kustomization_types.go index df0949f8..9b2672e2 100644 --- a/api/v1beta1/kustomization_types.go +++ b/api/v1beta1/kustomization_types.go @@ -19,7 +19,6 @@ package v1beta1 import ( "time" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -66,7 +65,7 @@ type KustomizationSpec struct { // A list of resources to be included in the health assessment. // +optional - HealthChecks []CrossNamespaceObjectReference `json:"healthChecks,omitempty"` + HealthChecks []meta.NamespacedObjectKindReference `json:"healthChecks,omitempty"` // A list of images used to override or set the name and tag for container images. // +optional @@ -115,7 +114,7 @@ type Decryption struct { // The secret name containing the private OpenPGP keys used for decryption. // +optional - SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` + SecretRef *meta.LocalObjectReference `json:"secretRef,omitempty"` } // Image contains the name, new name and new tag that will replace the original container image. @@ -144,7 +143,7 @@ type KubeConfig struct { // binaries and credentials to the Pod that is responsible for reconciling // the Kustomization. // +required - SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"` + SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"` } // KustomizationStatus defines the observed state of a kustomization. diff --git a/api/v1beta1/reference_types.go b/api/v1beta1/reference_types.go index 188ecee7..30304862 100644 --- a/api/v1beta1/reference_types.go +++ b/api/v1beta1/reference_types.go @@ -16,26 +16,6 @@ limitations under the License. package v1beta1 -// CrossNamespaceObjectReference contains enough information to let you locate the -// typed referenced object at cluster level -type CrossNamespaceObjectReference struct { - // API version of the referent, defaults to 'apps/v1' - // +optional - APIVersion string `json:"apiVersion,omitempty"` - - // Kind of the referent - // +required - Kind string `json:"kind"` - - // Name of the referent - // +required - Name string `json:"name"` - - // Namespace of the referent - // +optional - Namespace string `json:"namespace,omitempty"` -} - // CrossNamespaceSourceReference contains enough information to let you locate the // typed referenced object at cluster level type CrossNamespaceSourceReference struct { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 70ff6e3e..0a0fa977 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -21,27 +21,12 @@ limitations under the License. package v1beta1 import ( + "github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/runtime/dependency" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CrossNamespaceObjectReference) DeepCopyInto(out *CrossNamespaceObjectReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossNamespaceObjectReference. -func (in *CrossNamespaceObjectReference) DeepCopy() *CrossNamespaceObjectReference { - if in == nil { - return nil - } - out := new(CrossNamespaceObjectReference) - in.DeepCopyInto(out) - 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 @@ -62,7 +47,7 @@ func (in *Decryption) DeepCopyInto(out *Decryption) { *out = *in if in.SecretRef != nil { in, out := &in.SecretRef, &out.SecretRef - *out = new(corev1.LocalObjectReference) + *out = new(meta.LocalObjectReference) **out = **in } } @@ -188,7 +173,7 @@ func (in *KustomizationSpec) DeepCopyInto(out *KustomizationSpec) { } if in.HealthChecks != nil { in, out := &in.HealthChecks, &out.HealthChecks - *out = make([]CrossNamespaceObjectReference, len(*in)) + *out = make([]meta.NamespacedObjectKindReference, len(*in)) copy(*out, *in) } if in.Images != nil { diff --git a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml index 4c6636a3..8216610d 100644 --- a/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml +++ b/config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml @@ -62,9 +62,10 @@ spec: used for decryption. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: Name of the referent type: string + required: + - name type: object required: - provider @@ -90,11 +91,12 @@ spec: healthChecks: description: A list of resources to be included in the health assessment. items: - description: CrossNamespaceObjectReference contains enough information - to let you locate the typed referenced object at cluster level + description: NamespacedObjectKindReference contains enough information + to let you locate the typed referenced object in any namespace properties: apiVersion: - description: API version of the referent, defaults to 'apps/v1' + description: API version of the referent, if not specified the + Kubernetes preferred version will be used type: string kind: description: Kind of the referent @@ -103,7 +105,8 @@ spec: description: Name of the referent type: string namespace: - description: Namespace of the referent + description: Namespace of the referent, when not specified it + acts as LocalObjectReference type: string required: - kind @@ -153,9 +156,10 @@ spec: for reconciling the Kustomization. properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' + description: Name of the referent type: string + required: + - name type: object type: object path: diff --git a/controllers/kustomization_healthcheck.go b/controllers/kustomization_healthcheck.go index 5a370ad5..e6d3f13c 100644 --- a/controllers/kustomization_healthcheck.go +++ b/controllers/kustomization_healthcheck.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "github.com/fluxcd/pkg/apis/meta" "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/cli-utils/pkg/kstatus/polling" "sigs.k8s.io/cli-utils/pkg/kstatus/polling/aggregator" @@ -93,7 +94,7 @@ func (hc *KustomizeHealthCheck) Assess(pollInterval time.Duration) error { return nil } -func (hc *KustomizeHealthCheck) toObjMetadata(cr []kustomizev1.CrossNamespaceObjectReference) ([]object.ObjMetadata, error) { +func (hc *KustomizeHealthCheck) toObjMetadata(cr []meta.NamespacedObjectKindReference) ([]object.ObjMetadata, error) { oo := []object.ObjMetadata{} for _, c := range cr { // For backwards compatibility diff --git a/docs/api/kustomize.md b/docs/api/kustomize.md index f378a809..45b5cd6a 100644 --- a/docs/api/kustomize.md +++ b/docs/api/kustomize.md @@ -155,8 +155,8 @@ bool
healthChecks
-(Appears on: -KustomizationSpec) -
-CrossNamespaceObjectReference contains enough information to let you locate the -typed referenced object at cluster level
-Field | -Description | -
---|---|
-apiVersion - -string - - |
-
-(Optional)
- API version of the referent, defaults to ‘apps/v1’ - |
-
-kind - -string - - |
-
- Kind of the referent - |
-
-name - -string - - |
-
- Name of the referent - |
-
-namespace - -string - - |
-
-(Optional)
- Namespace of the referent - |
-
@@ -446,8 +378,8 @@ string
secretRef
secretRef
healthChecks