From 05750c347eb8801fc38f8cdbc76359395687753e Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Thu, 25 Jan 2024 10:49:00 +0600 Subject: [PATCH] Merge fluxcd-config with default value. Signed-off-by: Rokibul Hasan --- apis/fluxcd/v1alpha1/doc.go | 6 + apis/fluxcd/v1alpha1/fluxcdconfig_types.go | 250 +++++++++--------- apis/fluxcd/v1alpha1/openapi_generated.go | 193 +++++--------- ...n-cluster-management.io_fluxcdconfigs.yaml | 32 --- pkg/manager/helpers.go | 17 +- pkg/manager/manager.go | 4 +- 6 files changed, 220 insertions(+), 282 deletions(-) diff --git a/apis/fluxcd/v1alpha1/doc.go b/apis/fluxcd/v1alpha1/doc.go index 00bf64c2..c2a15422 100644 --- a/apis/fluxcd/v1alpha1/doc.go +++ b/apis/fluxcd/v1alpha1/doc.go @@ -23,3 +23,9 @@ limitations under the License. // +groupName=fluxcd.open-cluster-management.io package v1alpha1 + + + + + + diff --git a/apis/fluxcd/v1alpha1/fluxcdconfig_types.go b/apis/fluxcd/v1alpha1/fluxcdconfig_types.go index 4b0fe57e..108568b4 100644 --- a/apis/fluxcd/v1alpha1/fluxcdconfig_types.go +++ b/apis/fluxcd/v1alpha1/fluxcdconfig_types.go @@ -17,6 +17,8 @@ limitations under the License. package v1alpha1 import ( + + core "k8s.io/api/core/v1" networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,251 +29,251 @@ import ( type FluxCDConfigSpec struct { InstallCRDs bool `json:"installCRDs"` // +optional - CRDs CRDsSpec `json:"crds"` + CRDs CRDsSpec `json:"crds,omitempty"` // +optional - Multitenancy Multitenancy `json:"multitenancy"` + Multitenancy Multitenancy `json:"multitenancy,omitempty"` // +optional - ClusterDomain string `json:"clusterDomain"` + ClusterDomain string `json:"clusterDomain,omitempty"` // +optional - Cli CliSpec `json:"cli"` + Cli CliSpec `json:"cli,omitempty"` // +optional - HelmController ControllerSpec `json:"helmController"` + HelmController ControllerSpec `json:"helmController,omitempty"` // +optional - ImageAutomationController ControllerSpec `json:"imageAutomationController"` + ImageAutomationController ControllerSpec `json:"imageAutomationController,omitempty"` // +optional - ImageReflectionController ControllerSpec `json:"imageReflectionController"` + ImageReflectionController ControllerSpec `json:"imageReflectionController,omitempty"` // +optional - KustomizeController KustomizeControllerSpec `json:"kustomizeController"` + KustomizeController KustomizeControllerSpec `json:"kustomizeController,omitempty"` // +optional - NotificationController NotificationControllerSpec `json:"notificationController"` + NotificationController NotificationControllerSpec `json:"notificationController,omitempty"` // +optional - SourceController SourceControllerSpec `json:"sourceController"` + SourceController SourceControllerSpec `json:"sourceController,omitempty"` // +optional - Policies Policies `json:"policies"` + Policies Policies `json:"policies,omitempty"` // +optional - Rbac Rbac `json:"rbac"` + Rbac Rbac `json:"rbac,omitempty"` // +optional - LogLevel string `json:"logLevel"` + LogLevel string `json:"logLevel,omitempty"` // +optional - WatchAllNamespaces bool `json:"watchAllNamespaces"` + WatchAllNamespaces bool `json:"watchAllNamespaces,omitempty"` // +optional - ImagePullSecrets []core.LocalObjectReference `json:"imagePullSecrets"` + ImagePullSecrets []core.LocalObjectReference `json:"imagePullSecrets,omitempty"` // +optional - ExtraObjects []runtime.RawExtension `json:"extraObjects"` + ExtraObjects []runtime.RawExtension `json:"extraObjects,omitempty"` // +optional - Prometheus PrometheusSpec `json:"prometheus"` + Prometheus PrometheusSpec `json:"prometheus,omitempty"` } type CRDsSpec struct { // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` } type Multitenancy struct { // +optional - Enabled bool `json:"enabled"` + Enabled bool `json:"enabled,omitempty"` // +optional - DefaultServiceAccount string `json:"defaultServiceAccount"` + DefaultServiceAccount string `json:"defaultServiceAccount,omitempty"` // +optional - Privileged bool `json:"privileged"` + Privileged bool `json:"privileged,omitempty"` } type CliSpec struct { // +optional - Image string `json:"image"` + Image string `json:"image,omitempty"` // +optional - Tag string `json:"tag"` + Tag string `json:"tag,omitempty"` // +optional - NodeSelector map[string]string `json:"nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +optional - Affinity core.Affinity `json:"affinity"` + Affinity core.Affinity `json:"affinity,omitempty"` // +optional - Tolerations []core.Toleration `json:"tolerations"` + Tolerations []core.Toleration `json:"tolerations,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` // +optional - ServiceAccount CliServiceAccountSpec `json:"serviceAccount"` + ServiceAccount CliServiceAccountSpec `json:"serviceAccount,omitempty"` } type CliServiceAccountSpec struct { // +optional - Automount bool `json:"automount"` + Automount bool `json:"automount,omitempty"` } type ControllerSpec struct { Create bool `json:"create"` // +optional - Image string `json:"image"` + Image string `json:"image,omitempty"` // +optional - Tag string `json:"tag"` + Tag string `json:"tag,omitempty"` // +optional - Resources ResourceRequirements `json:"resources"` + Resources ResourceRequirements `json:"resources,omitempty"` // +optional - PriorityClassName string `json:"priorityClassName"` + PriorityClassName string `json:"priorityClassName,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` // +optional - Labels map[string]string `json:"labels"` + Labels map[string]string `json:"labels,omitempty"` // +optional - Container ContainerSpec `json:"container"` + Container ContainerSpec `json:"container,omitempty"` // +optional - ExtraEnv []core.EnvVar `json:"extraEnv"` + ExtraEnv []core.EnvVar `json:"extraEnv,omitempty"` // +optional - ServiceAccount ServiceAccountSpec `json:"serviceAccount"` + ServiceAccount ServiceAccountSpec `json:"serviceAccount,omitempty"` // +optional //+kubebuilder:validation:Enum=Always;Never;IfNotPresent;"" - ImagePullPolicy core.PullPolicy `json:"imagePullPolicy"` + ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` // +optional - NodeSelector map[string]string `json:"nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +optional - Affinity core.Affinity `json:"affinity"` + Affinity core.Affinity `json:"affinity,omitempty"` // +optional - Tolerations []core.Toleration `json:"tolerations"` + Tolerations []core.Toleration `json:"tolerations,omitempty"` } type KustomizeControllerSpec struct { Create bool `json:"create"` // +optional - Image string `json:"image"` + Image string `json:"image,omitempty"` // +optional - Tag string `json:"tag"` + Tag string `json:"tag,omitempty"` // +optional - Resources ResourceRequirements `json:"resources"` + Resources ResourceRequirements `json:"resources,omitempty"` // +optional - PriorityClassName string `json:"priorityClassName"` + PriorityClassName string `json:"priorityClassName,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` // +optional - Labels map[string]string `json:"labels"` + Labels map[string]string `json:"labels,omitempty"` // +optional - Container ContainerSpec `json:"container"` + Container ContainerSpec `json:"container,omitempty"` // +optional - EnvFrom EnvFromSource `json:"envFrom"` + EnvFrom EnvFromSource `json:"envFrom,omitempty"` // +optional - ExtraEnv []core.EnvVar `json:"extraEnv"` + ExtraEnv []core.EnvVar `json:"extraEnv,omitempty"` // +optional - ExtraSecretMounts []core.VolumeMount `json:"extraSecretMounts"` + ExtraSecretMounts []core.VolumeMount `json:"extraSecretMounts,omitempty"` // +optional - ServiceAccount ServiceAccountSpec `json:"serviceAccount"` + ServiceAccount ServiceAccountSpec `json:"serviceAccount,omitempty"` // +optional //+kubebuilder:validation:Enum=Always;Never;IfNotPresent;"" - ImagePullPolicy core.PullPolicy `json:"imagePullPolicy"` + ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` // +optional - Secret SecretSpec `json:"secret"` + Secret SecretSpec `json:"secret,omitempty"` // +optional - NodeSelector map[string]string `json:"nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +optional - Affinity core.Affinity `json:"affinity"` + Affinity core.Affinity `json:"affinity,omitempty"` // +optional - Tolerations []core.Toleration `json:"tolerations"` + Tolerations []core.Toleration `json:"tolerations,omitempty"` } type SecretSpec struct { - Create bool `json:"create"` + Create bool `json:"create,omitempty"` // +optional - Name string `json:"name"` + Name string `json:"name,omitempty"` // +optional - Data map[string]string `json:"data"` + Data map[string]string `json:"data,omitempty"` } type NotificationControllerSpec struct { Create bool `json:"create"` // +optional - Image string `json:"image"` + Image string `json:"image,omitempty"` // +optional - Tag string `json:"tag"` + Tag string `json:"tag,omitempty"` // +optional - Resources ResourceRequirements `json:"resources"` + Resources ResourceRequirements `json:"resources,omitempty"` // +optional - PriorityClassName string `json:"priorityClassName"` + PriorityClassName string `json:"priorityClassName,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` // +optional - Labels map[string]string `json:"labels"` + Labels map[string]string `json:"labels,omitempty"` // +optional - Container ContainerSpec `json:"container"` + Container ContainerSpec `json:"container,omitempty"` // +optional - ExtraEnv []core.EnvVar `json:"extraEnv"` + ExtraEnv []core.EnvVar `json:"extraEnv,omitempty"` // +optional - ServiceAccount ServiceAccountSpec `json:"serviceAccount"` + ServiceAccount ServiceAccountSpec `json:"serviceAccount,omitempty"` // +optional //+kubebuilder:validation:Enum=Always;Never;IfNotPresent;"" - ImagePullPolicy core.PullPolicy `json:"imagePullPolicy"` + ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` // +optional - Service ServiceSpec `json:"service"` + Service ServiceSpec `json:"service,omitempty"` // +optional - WebhookReceiver WebhookReceiverSpec `json:"webhookReceiver"` + WebhookReceiver WebhookReceiverSpec `json:"webhookReceiver,omitempty"` // +optional - NodeSelector map[string]string `json:"nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +optional - Affinity core.Affinity `json:"affinity"` + Affinity core.Affinity `json:"affinity,omitempty"` // +optional - Tolerations []core.Toleration `json:"tolerations"` + Tolerations []core.Toleration `json:"tolerations,omitempty"` } type WebhookReceiverSpec struct { // +optional - Service ServiceSpec `json:"service"` + Service ServiceSpec `json:"service,omitempty"` // +optional - Ingress IngressSpec `json:"ingress"` + Ingress IngressSpec `json:"ingress,omitempty"` } type IngressSpec struct { - Create bool `json:"create"` - Annotations map[string]string `json:"annotations"` - Labels map[string]string `json:"labels"` - Hosts []IngressRule `json:"hosts"` - TLS []networking.IngressTLS `json:"tls"` + Create bool `json:"create,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Hosts []IngressRule `json:"hosts,omitempty"` + TLS []networking.IngressTLS `json:"tls,omitempty"` } type IngressRule struct { - Host string `json:"host"` - Paths []HTTPIngressPath `json:"paths"` + Host string `json:"host,omitempty"` + Paths []HTTPIngressPath `json:"paths,omitempty"` } type HTTPIngressPath struct { - Path string `json:"path"` - PathType string `json:"pathType"` + Path string `json:"path,omitempty"` + PathType string `json:"pathType,omitempty"` } type SourceControllerSpec struct { Create bool `json:"create"` // +optional - Image string `json:"image"` + Image string `json:"image,omitempty"` // +optional - Tag string `json:"tag"` + Tag string `json:"tag,omitempty"` // +optional - Resources ResourceRequirements `json:"resources"` + Resources ResourceRequirements `json:"resources,omitempty"` // +optional - PriorityClassName string `json:"priorityClassName"` + PriorityClassName string `json:"priorityClassName,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` // +optional - Labels map[string]string `json:"labels"` + Labels map[string]string `json:"labels,omitempty"` // +optional - Container ContainerSpec `json:"container"` + Container ContainerSpec `json:"container,omitempty"` // +optional - ExtraEnv []core.EnvVar `json:"extraEnv"` + ExtraEnv []core.EnvVar `json:"extraEnv,omitempty"` // +optional - ServiceAccount ServiceAccountSpec `json:"serviceAccount"` + ServiceAccount ServiceAccountSpec `json:"serviceAccount,omitempty"` // +optional //+kubebuilder:validation:Enum=Always;Never;IfNotPresent;"" - ImagePullPolicy core.PullPolicy `json:"imagePullPolicy"` + ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` // +optional - Service ServiceSpec `json:"service"` + Service ServiceSpec `json:"service,omitempty"` // +optional - NodeSelector map[string]string `json:"nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +optional - Affinity core.Affinity `json:"affinity"` + Affinity core.Affinity `json:"affinity,omitempty"` // +optional - Tolerations []core.Toleration `json:"tolerations"` + Tolerations []core.Toleration `json:"tolerations,omitempty"` } type ServiceSpec struct { // +optional - Labels map[string]string `json:"labels"` + Labels map[string]string `json:"labels,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` } // ResourceRequirements describes the compute resource requirements. @@ -279,20 +281,20 @@ type ResourceRequirements struct { // Limits describes the maximum amount of compute resources allowed. // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ // +optional - Limits core.ResourceList `json:"limits"` + Limits core.ResourceList `json:"limits,omitempty"` // Requests describes the minimum amount of compute resources required. // If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, // otherwise to an implementation-defined value. // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ // +optional - Requests core.ResourceList `json:"requests"` + Requests core.ResourceList `json:"requests,omitempty"` } type EnvFromSource struct { // +optional - Map LocalObjectReference `json:"map"` + Map LocalObjectReference `json:"map,omitempty"` // +optional - Secret LocalObjectReference `json:"secret"` + Secret LocalObjectReference `json:"secret,omitempty"` } type LocalObjectReference struct { @@ -300,59 +302,59 @@ type LocalObjectReference struct { // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names // TODO: Add other useful fields. apiVersion, kind, uid? // +optional - Name string `json:"name"` + Name string `json:"name,omitempty"` } type ContainerSpec struct { // +optional - AdditionalArgs []string `json:"additionalArgs"` + AdditionalArgs []string `json:"additionalArgs,omitempty"` } type ServiceAccountSpec struct { - Create bool `json:"create"` + Create bool `json:"create,omitempty"` // +optional - Automount bool `json:"automount"` + Automount bool `json:"automount,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` } type Policies struct { - Create bool `json:"create"` + Create bool `json:"create,omitempty"` } type Rbac struct { - Create bool `json:"create"` + Create bool `json:"create,omitempty"` // +optional - CreateAggregation bool `json:"createAggregation"` + CreateAggregation bool `json:"createAggregation,omitempty"` // +optional - Annotations map[string]string `json:"annotations"` + Annotations map[string]string `json:"annotations,omitempty"` } type PrometheusSpec struct { // +optional - PodMonitor PodMonitorSpec `json:"podMonitor"` + PodMonitor PodMonitorSpec `json:"podMonitor,omitempty"` } type PodMonitorSpec struct { - Create bool `json:"create"` + Create bool `json:"create,omitempty"` // +optional - PodMetricsEndpoints []MetricsEndpoints `json:"podMetricsEndpoints"` + PodMetricsEndpoints []MetricsEndpoints `json:"podMetricsEndpoints,omitempty"` } type MetricsEndpoints struct { // +optional - Port string `json:"port"` + Port string `json:"port,omitempty"` // +optional - Relabelings []Relabeling `json:"relabelings"` + Relabelings []Relabeling `json:"relabelings,omitempty"` } type Relabeling struct { // +optional - SourceLabels []string `json:"sourceLabels"` + SourceLabels []string `json:"sourceLabels,omitempty"` // +optional - Action string `json:"action"` + Action string `json:"action,omitempty"` // +optional - Regex string `json:"regex"` + Regex string `json:"regex,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/apis/fluxcd/v1alpha1/openapi_generated.go b/apis/fluxcd/v1alpha1/openapi_generated.go index 3926bd26..93981556 100644 --- a/apis/fluxcd/v1alpha1/openapi_generated.go +++ b/apis/fluxcd/v1alpha1/openapi_generated.go @@ -417,9 +417,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_CliServiceAccountSpec(ref common.R Properties: map[string]spec.Schema{ "automount": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, }, @@ -436,16 +435,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_CliSpec(ref common.ReferenceCallba Properties: map[string]spec.Schema{ "image": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "tag": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "nodeSelector": { @@ -552,16 +549,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_ControllerSpec(ref common.Referenc }, "image": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "tag": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "resources": { @@ -572,9 +567,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_ControllerSpec(ref common.Referenc }, "priorityClassName": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "annotations": { @@ -635,7 +629,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_ControllerSpec(ref common.Referenc "imagePullPolicy": { SchemaProps: spec.SchemaProps{ Description: "Possible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", - Default: "", Type: []string{"string"}, Format: "", Enum: []interface{}{"Always", "IfNotPresent", "Never"}, @@ -829,9 +822,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_FluxCDConfigSpec(ref common.Refere }, "clusterDomain": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "cli": { @@ -890,16 +882,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_FluxCDConfigSpec(ref common.Refere }, "logLevel": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "watchAllNamespaces": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "imagePullSecrets": { @@ -950,20 +940,17 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_HTTPIngressPath(ref common.Referen Properties: map[string]spec.Schema{ "path": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "pathType": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, - Required: []string{"path", "pathType"}, }, }, } @@ -977,9 +964,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_IngressRule(ref common.ReferenceCa Properties: map[string]spec.Schema{ "host": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "paths": { @@ -996,7 +982,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_IngressRule(ref common.ReferenceCa }, }, }, - Required: []string{"host", "paths"}, }, }, Dependencies: []string{ @@ -1012,9 +997,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_IngressSpec(ref common.ReferenceCa Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "annotations": { @@ -1074,7 +1058,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_IngressSpec(ref common.ReferenceCa }, }, }, - Required: []string{"create", "annotations", "labels", "hosts", "tls"}, }, }, Dependencies: []string{ @@ -1097,16 +1080,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_KustomizeControllerSpec(ref common }, "image": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "tag": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "resources": { @@ -1117,9 +1098,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_KustomizeControllerSpec(ref common }, "priorityClassName": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "annotations": { @@ -1199,7 +1179,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_KustomizeControllerSpec(ref common "imagePullPolicy": { SchemaProps: spec.SchemaProps{ Description: "Possible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", - Default: "", Type: []string{"string"}, Format: "", Enum: []interface{}{"Always", "IfNotPresent", "Never"}, @@ -1263,7 +1242,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_LocalObjectReference(ref common.Re "name": { SchemaProps: spec.SchemaProps{ Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", - Default: "", Type: []string{"string"}, Format: "", }, @@ -1282,9 +1260,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_MetricsEndpoints(ref common.Refere Properties: map[string]spec.Schema{ "port": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "relabelings": { @@ -1316,23 +1293,20 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_Multitenancy(ref common.ReferenceC Properties: map[string]spec.Schema{ "enabled": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "defaultServiceAccount": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "privileged": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, }, @@ -1356,16 +1330,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_NotificationControllerSpec(ref com }, "image": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "tag": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "resources": { @@ -1376,9 +1348,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_NotificationControllerSpec(ref com }, "priorityClassName": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "annotations": { @@ -1439,7 +1410,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_NotificationControllerSpec(ref com "imagePullPolicy": { SchemaProps: spec.SchemaProps{ Description: "Possible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", - Default: "", Type: []string{"string"}, Format: "", Enum: []interface{}{"Always", "IfNotPresent", "Never"}, @@ -1508,9 +1478,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_PodMonitorSpec(ref common.Referenc Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "podMetricsEndpoints": { @@ -1527,7 +1496,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_PodMonitorSpec(ref common.Referenc }, }, }, - Required: []string{"create"}, }, }, Dependencies: []string{ @@ -1543,13 +1511,11 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_Policies(ref common.ReferenceCallb Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, }, - Required: []string{"create"}, }, }, } @@ -1583,16 +1549,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_Rbac(ref common.ReferenceCallback) Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "createAggregation": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "annotations": { @@ -1611,7 +1575,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_Rbac(ref common.ReferenceCallback) }, }, }, - Required: []string{"create"}, }, }, } @@ -1639,16 +1602,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_Relabeling(ref common.ReferenceCal }, "action": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "regex": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1708,16 +1669,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_SecretSpec(ref common.ReferenceCal Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "name": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "data": { @@ -1736,7 +1695,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_SecretSpec(ref common.ReferenceCal }, }, }, - Required: []string{"create"}, }, }, } @@ -1750,16 +1708,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_ServiceAccountSpec(ref common.Refe Properties: map[string]spec.Schema{ "create": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "automount": { SchemaProps: spec.SchemaProps{ - Default: false, - Type: []string{"boolean"}, - Format: "", + Type: []string{"boolean"}, + Format: "", }, }, "annotations": { @@ -1778,7 +1734,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_ServiceAccountSpec(ref common.Refe }, }, }, - Required: []string{"create"}, }, }, } @@ -1841,16 +1796,14 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_SourceControllerSpec(ref common.Re }, "image": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "tag": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "resources": { @@ -1861,9 +1814,8 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_SourceControllerSpec(ref common.Re }, "priorityClassName": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, "annotations": { @@ -1924,7 +1876,6 @@ func schema_fluxcd_addon_apis_fluxcd_v1alpha1_SourceControllerSpec(ref common.Re "imagePullPolicy": { SchemaProps: spec.SchemaProps{ Description: "Possible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present", - Default: "", Type: []string{"string"}, Format: "", Enum: []interface{}{"Always", "IfNotPresent", "Never"}, diff --git a/crds/fluxcd.open-cluster-management.io_fluxcdconfigs.yaml b/crds/fluxcd.open-cluster-management.io_fluxcdconfigs.yaml index 5c6dd22e..10d7f103 100644 --- a/crds/fluxcd.open-cluster-management.io_fluxcdconfigs.yaml +++ b/crds/fluxcd.open-cluster-management.io_fluxcdconfigs.yaml @@ -1013,8 +1013,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string @@ -1569,8 +1567,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string @@ -2133,8 +2129,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string @@ -2724,8 +2718,6 @@ spec: type: object name: type: string - required: - - create type: object serviceAccount: properties: @@ -2737,8 +2729,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string @@ -3315,8 +3305,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string @@ -3358,14 +3346,8 @@ spec: type: string pathType: type: string - required: - - path - - pathType type: object type: array - required: - - host - - paths type: object type: array labels: @@ -3384,12 +3366,6 @@ spec: type: string type: object type: array - required: - - annotations - - create - - hosts - - labels - - tls type: object service: properties: @@ -3410,8 +3386,6 @@ spec: properties: create: type: boolean - required: - - create type: object prometheus: properties: @@ -3439,8 +3413,6 @@ spec: type: array type: object type: array - required: - - create type: object type: object rbac: @@ -3453,8 +3425,6 @@ spec: type: boolean createAggregation: type: boolean - required: - - create type: object sourceController: properties: @@ -3999,8 +3969,6 @@ spec: type: boolean create: type: boolean - required: - - create type: object tag: type: string diff --git a/pkg/manager/helpers.go b/pkg/manager/helpers.go index d042cea8..d9907507 100644 --- a/pkg/manager/helpers.go +++ b/pkg/manager/helpers.go @@ -19,8 +19,8 @@ package manager import ( "context" "fmt" - fluxcnfv1alpha "github.com/kluster-manager/fluxcd-addon/apis/fluxcd/v1alpha1" + "sigs.k8s.io/yaml" "k8s.io/apimachinery/pkg/types" "open-cluster-management.io/addon-framework/pkg/addonfactory" @@ -70,7 +70,20 @@ func GetConfigValues(kc client.Client) addonfactory.GetValuesFunc { overrideValues = addonfactory.MergeValues(overrideValues, values) } - return overrideValues, nil + data, err := FS.ReadFile("agent-manifests/flux2/values.yaml") + if err != nil { + return nil, err + } + + var defaultValues map[string]any + err = yaml.Unmarshal(data, &defaultValues) + if err != nil { + return nil, err + } + + configValues := addonfactory.MergeValues(defaultValues, overrideValues) + + return configValues, nil } } diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index eb69c627..acbd7d9e 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -37,9 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -//go:embed agent-manifests -//go:embed agent-manifests/flux2 -//go:embed agent-manifests/flux2/templates/_helper.tpl +//go:embed all:agent-manifests var FS embed.FS const (