Skip to content

Commit

Permalink
(feat) Add ability to ignore resource for configuration drift
Browse files Browse the repository at this point in the history
Add field

```yaml
	// IgnoreForConfigurationDrift indicates to not track resource
	// for configuration drift detection.
	IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift"`
```

to Resource. Drift detection manager won't track any resource with such
field set for configuration drift

[Story](projectsveltos/addon-controller#612)
  • Loading branch information
mgianluc committed Jul 2, 2024
1 parent e2d71f6 commit 21c2275
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ GINKGO := $(TOOLS_BIN_DIR)/ginkgo

GOLANGCI_LINT_VERSION := "v1.57.2"

KUSTOMIZE_VER := v4.5.2
KUSTOMIZE_VER := v5.3.0
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5
$(KUSTOMIZE): # Build kustomize from tools folder.
CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)

Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/resourcesummary_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ type Resource struct {

// Version of the resource deployed in the Cluster.
Version string `json:"version"`

// IgnoreForConfigurationDrift indicates to not track resource
// for configuration drift detection.
// +kubebuilder:default:=false
IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift"`
}

type HelmResources struct {
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/v1beta1/resourcesummary_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ type Resource struct {

// Version of the resource deployed in the Cluster.
Version string `json:"version"`

// IgnoreForConfigurationDrift indicates to not track resource
// for configuration drift detection.
// +kubebuilder:default:=false
IgnoreForConfigurationDrift bool `json:"ignoreForConfigurationDrift"`
}

type HelmResources struct {
Expand Down
84 changes: 84 additions & 0 deletions config/crd/bases/lib.projectsveltos.io_resourcesummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -74,6 +80,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand Down Expand Up @@ -103,6 +110,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -121,6 +134,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -134,6 +148,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -152,6 +172,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -171,6 +192,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -189,6 +216,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -208,6 +236,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -226,6 +260,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -244,6 +279,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -262,6 +303,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand Down Expand Up @@ -318,6 +360,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -336,6 +384,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand Down Expand Up @@ -365,6 +414,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -383,6 +438,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -396,6 +452,12 @@ spec:
group:
description: Group of the resource deployed in the Cluster.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -414,6 +476,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -433,6 +496,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -451,6 +520,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -470,6 +540,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -488,6 +564,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand All @@ -506,6 +583,12 @@ spec:
hash:
description: Hash is the hash of a resource's data.
type: string
ignoreForConfigurationDrift:
default: false
description: |-
IgnoreForConfigurationDrift indicates to not track resource
for configuration drift detection.
type: boolean
kind:
description: Kind of the resource deployed in the Cluster.
minLength: 1
Expand All @@ -524,6 +607,7 @@ spec:
type: string
required:
- group
- ignoreForConfigurationDrift
- kind
- name
- version
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.0

require (
github.com/go-logr/logr v1.4.2
github.com/google/gofuzz v1.2.0
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -38,7 +39,6 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
Expand Down
Loading

0 comments on commit 21c2275

Please sign in to comment.