diff --git a/Makefile b/Makefile index 9bbdc0f..cd69b2f 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ ARCH ?= $(shell go env GOARCH) OS ?= $(shell uname -s | tr A-Z a-z) K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) -TAG ?= main +TAG ?= v0.7.0 .PHONY: all all: build diff --git a/api/v1alpha1/cleaner_types.go b/api/v1alpha1/cleaner_types.go index cc3eac5..a8bc2de 100644 --- a/api/v1alpha1/cleaner_types.go +++ b/api/v1alpha1/cleaner_types.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" + libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" ) // Action specifies the action to take on matching resources @@ -65,7 +65,7 @@ type ResourceSelector struct { Kind string `json:"kind"` // LabelFilters allows to filter resources based on current labels. - LabelFilters []libsveltosv1alpha1.LabelFilter `json:"labelFilters,omitempty"` + LabelFilters []libsveltosv1beta1.LabelFilter `json:"labelFilters,omitempty"` // Evaluate contains a function "evaluate" in lua language. // The function will be passed one of the object selected based on @@ -94,7 +94,7 @@ type ResourcePolicySet struct { } // NotificationType specifies different type of notifications -// +kubebuilder:validation:Enum:=CleanerReport;Slack;Webex;Discord;Teams +// +kubebuilder:validation:Enum:=CleanerReport;Slack;Webex;Discord;Teams;SMTP type NotificationType string const ( diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 7192c9c..3551b57 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -21,9 +21,10 @@ limitations under the License. package v1alpha1 import ( - apiv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" + + "github.com/projectsveltos/libsveltos/api/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -289,7 +290,7 @@ func (in *ResourceSelector) DeepCopyInto(out *ResourceSelector) { *out = *in if in.LabelFilters != nil { in, out := &in.LabelFilters, &out.LabelFilters - *out = make([]apiv1alpha1.LabelFilter, len(*in)) + *out = make([]v1beta1.LabelFilter, len(*in)) copy(*out, *in) } } diff --git a/charts/k8s-cleaner/README.md b/charts/k8s-cleaner/README.md index 9eca0aa..6badb73 100644 --- a/charts/k8s-cleaner/README.md +++ b/charts/k8s-cleaner/README.md @@ -32,7 +32,7 @@ Major Changes to functions are documented with the version affected. **Before up | controller.image.pullPolicy | string | `"IfNotPresent"` | Controller Image pull policy | | controller.image.registry | string | `"docker.io"` | Controller Image Registry | | controller.image.repository | string | `"projectsveltos/k8s-cleaner"` | Controller Image Repository | -| controller.image.tag | string | `"v0.6.0"` | ControllerImage Tag | +| controller.image.tag | string | `"v0.7.0"` | ControllerImage Tag | | controller.livenessProbe | object | `{"enabled":true,"httpGet":{"path":"/healthz","port":"healthz","scheme":"HTTP"},"initialDelaySeconds":15,"periodSeconds":20}` | Controller LivenessProbe | | controller.ports[0].containerPort | int | `8443` | | | controller.ports[0].name | string | `"metrics"` | | diff --git a/charts/k8s-cleaner/crd/apps.projectsveltos.io_cleaners.yaml b/charts/k8s-cleaner/crd/apps.projectsveltos.io_cleaners.yaml index 27b9b03..65869b3 100644 --- a/charts/k8s-cleaner/crd/apps.projectsveltos.io_cleaners.yaml +++ b/charts/k8s-cleaner/crd/apps.projectsveltos.io_cleaners.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.15.0 + controller-gen.kubebuilder.io/version: v0.16.2 name: cleaners.apps.projectsveltos.io spec: group: apps.projectsveltos.io @@ -76,7 +76,6 @@ spec: the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object. - TODO: this design is not final and this field is subject to change in the future. type: string kind: description: |- @@ -113,12 +112,16 @@ spec: - Webex - Discord - Teams + - SMTP type: string required: - name - type type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map resourcePolicySet: description: ResourcePolicySet identifies a group of resources properties: diff --git a/charts/k8s-cleaner/values.yaml b/charts/k8s-cleaner/values.yaml index 83dad37..22cb8ce 100644 --- a/charts/k8s-cleaner/values.yaml +++ b/charts/k8s-cleaner/values.yaml @@ -26,7 +26,7 @@ controller: # -- Controller Image Repository repository: projectsveltos/k8s-cleaner # -- ControllerImage Tag - tag: "v0.6.0" + tag: "v0.7.0" # -- Controller Image pull policy pullPolicy: IfNotPresent # -- Controller ARguments diff --git a/config/crd/bases/apps.projectsveltos.io_cleaners.yaml b/config/crd/bases/apps.projectsveltos.io_cleaners.yaml index 8fcd968..65869b3 100644 --- a/config/crd/bases/apps.projectsveltos.io_cleaners.yaml +++ b/config/crd/bases/apps.projectsveltos.io_cleaners.yaml @@ -112,6 +112,7 @@ spec: - Webex - Discord - Teams + - SMTP type: string required: - name diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index 6812f2a..0d0b424 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: spec: containers: # Change the value of image field below to your controller image URL - - image: docker.io/projectsveltos/k8s-cleaner:main + - image: docker.io/projectsveltos/k8s-cleaner:v0.7.0 name: controller diff --git a/go.mod b/go.mod index 59aa753..a8b3417 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/gomega v1.34.2 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/libsveltos v0.38.1-0.20240910103404-1bd4a057497d + github.com/projectsveltos/libsveltos v0.38.1-0.20240911110859-956cd4d7adda github.com/robfig/cron/v3 v3.0.1 github.com/slack-go/slack v0.14.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index c02c049..6035c28 100644 --- a/go.sum +++ b/go.sum @@ -149,8 +149,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/projectsveltos/libsveltos v0.38.1-0.20240910103404-1bd4a057497d h1:RxnoF/xgBaACvYILpgJn4lU9VgMvBRc3vZv+B0SgcaQ= -github.com/projectsveltos/libsveltos v0.38.1-0.20240910103404-1bd4a057497d/go.mod h1:qlj40eu4Mm1e2d/1/jxQgjevDLM2u/Sk6KE87Tuz67g= +github.com/projectsveltos/libsveltos v0.38.1-0.20240911110859-956cd4d7adda h1:4FrRsZcim4M0uzvgledV0DPAUfhoUkDVI4VvkNv2VI8= +github.com/projectsveltos/libsveltos v0.38.1-0.20240911110859-956cd4d7adda/go.mod h1:qlj40eu4Mm1e2d/1/jxQgjevDLM2u/Sk6KE87Tuz67g= github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= diff --git a/internal/controller/executor/worker.go b/internal/controller/executor/worker.go index c9f2561..ca0bad3 100644 --- a/internal/controller/executor/worker.go +++ b/internal/controller/executor/worker.go @@ -41,7 +41,7 @@ import ( appsv1alpha1 "gianlucam76/k8s-cleaner/api/v1alpha1" - libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" + libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) @@ -336,7 +336,7 @@ func fetchResources(ctx context.Context, resourceSelector *appsv1alpha1.Resource labelFilter += "," } f := resourceSelector.LabelFilters[i] - if f.Operation == libsveltosv1alpha1.OperationEqual { + if f.Operation == libsveltosv1beta1.OperationEqual { labelFilter += fmt.Sprintf("%s=%s", f.Key, f.Value) } else { labelFilter += fmt.Sprintf("%s!=%s", f.Key, f.Value) diff --git a/internal/controller/executor/worker_test.go b/internal/controller/executor/worker_test.go index 5595841..7d16f3f 100644 --- a/internal/controller/executor/worker_test.go +++ b/internal/controller/executor/worker_test.go @@ -33,7 +33,7 @@ import ( appsv1alpha1 "gianlucam76/k8s-cleaner/api/v1alpha1" "gianlucam76/k8s-cleaner/internal/controller/executor" - libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" + libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" ) var _ = Describe("Worker", func() { @@ -192,10 +192,10 @@ var _ = Describe("Worker", func() { Kind: "Secret", Group: "", Version: "v1", - LabelFilters: []libsveltosv1alpha1.LabelFilter{ + LabelFilters: []libsveltosv1beta1.LabelFilter{ { Key: key, - Operation: libsveltosv1alpha1.OperationEqual, + Operation: libsveltosv1beta1.OperationEqual, Value: value, }, }, diff --git a/manifest/manifest.yaml b/manifest/manifest.yaml index a991d28..702d271 100644 --- a/manifest/manifest.yaml +++ b/manifest/manifest.yaml @@ -116,6 +116,7 @@ spec: - Webex - Discord - Teams + - SMTP type: string required: - name @@ -480,7 +481,7 @@ spec: - --diagnostics-address=:8443 command: - /manager - image: docker.io/projectsveltos/k8s-cleaner:main + image: docker.io/projectsveltos/k8s-cleaner:v0.7.0 livenessProbe: failureThreshold: 3 httpGet: