Skip to content

Commit b018472

Browse files
authored
Merge pull request #631 from gianlucam76/main
Merge dev to main
2 parents 0434559 + d9c708f commit b018472

22 files changed

+14506
-400
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ KIND := $(TOOLS_BIN_DIR)/kind
6969
KUBECTL := $(TOOLS_BIN_DIR)/kubectl
7070

7171
GOLANGCI_LINT_VERSION := "v1.57.2"
72-
CLUSTERCTL_VERSION := "v1.7.3"
72+
CLUSTERCTL_VERSION := "v1.7.4"
7373

7474
KUSTOMIZE_VER := v5.3.0
7575
KUSTOMIZE_BIN := kustomize
@@ -267,6 +267,9 @@ create-cluster: $(KIND) $(CLUSTERCTL) $(KUBECTL) $(ENVSUBST) ## Create a new kin
267267
@echo "prepare configMap with kustomize files"
268268
$(KUBECTL) create configmap kustomize --from-file=test/kustomize.tar.gz
269269

270+
@echo "prepare configMap with flux resources"
271+
$(KUBECTL) create configmap install-flux --from-file=test/flux-install.yaml
272+
270273
@echo apply reloader CRD to managed cluster
271274
$(KUBECTL) --kubeconfig=./test/fv/workload_kubeconfig apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/manifests/apiextensions.k8s.io_v1_customresourcedefinition_reloaders.lib.projectsveltos.io.yaml
272275

api/v1alpha1/clusterconfiguration_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ type Resource struct {
5454

5555
// Owner is the list of ConfigMap/Secret containing this resource.
5656
Owner corev1.ObjectReference `json:"owner"`
57+
58+
// IgnoreForConfigurationDrift indicates to not track resource
59+
// for configuration drift detection.
60+
// This field has a meaning only when mode is ContinuousWithDriftDetection
61+
// +kubebuilder:default:=false
62+
// +optional
63+
IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift,omitempty"`
5764
}
5865

5966
type Chart struct {

api/v1alpha1/zz_generated.conversion.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/clusterconfiguration_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ type Resource struct {
5858
// IgnoreForConfigurationDrift indicates to not track resource
5959
// for configuration drift detection.
6060
// This field has a meaning only when mode is ContinuousWithDriftDetection
61-
IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift"`
61+
// +kubebuilder:default:=false
62+
// +optional
63+
IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift,omitempty"`
6264
}
6365

6466
type Chart struct {

api/v1beta1/spec.go

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -507,64 +507,6 @@ type Clusters struct {
507507
Clusters []corev1.ObjectReference `json:"clusters,omitempty"`
508508
}
509509

510-
type PatchSelector struct {
511-
512-
// Version of the API Group to select resources from.
513-
// Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources.
514-
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
515-
// +optional
516-
Version string `json:"version,omitempty"`
517-
518-
// Group is the API group to select resources from.
519-
// Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources.
520-
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
521-
// +optional
522-
Group string `json:"group,omitempty"`
523-
524-
// Kind of the API Group to select resources from.
525-
// Together with Group and Version it is capable of unambiguously
526-
// identifying and/or selecting resources.
527-
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
528-
// +optional
529-
Kind string `json:"kind,omitempty"`
530-
531-
// Namespace to select resources from.
532-
// +optional
533-
Namespace string `json:"namespace,omitempty"`
534-
535-
// Name to match resources with.
536-
// +optional
537-
Name string `json:"name,omitempty"`
538-
539-
// AnnotationSelector is a string that follows the label selection expression
540-
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
541-
// It matches with the resource annotations.
542-
// +optional
543-
AnnotationSelector string `json:"annotationSelector,omitempty"`
544-
545-
// LabelSelector is a string that follows the label selection expression
546-
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
547-
// It matches with the resource labels.
548-
// +optional
549-
LabelSelector string `json:"labelSelector,omitempty"`
550-
}
551-
552-
// Patch contains an inline StrategicMerge or JSON6902 patch, and the target the patch should
553-
// be applied to.
554-
type Patch struct {
555-
// Patch contains an inline StrategicMerge patch or an inline JSON6902 patch with
556-
// an array of operation objects.
557-
// These values can be static or leverage Go templates for dynamic customization.
558-
// When expressed as templates, the values are filled in using information from
559-
// resources within the management cluster before deployment (Cluster and TemplateResourceRefs)
560-
// +required
561-
Patch string `json:"patch,omitempty"`
562-
563-
// Target points to the resources that the patch document should be applied to.
564-
// +optional
565-
Target *PatchSelector `json:"target,omitempty"`
566-
}
567-
568510
type Spec struct {
569511
// ClusterSelector identifies clusters to associate to.
570512
// +optional
@@ -682,7 +624,7 @@ type Spec struct {
682624
// Define additional Kustomize inline Patches applied for all resources on this profile
683625
// Within the Patch Spec you can use templating
684626
// +optional
685-
Patches []Patch `json:"patches,omitempty"`
627+
Patches []libsveltosv1beta1.Patch `json:"patches,omitempty"`
686628

687629
// ExtraLabels: These labels will be added by Sveltos to all Kubernetes resources deployed in
688630
// a managed cluster based on this ClusterProfile/Profile instance.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/config.projectsveltos.io_clusterconfigurations.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ spec:
116116
description: Group of the resource deployed in the
117117
Cluster.
118118
type: string
119+
ignoreForConfigurationDrift:
120+
default: false
121+
description: |-
122+
IgnoreForConfigurationDrift indicates to not track resource
123+
for configuration drift detection.
124+
This field has a meaning only when mode is ContinuousWithDriftDetection
125+
type: boolean
119126
kind:
120127
description: Kind of the resource deployed in the
121128
Cluster.
@@ -281,6 +288,13 @@ spec:
281288
description: Group of the resource deployed in the
282289
Cluster.
283290
type: string
291+
ignoreForConfigurationDrift:
292+
default: false
293+
description: |-
294+
IgnoreForConfigurationDrift indicates to not track resource
295+
for configuration drift detection.
296+
This field has a meaning only when mode is ContinuousWithDriftDetection
297+
type: boolean
284298
kind:
285299
description: Kind of the resource deployed in the
286300
Cluster.
@@ -480,6 +494,7 @@ spec:
480494
Cluster.
481495
type: string
482496
ignoreForConfigurationDrift:
497+
default: false
483498
description: |-
484499
IgnoreForConfigurationDrift indicates to not track resource
485500
for configuration drift detection.
@@ -557,7 +572,6 @@ spec:
557572
type: string
558573
required:
559574
- group
560-
- ignoreForConfigurationDrift
561575
- kind
562576
- name
563577
- owner
@@ -652,6 +666,7 @@ spec:
652666
Cluster.
653667
type: string
654668
ignoreForConfigurationDrift:
669+
default: false
655670
description: |-
656671
IgnoreForConfigurationDrift indicates to not track resource
657672
for configuration drift detection.
@@ -729,7 +744,6 @@ spec:
729744
type: string
730745
required:
731746
- group
732-
- ignoreForConfigurationDrift
733747
- kind
734748
- name
735749
- owner

config/crd/bases/config.projectsveltos.io_clusterreports.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ spec:
8484
group:
8585
description: Group of the resource deployed in the Cluster.
8686
type: string
87+
ignoreForConfigurationDrift:
88+
default: false
89+
description: |-
90+
IgnoreForConfigurationDrift indicates to not track resource
91+
for configuration drift detection.
92+
This field has a meaning only when mode is ContinuousWithDriftDetection
93+
type: boolean
8794
kind:
8895
description: Kind of the resource deployed in the Cluster.
8996
minLength: 1
@@ -230,6 +237,13 @@ spec:
230237
group:
231238
description: Group of the resource deployed in the Cluster.
232239
type: string
240+
ignoreForConfigurationDrift:
241+
default: false
242+
description: |-
243+
IgnoreForConfigurationDrift indicates to not track resource
244+
for configuration drift detection.
245+
This field has a meaning only when mode is ContinuousWithDriftDetection
246+
type: boolean
233247
kind:
234248
description: Kind of the resource deployed in the Cluster.
235249
minLength: 1
@@ -385,6 +399,7 @@ spec:
385399
description: Group of the resource deployed in the Cluster.
386400
type: string
387401
ignoreForConfigurationDrift:
402+
default: false
388403
description: |-
389404
IgnoreForConfigurationDrift indicates to not track resource
390405
for configuration drift detection.
@@ -459,7 +474,6 @@ spec:
459474
type: string
460475
required:
461476
- group
462-
- ignoreForConfigurationDrift
463477
- kind
464478
- name
465479
- owner
@@ -538,6 +552,7 @@ spec:
538552
description: Group of the resource deployed in the Cluster.
539553
type: string
540554
ignoreForConfigurationDrift:
555+
default: false
541556
description: |-
542557
IgnoreForConfigurationDrift indicates to not track resource
543558
for configuration drift detection.
@@ -612,7 +627,6 @@ spec:
612627
type: string
613628
required:
614629
- group
615-
- ignoreForConfigurationDrift
616630
- kind
617631
- name
618632
- owner

controllers/handlers_helm.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
"github.com/projectsveltos/libsveltos/lib/clusterproxy"
6161
"github.com/projectsveltos/libsveltos/lib/deployer"
6262
logs "github.com/projectsveltos/libsveltos/lib/logsettings"
63+
"github.com/projectsveltos/libsveltos/lib/patcher"
6364
"github.com/projectsveltos/libsveltos/lib/utils"
6465
)
6566

@@ -1942,7 +1943,7 @@ func getRecreateValue(options *configv1beta1.HelmOptions) bool {
19421943
return false
19431944
}
19441945

1945-
func getHelmInstallClient(requestedChart *configv1beta1.HelmChart, kubeconfig string, patches []configv1beta1.Patch) (*action.Install, error) {
1946+
func getHelmInstallClient(requestedChart *configv1beta1.HelmChart, kubeconfig string, patches []libsveltosv1beta1.Patch) (*action.Install, error) {
19461947
actionConfig, err := actionConfigInit(requestedChart.ReleaseNamespace, kubeconfig, getEnableClientCacheValue(requestedChart.Options))
19471948
if err != nil {
19481949
return nil, err
@@ -1970,13 +1971,15 @@ func getHelmInstallClient(requestedChart *configv1beta1.HelmChart, kubeconfig st
19701971
installClient.Description = getDescriptionValue(requestedChart.Options)
19711972

19721973
if len(patches) > 0 {
1973-
installClient.PostRenderer = &CustomPatchPostRenderer{Patches: patches}
1974+
installClient.PostRenderer = &patcher.CustomPatchPostRenderer{Patches: patches}
19741975
}
19751976

19761977
return installClient, nil
19771978
}
19781979

1979-
func getHelmUpgradeClient(requestedChart *configv1beta1.HelmChart, actionConfig *action.Configuration, patches []configv1beta1.Patch) (*action.Upgrade, error) {
1980+
func getHelmUpgradeClient(requestedChart *configv1beta1.HelmChart, actionConfig *action.Configuration,
1981+
patches []libsveltosv1beta1.Patch) (*action.Upgrade, error) {
1982+
19801983
upgradeClient := action.NewUpgrade(actionConfig)
19811984
upgradeClient.Install = true
19821985
upgradeClient.Namespace = requestedChart.ReleaseNamespace
@@ -2006,7 +2009,7 @@ func getHelmUpgradeClient(requestedChart *configv1beta1.HelmChart, actionConfig
20062009
upgradeClient.Recreate = getRecreateValue(requestedChart.Options)
20072010

20082011
if len(patches) > 0 {
2009-
upgradeClient.PostRenderer = &CustomPatchPostRenderer{Patches: patches}
2012+
upgradeClient.PostRenderer = &patcher.CustomPatchPostRenderer{Patches: patches}
20102013
}
20112014

20122015
return upgradeClient, nil

controllers/handlers_helm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ var _ = Describe("Hash methods", func() {
601601
kyvernoChart,
602602
nginxChart,
603603
},
604-
Patches: []configv1beta1.Patch{
604+
Patches: []libsveltosv1beta1.Patch{
605605
{
606606
Patch: `- op: add
607607
path: /metadata/labels/environment

0 commit comments

Comments
 (0)