diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3f612267..31e8b7d4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,11 +14,11 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # tag=v4.1.5 - name: Set up Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: - go-version: 1.22.7 + go-version: 1.23.4 - name: Build run: make build - name: FMT @@ -33,11 +33,11 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # tag=v4.1.5 - name: Set up Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: - go-version: 1.22.7 + go-version: 1.23.4 - name: ut run: make test env: diff --git a/.golangci.yaml b/.golangci.yaml index 167222d2..b73e0bc4 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -33,7 +33,7 @@ linters-settings: min-complexity: 20 goimports: local-prefixes: github.com/projectsveltos - mnd: + gomnd: checks: argument,case,condition,return gomodguard: # Although this is almost empty, we will evolve the list below with the diff --git a/Dockerfile b/Dockerfile index ab5722ac..fc0b8ac2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.22.7 AS builder +FROM golang:1.23.4 AS builder ARG ARCH ARG GIT_VERSION=unknown diff --git a/Makefile b/Makefile index 1592730f..7405f7c7 100644 --- a/Makefile +++ b/Makefile @@ -35,16 +35,16 @@ KUBECTL := $(TOOLS_BIN_DIR)/kubectl SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup_envs CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen -GOLANGCI_LINT_VERSION := "v1.61.0" +GOLANGCI_LINT_VERSION := "v1.62.2" -KUSTOMIZE_VER := v5.3.0 +KUSTOMIZE_VER := v4.5.2 KUSTOMIZE_BIN := kustomize KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)) -KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5 +KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE): # Build kustomize from tools folder. CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER) -CONVERSION_GEN_VER := v0.31.0 +CONVERSION_GEN_VER := v0.32.0 CONVERSION_GEN_BIN := conversion-gen # We are intentionally using the binary without version suffix, to avoid the version # in generated files. @@ -120,25 +120,12 @@ generate: ## Run all generate-manifests-*, generate-go-deepcopy-* echo "---" >> manifest/manifest.yaml cat tmp/apiextensions.k8s.io_v1_customresourcedefinition_snapshots.utils.projectsveltos.io.yaml >> manifest/manifest.yaml echo "---" >> manifest/manifest.yaml - cat tmp/apiextensions.k8s.io_v1_customresourcedefinition_techsupports.utils.projectsveltos.io.yaml >> manifest/manifest.yaml rm -rf tmp MANIFEST_IMG=$(SVELTOSCTL_IMG) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image $(MAKE) fmt -.PHONY: generate-go-conversions -generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code for utils.projectsveltos.io api - $(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1" - $(CONVERSION_GEN) \ - --output-file=zz_generated.conversion.go \ - --go-header-file=./hack/boilerplate.generatego.txt \ - ./api/v1alpha1 - -.PHONY: clean-generated-conversions -clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs. Example SRC_DIRS="./api/v1alpha4" - (IFS=','; for i in $(SRC_DIRS); do find $$i -type f -name 'zz_generated.conversion*' -exec rm -f {} \;; done) - set-manifest-image: - sed -i'' -e 's@image: .*@image: '"docker.io/${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./manifest/manifest.yaml + sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./manifest/manifest.yaml .PHONY: generate-go-deepcopy generate-go-deepcopy: $(CONTROLLER_GEN) ## Run all generate-go-deepcopy-* targets diff --git a/README.md b/README.md index 1c1a938c..e206e527 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,6 @@ You might also want to change the timezone of sveltosctl pod by using specific t - [Multi-tenancy: display admin permissions](#multi-tenancy-display-admin-permissions) - [Log severity settings](#log-severity-settings) - [Display outcome of ClusterProfile/Profile in DryRun mode](#display-outcome-of-clusterprofile-in-dryrun-mode) - - [Techsupport](#techsupport) - - [list](#list) - [Snapshot](#snapshot) - [list](#list-1) - [diff](#diff) @@ -248,57 +246,6 @@ Usage: --profile= Show which Kubernetes addons would change because of this clusterprofile/profile. If not specified all clusterprofiles/profiles are considered. ``` -## Techsupport - -When running sveltosctl as pod in the management cluster, it can take collect techsupports (both logs and resources). - -Define a Techsupport instance, following for instance will collect a techsupport every hour, collecting: - -1. logs for all pods in kube-system namespace (last 10 minutes,i.e, 600 seconds, of logs); -2. All Secrets and Deployments - -from all managed clusters matching cluster selectors __env=fv__ - -``` -apiVersion: utils.projectsveltos.io/v1beta1 -kind: Techsupport -metadata: - name: hourly -spec: - clusterSelector: - matchLabels: - env: fv - schedule: “00 * * * *” - storage: /techsupport - logs: - - namespace: kube-system - sinceSeconds: 600 - resources: - - group: “” - version: v1 - kind: Secret - - group: “” - version: v1 - kind: Deployment -``` - -where field _schedule_ is defined in [Cron format](https://en.wikipedia.org/wiki/Cron). - - -### list - -**techsupport list** can be used to display all collected techsupports: - -``` -kubectl exec -it -n projectsveltos sveltosctl-0 -- ./sveltosctl techsupport list --techsupport=hourly -+--------------------+---------------------+ -| TECHSUPPORT POLICY | DATE | -+--------------------+---------------------+ -| hourly | 2022-10-10:22:00:00 | -| hourly | 2022-10-10:23:00:00 | -+--------------------+---------------------+ -``` - ## Snapshot When running sveltosctl as pod in the management cluster, it can take configuration snapshot. diff --git a/api/v1alpha1/techsupport_conversion.go b/api/v1alpha1/techsupport_conversion.go deleted file mode 100644 index 2e602403..00000000 --- a/api/v1alpha1/techsupport_conversion.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -Copyright 2024. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "fmt" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apimachineryconversion "k8s.io/apimachinery/pkg/conversion" - "sigs.k8s.io/controller-runtime/pkg/conversion" - - libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" -) - -// ConvertTo converts v1alpha1 to the Hub version (v1beta1). -func (src *Techsupport) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*utilsv1beta1.Techsupport) - err := Convert_v1alpha1_Techsupport_To_v1beta1_Techsupport(src, dst, nil) - if err != nil { - return err - } - - if src.Spec.ClusterSelector == "" { - dst.Spec.ClusterSelector.LabelSelector = metav1.LabelSelector{} - } - - return nil -} - -// ConvertFrom converts from the Hub version (v1beta1) to this v1alpha1. -func (dst *Techsupport) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*utilsv1beta1.Techsupport) - err := Convert_v1beta1_Techsupport_To_v1alpha1_Techsupport(src, dst, nil) - if err != nil { - return err - } - - if src.Spec.ClusterSelector.MatchLabels == nil { - dst.Spec.ClusterSelector = "" - } - - return nil -} - -func Convert_v1alpha1_TechsupportSpec_To_v1beta1_TechsupportSpec(srcSpec *TechsupportSpec, dstSpec *utilsv1beta1.TechsupportSpec, - scope apimachineryconversion.Scope) error { - - if err := autoConvert_v1alpha1_TechsupportSpec_To_v1beta1_TechsupportSpec(srcSpec, dstSpec, nil); err != nil { - return err - } - - labelSelector, err := metav1.ParseToLabelSelector(string(srcSpec.ClusterSelector)) - if err != nil { - return fmt.Errorf("error converting labels.Selector to metav1.Selector: %w", err) - } - dstSpec.ClusterSelector = libsveltosv1beta1.Selector{LabelSelector: *labelSelector} - - return nil -} - -func Convert_v1beta1_TechsupportSpec_To_v1alpha1_TechsupportSpec(srcSpec *utilsv1beta1.TechsupportSpec, dstSpec *TechsupportSpec, - scope apimachineryconversion.Scope) error { - - if err := autoConvert_v1beta1_TechsupportSpec_To_v1alpha1_TechsupportSpec(srcSpec, dstSpec, nil); err != nil { - return err - } - - labelSelector, err := srcSpec.ClusterSelector.ToSelector() - if err != nil { - return fmt.Errorf("failed to convert : %w", err) - } - - dstSpec.ClusterSelector = libsveltosv1alpha1.Selector(labelSelector.String()) - - return nil -} diff --git a/api/v1alpha1/techsupport_types.go b/api/v1alpha1/techsupport_types.go deleted file mode 100644 index 98d062d5..00000000 --- a/api/v1alpha1/techsupport_types.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright 2022. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" -) - -const ( - // TechsupportFinalizer allows TechsupportReconciler to clean up resources associated with - // Techsupport instance before removing it from the apiserver. - TechsupportFinalizer = "techsupportfinalizer.projectsveltos.io" -) - -// Resource indicates the type of resources to collect. -type Resource struct { - // Namespace of the resource deployed in the Cluster. - // Empty for resources scoped at cluster level. - // +optional - Namespace string `json:"namespace,omitempty"` - - // Group of the resource deployed in the Cluster. - Group string `json:"group"` - - // Version of the resource deployed in the Cluster. - Version string `json:"version"` - - // Kind of the resource deployed in the Cluster. - // +kubebuilder:validation:MinLength=1 - Kind string `json:"kind"` - - // LabelFilters allows to filter resources based on current labels. - LabelFilters []libsveltosv1alpha1.LabelFilter `json:"labelFilters,omitempty"` -} - -// LogFilter allows to select which logs to collect -type Log struct { - // Namespace of the pods deployed in the Cluster. - // +optional - Namespace string `json:"namespace,omitempty"` - - // LabelFilters allows to filter pods based on current labels. - LabelFilters []libsveltosv1alpha1.LabelFilter `json:"labelFilters,omitempty"` - - // A relative time in seconds before the current time from which to collect logs. - // If this value precedes the time a pod was started, only logs since the pod start will be returned. - // If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - // +optional - SinceSeconds *int64 `json:"sinceSeconds,omitempty"` -} - -// TechsupportSpec defines the desired state of Techsupport -type TechsupportSpec struct { - // ClusterSelector identifies clusters to collect techsupport from. - ClusterSelector libsveltosv1alpha1.Selector `json:"clusterSelector"` - - // Resources indicates what resorces to collect - // +optional - Resources []Resource `json:"resources,omitempty"` - - // Logs indicates what pods' log to collect - // +optional - Logs []Log `json:"logs,omitempty"` - - // If set denerates a tar file with all collected logs/resources - // +kubebuilder:default:=false - // +optional - Tar bool `json:"tar,omitempty"` - - // Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - Schedule string `json:"schedule"` - - // Optional deadline in seconds for starting the job if it misses scheduled - // time for any reason. Missed jobs executions will be counted as failed ones. - // +optional - StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - - // Storage represents directory where techsupports will be stored. - // It must be an existing directory. - // Techsupports will be stored in this directory in a subdirectory named - // with Techsupport instance name. - Storage string `json:"storage"` - - // The number of successful finished techsupport to retains. - // If specified, only SuccessfulTechsupportLimit will be retained. Once such - // number is reached, for any new successful snapshots, the oldest one is - // deleted. - // +optional - SuccessfulTechsupportLimit *int32 `json:"successfulTechsupportLimit,omitempty"` -} - -// TechsupportStatus defines the observed state of Techsupport -type TechsupportStatus struct { - // Information when next snapshot is scheduled - // +optional - NextScheduleTime *metav1.Time `json:"nextScheduleTime,omitempty"` - - // Information when was the last time a snapshot was successfully scheduled. - // +optional - LastRunTime *metav1.Time `json:"lastRunTime,omitempty"` - - // Status indicates what happened to last techsupport collection. - LastRunStatus *CollectionStatus `json:"lastRunStatus,omitempty"` - - // FailureMessage provides more information about the error, if - // any occurred - FailureMessage *string `json:"failureMessage,omitempty"` - - // MatchingClusterRefs reference all the clusters currently matching - // Techsupport - MatchingClusterRefs []corev1.ObjectReference `json:"machingClusters,omitempty"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:resource:path=techsupports,scope=Cluster -//+kubebuilder:subresource:status - -// Techsupport is the Schema for the snapshot API -type Techsupport struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec TechsupportSpec `json:"spec,omitempty"` - Status TechsupportStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// TechsupportList contains a list of Techsupport instances -type TechsupportList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Techsupport `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Techsupport{}, &TechsupportList{}) -} diff --git a/api/v1alpha1/zz_generated.conversion.go b/api/v1alpha1/zz_generated.conversion.go index f1498763..47c50433 100644 --- a/api/v1alpha1/zz_generated.conversion.go +++ b/api/v1alpha1/zz_generated.conversion.go @@ -23,13 +23,10 @@ package v1alpha1 import ( unsafe "unsafe" - corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - apiv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" - apiv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" v1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" ) @@ -40,26 +37,6 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { - if err := s.AddGeneratedConversionFunc((*Log)(nil), (*v1beta1.Log)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Log_To_v1beta1_Log(a.(*Log), b.(*v1beta1.Log), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta1.Log)(nil), (*Log)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_Log_To_v1alpha1_Log(a.(*v1beta1.Log), b.(*Log), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*Resource)(nil), (*v1beta1.Resource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Resource_To_v1beta1_Resource(a.(*Resource), b.(*v1beta1.Resource), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta1.Resource)(nil), (*Resource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_Resource_To_v1alpha1_Resource(a.(*v1beta1.Resource), b.(*Resource), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*Snapshot)(nil), (*v1beta1.Snapshot)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_Snapshot_To_v1beta1_Snapshot(a.(*Snapshot), b.(*v1beta1.Snapshot), scope) }); err != nil { @@ -100,101 +77,9 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*Techsupport)(nil), (*v1beta1.Techsupport)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Techsupport_To_v1beta1_Techsupport(a.(*Techsupport), b.(*v1beta1.Techsupport), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta1.Techsupport)(nil), (*Techsupport)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_Techsupport_To_v1alpha1_Techsupport(a.(*v1beta1.Techsupport), b.(*Techsupport), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*TechsupportList)(nil), (*v1beta1.TechsupportList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_TechsupportList_To_v1beta1_TechsupportList(a.(*TechsupportList), b.(*v1beta1.TechsupportList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta1.TechsupportList)(nil), (*TechsupportList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_TechsupportList_To_v1alpha1_TechsupportList(a.(*v1beta1.TechsupportList), b.(*TechsupportList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*TechsupportStatus)(nil), (*v1beta1.TechsupportStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus(a.(*TechsupportStatus), b.(*v1beta1.TechsupportStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta1.TechsupportStatus)(nil), (*TechsupportStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus(a.(*v1beta1.TechsupportStatus), b.(*TechsupportStatus), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*TechsupportSpec)(nil), (*v1beta1.TechsupportSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_TechsupportSpec_To_v1beta1_TechsupportSpec(a.(*TechsupportSpec), b.(*v1beta1.TechsupportSpec), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*v1beta1.TechsupportSpec)(nil), (*TechsupportSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_TechsupportSpec_To_v1alpha1_TechsupportSpec(a.(*v1beta1.TechsupportSpec), b.(*TechsupportSpec), scope) - }); err != nil { - return err - } - return nil -} - -func autoConvert_v1alpha1_Log_To_v1beta1_Log(in *Log, out *v1beta1.Log, s conversion.Scope) error { - out.Namespace = in.Namespace - out.LabelFilters = *(*[]apiv1beta1.LabelFilter)(unsafe.Pointer(&in.LabelFilters)) - out.SinceSeconds = (*int64)(unsafe.Pointer(in.SinceSeconds)) - return nil -} - -// Convert_v1alpha1_Log_To_v1beta1_Log is an autogenerated conversion function. -func Convert_v1alpha1_Log_To_v1beta1_Log(in *Log, out *v1beta1.Log, s conversion.Scope) error { - return autoConvert_v1alpha1_Log_To_v1beta1_Log(in, out, s) -} - -func autoConvert_v1beta1_Log_To_v1alpha1_Log(in *v1beta1.Log, out *Log, s conversion.Scope) error { - out.Namespace = in.Namespace - out.LabelFilters = *(*[]apiv1alpha1.LabelFilter)(unsafe.Pointer(&in.LabelFilters)) - out.SinceSeconds = (*int64)(unsafe.Pointer(in.SinceSeconds)) - return nil -} - -// Convert_v1beta1_Log_To_v1alpha1_Log is an autogenerated conversion function. -func Convert_v1beta1_Log_To_v1alpha1_Log(in *v1beta1.Log, out *Log, s conversion.Scope) error { - return autoConvert_v1beta1_Log_To_v1alpha1_Log(in, out, s) -} - -func autoConvert_v1alpha1_Resource_To_v1beta1_Resource(in *Resource, out *v1beta1.Resource, s conversion.Scope) error { - out.Namespace = in.Namespace - out.Group = in.Group - out.Version = in.Version - out.Kind = in.Kind - out.LabelFilters = *(*[]apiv1beta1.LabelFilter)(unsafe.Pointer(&in.LabelFilters)) return nil } -// Convert_v1alpha1_Resource_To_v1beta1_Resource is an autogenerated conversion function. -func Convert_v1alpha1_Resource_To_v1beta1_Resource(in *Resource, out *v1beta1.Resource, s conversion.Scope) error { - return autoConvert_v1alpha1_Resource_To_v1beta1_Resource(in, out, s) -} - -func autoConvert_v1beta1_Resource_To_v1alpha1_Resource(in *v1beta1.Resource, out *Resource, s conversion.Scope) error { - out.Namespace = in.Namespace - out.Group = in.Group - out.Version = in.Version - out.Kind = in.Kind - out.LabelFilters = *(*[]apiv1alpha1.LabelFilter)(unsafe.Pointer(&in.LabelFilters)) - return nil -} - -// Convert_v1beta1_Resource_To_v1alpha1_Resource is an autogenerated conversion function. -func Convert_v1beta1_Resource_To_v1alpha1_Resource(in *v1beta1.Resource, out *Resource, s conversion.Scope) error { - return autoConvert_v1beta1_Resource_To_v1alpha1_Resource(in, out, s) -} - func autoConvert_v1alpha1_Snapshot_To_v1beta1_Snapshot(in *Snapshot, out *v1beta1.Snapshot, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1alpha1_SnapshotSpec_To_v1beta1_SnapshotSpec(&in.Spec, &out.Spec, s); err != nil { @@ -300,129 +185,3 @@ func autoConvert_v1beta1_SnapshotStatus_To_v1alpha1_SnapshotStatus(in *v1beta1.S func Convert_v1beta1_SnapshotStatus_To_v1alpha1_SnapshotStatus(in *v1beta1.SnapshotStatus, out *SnapshotStatus, s conversion.Scope) error { return autoConvert_v1beta1_SnapshotStatus_To_v1alpha1_SnapshotStatus(in, out, s) } - -func autoConvert_v1alpha1_Techsupport_To_v1beta1_Techsupport(in *Techsupport, out *v1beta1.Techsupport, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1alpha1_TechsupportSpec_To_v1beta1_TechsupportSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha1_Techsupport_To_v1beta1_Techsupport is an autogenerated conversion function. -func Convert_v1alpha1_Techsupport_To_v1beta1_Techsupport(in *Techsupport, out *v1beta1.Techsupport, s conversion.Scope) error { - return autoConvert_v1alpha1_Techsupport_To_v1beta1_Techsupport(in, out, s) -} - -func autoConvert_v1beta1_Techsupport_To_v1alpha1_Techsupport(in *v1beta1.Techsupport, out *Techsupport, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_TechsupportSpec_To_v1alpha1_TechsupportSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_Techsupport_To_v1alpha1_Techsupport is an autogenerated conversion function. -func Convert_v1beta1_Techsupport_To_v1alpha1_Techsupport(in *v1beta1.Techsupport, out *Techsupport, s conversion.Scope) error { - return autoConvert_v1beta1_Techsupport_To_v1alpha1_Techsupport(in, out, s) -} - -func autoConvert_v1alpha1_TechsupportList_To_v1beta1_TechsupportList(in *TechsupportList, out *v1beta1.TechsupportList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]v1beta1.Techsupport, len(*in)) - for i := range *in { - if err := Convert_v1alpha1_Techsupport_To_v1beta1_Techsupport(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1alpha1_TechsupportList_To_v1beta1_TechsupportList is an autogenerated conversion function. -func Convert_v1alpha1_TechsupportList_To_v1beta1_TechsupportList(in *TechsupportList, out *v1beta1.TechsupportList, s conversion.Scope) error { - return autoConvert_v1alpha1_TechsupportList_To_v1beta1_TechsupportList(in, out, s) -} - -func autoConvert_v1beta1_TechsupportList_To_v1alpha1_TechsupportList(in *v1beta1.TechsupportList, out *TechsupportList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Techsupport, len(*in)) - for i := range *in { - if err := Convert_v1beta1_Techsupport_To_v1alpha1_Techsupport(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_TechsupportList_To_v1alpha1_TechsupportList is an autogenerated conversion function. -func Convert_v1beta1_TechsupportList_To_v1alpha1_TechsupportList(in *v1beta1.TechsupportList, out *TechsupportList, s conversion.Scope) error { - return autoConvert_v1beta1_TechsupportList_To_v1alpha1_TechsupportList(in, out, s) -} - -func autoConvert_v1alpha1_TechsupportSpec_To_v1beta1_TechsupportSpec(in *TechsupportSpec, out *v1beta1.TechsupportSpec, s conversion.Scope) error { - // WARNING: in.ClusterSelector requires manual conversion: inconvertible types (github.com/projectsveltos/libsveltos/api/v1alpha1.Selector vs github.com/projectsveltos/libsveltos/api/v1beta1.Selector) - out.Resources = *(*[]v1beta1.Resource)(unsafe.Pointer(&in.Resources)) - out.Logs = *(*[]v1beta1.Log)(unsafe.Pointer(&in.Logs)) - out.Tar = in.Tar - out.Schedule = in.Schedule - out.StartingDeadlineSeconds = (*int64)(unsafe.Pointer(in.StartingDeadlineSeconds)) - out.Storage = in.Storage - out.SuccessfulTechsupportLimit = (*int32)(unsafe.Pointer(in.SuccessfulTechsupportLimit)) - return nil -} - -func autoConvert_v1beta1_TechsupportSpec_To_v1alpha1_TechsupportSpec(in *v1beta1.TechsupportSpec, out *TechsupportSpec, s conversion.Scope) error { - // WARNING: in.ClusterSelector requires manual conversion: inconvertible types (github.com/projectsveltos/libsveltos/api/v1beta1.Selector vs github.com/projectsveltos/libsveltos/api/v1alpha1.Selector) - out.Resources = *(*[]Resource)(unsafe.Pointer(&in.Resources)) - out.Logs = *(*[]Log)(unsafe.Pointer(&in.Logs)) - out.Tar = in.Tar - out.Schedule = in.Schedule - out.StartingDeadlineSeconds = (*int64)(unsafe.Pointer(in.StartingDeadlineSeconds)) - out.Storage = in.Storage - out.SuccessfulTechsupportLimit = (*int32)(unsafe.Pointer(in.SuccessfulTechsupportLimit)) - return nil -} - -func autoConvert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus(in *TechsupportStatus, out *v1beta1.TechsupportStatus, s conversion.Scope) error { - out.NextScheduleTime = (*v1.Time)(unsafe.Pointer(in.NextScheduleTime)) - out.LastRunTime = (*v1.Time)(unsafe.Pointer(in.LastRunTime)) - out.LastRunStatus = (*v1beta1.CollectionStatus)(unsafe.Pointer(in.LastRunStatus)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.MatchingClusterRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.MatchingClusterRefs)) - return nil -} - -// Convert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus is an autogenerated conversion function. -func Convert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus(in *TechsupportStatus, out *v1beta1.TechsupportStatus, s conversion.Scope) error { - return autoConvert_v1alpha1_TechsupportStatus_To_v1beta1_TechsupportStatus(in, out, s) -} - -func autoConvert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus(in *v1beta1.TechsupportStatus, out *TechsupportStatus, s conversion.Scope) error { - out.NextScheduleTime = (*v1.Time)(unsafe.Pointer(in.NextScheduleTime)) - out.LastRunTime = (*v1.Time)(unsafe.Pointer(in.LastRunTime)) - out.LastRunStatus = (*CollectionStatus)(unsafe.Pointer(in.LastRunStatus)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.MatchingClusterRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.MatchingClusterRefs)) - return nil -} - -// Convert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus is an autogenerated conversion function. -func Convert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus(in *v1beta1.TechsupportStatus, out *TechsupportStatus, s conversion.Scope) error { - return autoConvert_v1beta1_TechsupportStatus_To_v1alpha1_TechsupportStatus(in, out, s) -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 7a1f1c8b..8ae134a8 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -21,57 +21,9 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" - - apiv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Log) DeepCopyInto(out *Log) { - *out = *in - if in.LabelFilters != nil { - in, out := &in.LabelFilters, &out.LabelFilters - *out = make([]apiv1alpha1.LabelFilter, len(*in)) - copy(*out, *in) - } - if in.SinceSeconds != nil { - in, out := &in.SinceSeconds, &out.SinceSeconds - *out = new(int64) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Log. -func (in *Log) DeepCopy() *Log { - if in == nil { - return nil - } - out := new(Log) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Resource) DeepCopyInto(out *Resource) { - *out = *in - if in.LabelFilters != nil { - in, out := &in.LabelFilters, &out.LabelFilters - *out = make([]apiv1alpha1.LabelFilter, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resource. -func (in *Resource) DeepCopy() *Resource { - if in == nil { - return nil - } - out := new(Resource) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Snapshot) DeepCopyInto(out *Snapshot) { *out = *in @@ -188,139 +140,3 @@ func (in *SnapshotStatus) DeepCopy() *SnapshotStatus { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Techsupport) DeepCopyInto(out *Techsupport) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Techsupport. -func (in *Techsupport) DeepCopy() *Techsupport { - if in == nil { - return nil - } - out := new(Techsupport) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Techsupport) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportList) DeepCopyInto(out *TechsupportList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Techsupport, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportList. -func (in *TechsupportList) DeepCopy() *TechsupportList { - if in == nil { - return nil - } - out := new(TechsupportList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TechsupportList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportSpec) DeepCopyInto(out *TechsupportSpec) { - *out = *in - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]Resource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Logs != nil { - in, out := &in.Logs, &out.Logs - *out = make([]Log, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.StartingDeadlineSeconds != nil { - in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds - *out = new(int64) - **out = **in - } - if in.SuccessfulTechsupportLimit != nil { - in, out := &in.SuccessfulTechsupportLimit, &out.SuccessfulTechsupportLimit - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportSpec. -func (in *TechsupportSpec) DeepCopy() *TechsupportSpec { - if in == nil { - return nil - } - out := new(TechsupportSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportStatus) DeepCopyInto(out *TechsupportStatus) { - *out = *in - if in.NextScheduleTime != nil { - in, out := &in.NextScheduleTime, &out.NextScheduleTime - *out = (*in).DeepCopy() - } - if in.LastRunTime != nil { - in, out := &in.LastRunTime, &out.LastRunTime - *out = (*in).DeepCopy() - } - if in.LastRunStatus != nil { - in, out := &in.LastRunStatus, &out.LastRunStatus - *out = new(CollectionStatus) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } - if in.MatchingClusterRefs != nil { - in, out := &in.MatchingClusterRefs, &out.MatchingClusterRefs - *out = make([]v1.ObjectReference, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportStatus. -func (in *TechsupportStatus) DeepCopy() *TechsupportStatus { - if in == nil { - return nil - } - out := new(TechsupportStatus) - in.DeepCopyInto(out) - return out -} diff --git a/api/v1beta1/techsupport_conversion.go b/api/v1beta1/techsupport_conversion.go deleted file mode 100644 index 6e358b20..00000000 --- a/api/v1beta1/techsupport_conversion.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2024. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -// Hub marks this type as a conversion hub. -func (*Techsupport) Hub() {} diff --git a/api/v1beta1/techsupport_types.go b/api/v1beta1/techsupport_types.go deleted file mode 100644 index 64b79a19..00000000 --- a/api/v1beta1/techsupport_types.go +++ /dev/null @@ -1,156 +0,0 @@ -/* -Copyright 2024. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" -) - -const ( - // TechsupportFinalizer allows TechsupportReconciler to clean up resources associated with - // Techsupport instance before removing it from the apiserver. - TechsupportFinalizer = "techsupportfinalizer.projectsveltos.io" -) - -// Resource indicates the type of resources to collect. -type Resource struct { - // Namespace of the resource deployed in the Cluster. - // Empty for resources scoped at cluster level. - // +optional - Namespace string `json:"namespace,omitempty"` - - // Group of the resource deployed in the Cluster. - Group string `json:"group"` - - // Version of the resource deployed in the Cluster. - Version string `json:"version"` - - // Kind of the resource deployed in the Cluster. - // +kubebuilder:validation:MinLength=1 - Kind string `json:"kind"` - - // LabelFilters allows to filter resources based on current labels. - LabelFilters []libsveltosv1beta1.LabelFilter `json:"labelFilters,omitempty"` -} - -// LogFilter allows to select which logs to collect -type Log struct { - // Namespace of the pods deployed in the Cluster. - // +optional - Namespace string `json:"namespace,omitempty"` - - // LabelFilters allows to filter pods based on current labels. - LabelFilters []libsveltosv1beta1.LabelFilter `json:"labelFilters,omitempty"` - - // A relative time in seconds before the current time from which to collect logs. - // If this value precedes the time a pod was started, only logs since the pod start will be returned. - // If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - // +optional - SinceSeconds *int64 `json:"sinceSeconds,omitempty"` -} - -// TechsupportSpec defines the desired state of Techsupport -type TechsupportSpec struct { - // ClusterSelector identifies clusters to collect techsupport from. - ClusterSelector libsveltosv1beta1.Selector `json:"clusterSelector"` - - // Resources indicates what resorces to collect - // +optional - Resources []Resource `json:"resources,omitempty"` - - // Logs indicates what pods' log to collect - // +optional - Logs []Log `json:"logs,omitempty"` - - // If set denerates a tar file with all collected logs/resources - // +kubebuilder:default:=false - // +optional - Tar bool `json:"tar,omitempty"` - - // Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - Schedule string `json:"schedule"` - - // Optional deadline in seconds for starting the job if it misses scheduled - // time for any reason. Missed jobs executions will be counted as failed ones. - // +optional - StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` - - // Storage represents directory where techsupports will be stored. - // It must be an existing directory. - // Techsupports will be stored in this directory in a subdirectory named - // with Techsupport instance name. - Storage string `json:"storage"` - - // The number of successful finished techsupport to retains. - // If specified, only SuccessfulTechsupportLimit will be retained. Once such - // number is reached, for any new successful snapshots, the oldest one is - // deleted. - // +optional - SuccessfulTechsupportLimit *int32 `json:"successfulTechsupportLimit,omitempty"` -} - -// TechsupportStatus defines the observed state of Techsupport -type TechsupportStatus struct { - // Information when next snapshot is scheduled - // +optional - NextScheduleTime *metav1.Time `json:"nextScheduleTime,omitempty"` - - // Information when was the last time a snapshot was successfully scheduled. - // +optional - LastRunTime *metav1.Time `json:"lastRunTime,omitempty"` - - // Status indicates what happened to last techsupport collection. - LastRunStatus *CollectionStatus `json:"lastRunStatus,omitempty"` - - // FailureMessage provides more information about the error, if - // any occurred - FailureMessage *string `json:"failureMessage,omitempty"` - - // MatchingClusterRefs reference all the clusters currently matching - // Techsupport - MatchingClusterRefs []corev1.ObjectReference `json:"machingClusters,omitempty"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:resource:path=techsupports,scope=Cluster -//+kubebuilder:subresource:status -//+kubebuilder:storageversion - -// Techsupport is the Schema for the snapshot API -type Techsupport struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec TechsupportSpec `json:"spec,omitempty"` - Status TechsupportStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// TechsupportList contains a list of Techsupport instances -type TechsupportList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Techsupport `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Techsupport{}, &TechsupportList{}) -} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 2987fadc..1ced3ac9 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -21,57 +21,9 @@ limitations under the License. package v1beta1 import ( - v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" - - apiv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Log) DeepCopyInto(out *Log) { - *out = *in - if in.LabelFilters != nil { - in, out := &in.LabelFilters, &out.LabelFilters - *out = make([]apiv1beta1.LabelFilter, len(*in)) - copy(*out, *in) - } - if in.SinceSeconds != nil { - in, out := &in.SinceSeconds, &out.SinceSeconds - *out = new(int64) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Log. -func (in *Log) DeepCopy() *Log { - if in == nil { - return nil - } - out := new(Log) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Resource) DeepCopyInto(out *Resource) { - *out = *in - if in.LabelFilters != nil { - in, out := &in.LabelFilters, &out.LabelFilters - *out = make([]apiv1beta1.LabelFilter, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resource. -func (in *Resource) DeepCopy() *Resource { - if in == nil { - return nil - } - out := new(Resource) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Snapshot) DeepCopyInto(out *Snapshot) { *out = *in @@ -188,140 +140,3 @@ func (in *SnapshotStatus) DeepCopy() *SnapshotStatus { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Techsupport) DeepCopyInto(out *Techsupport) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Techsupport. -func (in *Techsupport) DeepCopy() *Techsupport { - if in == nil { - return nil - } - out := new(Techsupport) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Techsupport) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportList) DeepCopyInto(out *TechsupportList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Techsupport, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportList. -func (in *TechsupportList) DeepCopy() *TechsupportList { - if in == nil { - return nil - } - out := new(TechsupportList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TechsupportList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportSpec) DeepCopyInto(out *TechsupportSpec) { - *out = *in - in.ClusterSelector.DeepCopyInto(&out.ClusterSelector) - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]Resource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Logs != nil { - in, out := &in.Logs, &out.Logs - *out = make([]Log, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.StartingDeadlineSeconds != nil { - in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds - *out = new(int64) - **out = **in - } - if in.SuccessfulTechsupportLimit != nil { - in, out := &in.SuccessfulTechsupportLimit, &out.SuccessfulTechsupportLimit - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportSpec. -func (in *TechsupportSpec) DeepCopy() *TechsupportSpec { - if in == nil { - return nil - } - out := new(TechsupportSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TechsupportStatus) DeepCopyInto(out *TechsupportStatus) { - *out = *in - if in.NextScheduleTime != nil { - in, out := &in.NextScheduleTime, &out.NextScheduleTime - *out = (*in).DeepCopy() - } - if in.LastRunTime != nil { - in, out := &in.LastRunTime, &out.LastRunTime - *out = (*in).DeepCopy() - } - if in.LastRunStatus != nil { - in, out := &in.LastRunStatus, &out.LastRunStatus - *out = new(CollectionStatus) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } - if in.MatchingClusterRefs != nil { - in, out := &in.MatchingClusterRefs, &out.MatchingClusterRefs - *out = make([]v1.ObjectReference, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TechsupportStatus. -func (in *TechsupportStatus) DeepCopy() *TechsupportStatus { - if in == nil { - return nil - } - out := new(TechsupportStatus) - in.DeepCopyInto(out) - return out -} diff --git a/cmd/sveltosctl/main.go b/cmd/sveltosctl/main.go index c6f2f26d..f504bc2c 100644 --- a/cmd/sveltosctl/main.go +++ b/cmd/sveltosctl/main.go @@ -46,7 +46,6 @@ func main() { mode was to be moved out of DryRun mode. Displays also information on which permissions each tenant admin has in each managed cluster. snapshot Displays collected snaphost. Visualize diffs between two collected snapshots. - techsupport Displays collected techsupport. register Onboard an existing non CAPI cluster by creating all necessary internal resources. generate Generates a Kubeconfig that can later be used to register a cluster. Run this command with sveltosctl pointing to the cluster you want Sveltos to manage. @@ -103,8 +102,6 @@ Description: err = commands.Show(ctx, args, logger) case "snapshot": err = commands.Snapshot(ctx, args, logger) - case "techsupport": - err = commands.Techsupport(ctx, args, logger) case "register": err = commands.RegisterCluster(ctx, args, logger) case "generate": diff --git a/config/crd/bases/utils.projectsveltos.io_snapshots.yaml b/config/crd/bases/utils.projectsveltos.io_snapshots.yaml index 0b87573b..33362e0c 100644 --- a/config/crd/bases/utils.projectsveltos.io_snapshots.yaml +++ b/config/crd/bases/utils.projectsveltos.io_snapshots.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + controller-gen.kubebuilder.io/version: v0.17.0 name: snapshots.utils.projectsveltos.io spec: group: utils.projectsveltos.io @@ -15,89 +15,6 @@ spec: scope: Cluster versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Snapshot is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: SnapshotSpec defines the desired state of Snapshot - properties: - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where snapshots will be stored. - It must be an existing directory. - Snapshots will be stored in this directory in a subdirectory named - with Snapshot instance name. - type: string - successfulSnapshotLimit: - description: |- - The number of successful finished snapshots to retains. - If specified, only SuccessfulSnapshotLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - required: - - schedule - - storage - type: object - status: - description: SnapshotStatus defines the observed state of Snapshot - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last snapshot collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: false - subresources: - status: {} - - name: v1beta1 schema: openAPIV3Schema: description: Snapshot is the Schema for the snapshot API diff --git a/config/crd/bases/utils.projectsveltos.io_techsupports.yaml b/config/crd/bases/utils.projectsveltos.io_techsupports.yaml deleted file mode 100644 index eef3d5d5..00000000 --- a/config/crd/bases/utils.projectsveltos.io_techsupports.yaml +++ /dev/null @@ -1,519 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.5 - name: techsupports.utils.projectsveltos.io -spec: - group: utils.projectsveltos.io - names: - kind: Techsupport - listKind: TechsupportList - plural: techsupports - singular: techsupport - scope: Cluster - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Techsupport is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: TechsupportSpec defines the desired state of Techsupport - properties: - clusterSelector: - description: ClusterSelector identifies clusters to collect techsupport - from. - type: string - logs: - description: Logs indicates what pods' log to collect - items: - description: LogFilter allows to select which logs to collect - properties: - labelFilters: - description: LabelFilters allows to filter pods based on current - labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: Namespace of the pods deployed in the Cluster. - type: string - sinceSeconds: - description: |- - A relative time in seconds before the current time from which to collect logs. - If this value precedes the time a pod was started, only logs since the pod start will be returned. - If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - format: int64 - type: integer - type: object - type: array - resources: - description: Resources indicates what resorces to collect - items: - description: Resource indicates the type of resources to collect. - properties: - group: - description: Group of the resource deployed in the Cluster. - type: string - kind: - description: Kind of the resource deployed in the Cluster. - minLength: 1 - type: string - labelFilters: - description: LabelFilters allows to filter resources based on - current labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: |- - Namespace of the resource deployed in the Cluster. - Empty for resources scoped at cluster level. - type: string - version: - description: Version of the resource deployed in the Cluster. - type: string - required: - - group - - kind - - version - type: object - type: array - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where techsupports will be stored. - It must be an existing directory. - Techsupports will be stored in this directory in a subdirectory named - with Techsupport instance name. - type: string - successfulTechsupportLimit: - description: |- - The number of successful finished techsupport to retains. - If specified, only SuccessfulTechsupportLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - tar: - default: false - description: If set denerates a tar file with all collected logs/resources - type: boolean - required: - - clusterSelector - - schedule - - storage - type: object - status: - description: TechsupportStatus defines the observed state of Techsupport - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last techsupport collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - machingClusters: - description: |- - MatchingClusterRefs reference all the clusters currently matching - Techsupport - items: - description: ObjectReference contains enough information to let - you inspect or modify the referred object. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: |- - If referring to a piece of an object instead of an entire object, this string - should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to the name of the container that triggered - 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. - type: string - kind: - description: |- - Kind of the referent. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - namespace: - description: |- - Namespace of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ - type: string - resourceVersion: - description: |- - Specific resourceVersion to which this reference is made, if any. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency - type: string - uid: - description: |- - UID of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids - type: string - type: object - x-kubernetes-map-type: atomic - type: array - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: false - subresources: - status: {} - - name: v1beta1 - schema: - openAPIV3Schema: - description: Techsupport is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: TechsupportSpec defines the desired state of Techsupport - properties: - clusterSelector: - description: ClusterSelector identifies clusters to collect techsupport - from. - properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. - The requirements are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that the selector applies - to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - x-kubernetes-list-type: atomic - required: - - key - - operator - type: object - type: array - x-kubernetes-list-type: atomic - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - logs: - description: Logs indicates what pods' log to collect - items: - description: LogFilter allows to select which logs to collect - properties: - labelFilters: - description: LabelFilters allows to filter pods based on current - labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: Namespace of the pods deployed in the Cluster. - type: string - sinceSeconds: - description: |- - A relative time in seconds before the current time from which to collect logs. - If this value precedes the time a pod was started, only logs since the pod start will be returned. - If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - format: int64 - type: integer - type: object - type: array - resources: - description: Resources indicates what resorces to collect - items: - description: Resource indicates the type of resources to collect. - properties: - group: - description: Group of the resource deployed in the Cluster. - type: string - kind: - description: Kind of the resource deployed in the Cluster. - minLength: 1 - type: string - labelFilters: - description: LabelFilters allows to filter resources based on - current labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: |- - Namespace of the resource deployed in the Cluster. - Empty for resources scoped at cluster level. - type: string - version: - description: Version of the resource deployed in the Cluster. - type: string - required: - - group - - kind - - version - type: object - type: array - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where techsupports will be stored. - It must be an existing directory. - Techsupports will be stored in this directory in a subdirectory named - with Techsupport instance name. - type: string - successfulTechsupportLimit: - description: |- - The number of successful finished techsupport to retains. - If specified, only SuccessfulTechsupportLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - tar: - default: false - description: If set denerates a tar file with all collected logs/resources - type: boolean - required: - - clusterSelector - - schedule - - storage - type: object - status: - description: TechsupportStatus defines the observed state of Techsupport - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last techsupport collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - machingClusters: - description: |- - MatchingClusterRefs reference all the clusters currently matching - Techsupport - items: - description: ObjectReference contains enough information to let - you inspect or modify the referred object. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: |- - If referring to a piece of an object instead of an entire object, this string - should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to the name of the container that triggered - 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. - type: string - kind: - description: |- - Kind of the referent. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - namespace: - description: |- - Namespace of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ - type: string - resourceVersion: - description: |- - Specific resourceVersion to which this reference is made, if any. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency - type: string - uid: - description: |- - UID of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids - type: string - type: object - x-kubernetes-map-type: atomic - type: array - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 64a626d8..1ef43965 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,19 +2,18 @@ # since it depends on service name and namespace that are out of this kustomize package. # It should be run by config/default resources: -- bases/utils.projectsveltos.io_techsupports.yaml - bases/utils.projectsveltos.io_snapshots.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_techsupports.yaml +- path: patches/webhook_in_snapshots.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -- path: patches/cainjection_in_techsupports.yaml +- path: patches/cainjection_in_snapshots.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_snapshots.yaml b/config/crd/patches/cainjection_in_snapshots.yaml index 50345f2e..581884d0 100644 --- a/config/crd/patches/cainjection_in_snapshots.yaml +++ b/config/crd/patches/cainjection_in_snapshots.yaml @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + cert-manager.io/inject-ca-from: projectsveltos/projectsveltos-serving-cert # this is hardcoded with conversion-webhook repo name: snapshots.utils.projectsveltos.io diff --git a/config/crd/patches/cainjection_in_techsupports.yaml b/config/crd/patches/cainjection_in_techsupports.yaml deleted file mode 100644 index e81d923f..00000000 --- a/config/crd/patches/cainjection_in_techsupports.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: projectsveltos/projectsveltos-serving-cert # this is hardcoded with conversion-webhook repo - name: techsupports.utils.projectsveltos.io diff --git a/config/crd/patches/webhook_in_techsupports.yaml b/config/crd/patches/webhook_in_snapshots.yaml similarity index 89% rename from config/crd/patches/webhook_in_techsupports.yaml rename to config/crd/patches/webhook_in_snapshots.yaml index 5d119dee..b974d3a7 100644 --- a/config/crd/patches/webhook_in_techsupports.yaml +++ b/config/crd/patches/webhook_in_snapshots.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: techsupports.utils.projectsveltos.io + name: snapshots.utils.projectsveltos.io spec: conversion: strategy: Webhook diff --git a/go.mod b/go.mod index ea612b25..fe1ea8e7 100644 --- a/go.mod +++ b/go.mod @@ -1,39 +1,62 @@ module github.com/projectsveltos/sveltosctl -go 1.22.7 +go 1.23.4 require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 - github.com/fatih/color v1.18.0 + github.com/fatih/color v1.17.0 github.com/gdexlab/go-render v1.0.1 github.com/go-logr/logr v1.4.2 github.com/hexops/gotextdiff v1.0.3 github.com/olekukonko/tablewriter v0.0.5 - github.com/onsi/ginkgo/v2 v2.22.0 - github.com/onsi/gomega v1.36.0 + github.com/onsi/ginkgo/v2 v2.22.2 + github.com/onsi/gomega v1.36.2 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/addon-controller v0.43.1-0.20241202100654-55c0786240ee - github.com/projectsveltos/event-manager v0.43.1-0.20241202114051-1c0a0d0cadee - github.com/projectsveltos/libsveltos v0.43.1-0.20241201131544-c4c2550af4af + github.com/projectsveltos/addon-controller v0.45.0 + github.com/projectsveltos/event-manager v0.45.0 + github.com/projectsveltos/libsveltos v0.45.0 github.com/robfig/cron/v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.31.3 - k8s.io/apiextensions-apiserver v0.31.3 - k8s.io/apimachinery v0.31.3 - k8s.io/client-go v0.31.3 + k8s.io/api v0.32.0 + k8s.io/apiextensions-apiserver v0.32.0 + k8s.io/apimachinery v0.32.0 + k8s.io/client-go v0.32.0 k8s.io/klog/v2 v2.130.1 - k8s.io/kubectl v0.31.3 - sigs.k8s.io/cluster-api v1.8.5 - sigs.k8s.io/controller-runtime v0.19.2 + k8s.io/kubectl v0.32.0 + sigs.k8s.io/cluster-api v1.9.3 + sigs.k8s.io/controller-runtime v0.19.4 sigs.k8s.io/yaml v1.4.0 ) require ( + github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/BurntSushi/toml v1.3.2 // indirect + github.com/MakeNowJust/heredoc v1.0.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/Masterminds/squirrel v1.5.4 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/chai2010/gettext-go v1.0.2 // indirect + github.com/containerd/containerd v1.7.12 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/dariubs/percent v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/go-restful/v3 v3.12.1 // indirect + github.com/docker/cli v24.0.6+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.9+incompatible // indirect + github.com/docker/docker-credential-helpers v0.7.0 // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-metrics v0.0.1 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/evanphx/json-patch v5.7.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect @@ -41,54 +64,72 @@ require ( github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gobuffalo/flect v1.0.3 // indirect + github.com/gobuffalo/flect v1.0.2 // indirect + github.com/gobwas/glob v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gnostic-models v0.6.9 // 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-20241029153458-d1b30febd7db // indirect + github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect github.com/google/uuid v1.6.0 // indirect - github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.10 // indirect + github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect + github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/locker v1.0.1 // indirect + github.com/moby/spdystream v0.2.0 // indirect + github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/prometheus/client_golang v1.20.5 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.60.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/rivo/uniseg v0.4.7 // indirect + github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/go-digest/blake3 v0.0.0-20231025023718-d50d2fec9c98 // indirect + github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.48.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/rivo/uniseg v0.4.2 // indirect + github.com/rubenv/sql-migrate v1.5.2 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.20.0 // indirect - golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/oauth2 v0.24.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/time v0.8.0 // indirect + golang.org/x/tools v0.28.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/protobuf v1.35.1 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/cluster-bootstrap v0.31.1 // indirect - k8s.io/component-base v0.31.3 // indirect - k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094 // indirect - k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect + k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect + sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect ) // Replace digest lib to master to gather access to BLAKE3. // xref: https://github.com/opencontainers/go-digest/pull/66 -replace github.com/opencontainers/go-digest => github.com/opencontainers/go-digest v1.0.1-0.20240426182413-22b78e47854a +replace github.com/opencontainers/go-digest => github.com/opencontainers/go-digest v1.0.1-0.20220411205349-bde1400a84be diff --git a/go.sum b/go.sum index 3fc9a9bb..22143066 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,115 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= +github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= +github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= +github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= +github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= +github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= +github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= +github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= +github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= +github.com/containerd/containerd v1.7.12/go.mod h1:/5OMpE1p0ylxtEUGY8kuCYkDRzJm9NO1TFMWjUpdevk= +github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= +github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/coredns/caddy v1.1.0 h1:ezvsPrT/tA/7pYDBZxu0cT0VmWk75AfIaf6GSYCNMf0= +github.com/coredns/caddy v1.1.0/go.mod h1:A6ntJQlAWuQfFlsd9hvigKbo2WS0VUs2l1e2F+BawD4= +github.com/coredns/corefile-migration v1.0.21 h1:W/DCETrHDiFo0Wj03EyMkaQ9fwsmSgqTCQDHpceaSsE= +github.com/coredns/corefile-migration v1.0.21/go.mod h1:XnhgULOEouimnzgn0t4WPuFDN2/PJQcTxdWKC5eXNGE= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/dariubs/percent v1.0.0 h1:fY8q40FRYaCiFZ0gTOa73Cmp21hS32w+tSSmqbGnUzc= +github.com/dariubs/percent v1.0.0/go.mod h1:NDZpkezJ8QqyIW/510MywB5T2KdC8v/0oTlEoPcMsRM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= +github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2/go.mod h1:WHNsWjnIn2V1LYOrME7e8KxSeKunYHsxEm4am0BUtcI= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/cli v24.0.6+incompatible h1:fF+XCQCgJjjQNIMjzaSmiKJSCcfcXb3TWTcc7GAneOY= +github.com/docker/cli v24.0.6+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= +github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= +github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= +github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= +github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= +github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= +github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= -github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= -github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= @@ -24,56 +120,89 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gdexlab/go-render v1.0.1 h1:rxqB3vo5s4n1kF0ySmoNeSPRYkEsyHgln4jFIQY7v0U= github.com/gdexlab/go-render v1.0.1/go.mod h1:wRi5nW2qfjiGj4mPukH4UV0IknS1cHD4VgFTmJX5JzM= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs= +github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= -github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= -github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= -github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= -github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= -github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= -github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU= +github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs= +github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0= +github.com/gobuffalo/packd v1.0.1/go.mod h1:PP2POP3p3RXGz7Jh6eYEf93S7vA2za6xM7QT85L4+VY= +github.com/gobuffalo/packr/v2 v2.8.3 h1:xE1yzvnO56cUC0sTpKR3DIbxZgB54AftTFMhB2XEWlY= +github.com/gobuffalo/packr/v2 v2.8.3/go.mod h1:0SahksCVcx4IMnigTjiFuyldmTrdTctXsOdiU5KwbKc= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= +github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= -github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= +github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= +github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -82,32 +211,61 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= +github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.1.25 h1:dFwPR6SfLtrSwgDcIq2bcU/gVutB4sNApq2HBdqcakg= +github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= +github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= +github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= +github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= -github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= -github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y= -github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= +github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk= +github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= +github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/addon-controller v0.43.1-0.20241202100654-55c0786240ee h1:rkbzO6c5ttqDk1KAtbr3HPSquT5AO4eaa388NNgiCRc= -github.com/projectsveltos/addon-controller v0.43.1-0.20241202100654-55c0786240ee/go.mod h1:Mg0CsrS5NLlvKL5kIjqLznmvVE63Guj2aK+23k0kf0Y= -github.com/projectsveltos/event-manager v0.43.1-0.20241202114051-1c0a0d0cadee h1:JtYRf4FocJZCwswqMMdB2J7+9hQITW3kYnt9ftdLOMA= -github.com/projectsveltos/event-manager v0.43.1-0.20241202114051-1c0a0d0cadee/go.mod h1:XyJhynQqut5bUGdjGHCDpIOyf/rJv4KETlvJ7cr/V+s= -github.com/projectsveltos/libsveltos v0.43.1-0.20241201131544-c4c2550af4af h1:rkf6H9XqWmO10dTmZIsns7Zgcw4+vvnLa1bUrURPoJA= -github.com/projectsveltos/libsveltos v0.43.1-0.20241201131544-c4c2550af4af/go.mod h1:4hqQRjwZ/DZ6u0haL3zhdARZ3lpspLv57rkhpXIzbsg= +github.com/projectsveltos/addon-controller v0.45.0 h1:CqzaBrM4Hv89nQgTragqqpUMof72jw5gux3CDU0X3uc= +github.com/projectsveltos/addon-controller v0.45.0/go.mod h1:Stt7bkTOQ3KFaH8KHtAeES7cTZtXn9tJnHNwe5mk0Jo= +github.com/projectsveltos/event-manager v0.45.0 h1:oWmtMV7+EkQYKvuoFVwjqIePRYZPeMbl9TqvqLXkrYk= +github.com/projectsveltos/event-manager v0.45.0/go.mod h1:FDDIs/++tjolt0Yu9sQrFbntmo3O602xi/uZBSFHPUU= +github.com/projectsveltos/libsveltos v0.45.0 h1:4YJxmGmi6HsJ1uBqQk2Yt0ifuZbaZXiQAQJOmz5X8GU= +github.com/projectsveltos/libsveltos v0.45.0/go.mod h1:ncyIWW5KY89X36cJmcq389ZMJiYQ7WTo+EMB6WR5q+E= github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= @@ -117,18 +275,42 @@ github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= +github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rubenv/sql-migrate v1.5.2 h1:bMDqOnrJVV/6JQgQ/MxOpU+AdO8uzYYA/TxFUBzFtS0= +github.com/rubenv/sql-migrate v1.5.2/go.mod h1:H38GW8Vqf8F0Su5XignRyaRcbXbJunSWxs+kmzlg0Is= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -138,59 +320,117 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= +github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= +github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY= +github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= +github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= +github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= +github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= +github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 h1:1eHu3/pUSWaOgltNK3WJFaywKsTIr/PwvHyDmi0lQA0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0/go.mod h1:HyABWq60Uy1kjJSa2BVOxUVao8Cdick5AWSKPutqy6U= +go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc= +go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs= +go.opentelemetry.io/otel/metric v1.20.0 h1:ZlrO8Hu9+GAhnepmRGhSU7/VkpjrNowxRN9GyKR4wzA= +go.opentelemetry.io/otel/metric v1.20.0/go.mod h1:90DRw3nfK4D7Sm/75yQ00gTJxtkBxX+wu6YaNymbpVM= +go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ= +go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU= +go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= +go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 h1:1wqE9dj9NpSm04INVsJhhEUzhuDVjbcyKH91sVyPATw= -golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= -golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= -golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= +golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -198,39 +438,33 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.31.3 h1:umzm5o8lFbdN/hIXbrK9oRpOproJO62CV1zqxXrLgk8= -k8s.io/api v0.31.3/go.mod h1:UJrkIp9pnMOI9K2nlL6vwpxRzzEX5sWgn8kGQe92kCE= -k8s.io/apiextensions-apiserver v0.31.3 h1:+GFGj2qFiU7rGCsA5o+p/rul1OQIq6oYpQw4+u+nciE= -k8s.io/apiextensions-apiserver v0.31.3/go.mod h1:2DSpFhUZZJmn/cr/RweH1cEVVbzFw9YBu4T+U3mf1e4= -k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= -k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= -k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= -k8s.io/cluster-bootstrap v0.31.1 h1:lS5aJi2r6WEKnjO5UhbYsz8e3xmEfoF4Hiob/gnB/Nk= -k8s.io/cluster-bootstrap v0.31.1/go.mod h1:dxroRr4eQ0ekxis/kzGa1qODprQXAxQZrgDLfTk8Pug= -k8s.io/component-base v0.31.3 h1:DMCXXVx546Rfvhj+3cOm2EUxhS+EyztH423j+8sOwhQ= -k8s.io/component-base v0.31.3/go.mod h1:xME6BHfUOafRgT0rGVBGl7TuSg8Z9/deT7qq6w7qjIU= +k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE= +k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0= +k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0= +k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw= +k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg= +k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8= +k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094 h1:MErs8YA0abvOqJ8gIupA1Tz6PKXYUw34XsGlA7uSL1k= -k8s.io/kube-openapi v0.0.0-20241009091222-67ed5848f094/go.mod h1:7ioBJr1A6igWjsR2fxq2EZ0mlMwYLejazSIc2bzMp2U= -k8s.io/kubectl v0.31.3 h1:3r111pCjPsvnR98oLLxDMwAeM6OPGmPty6gSKaLTQes= -k8s.io/kubectl v0.31.3/go.mod h1:lhMECDCbJN8He12qcKqs2QfmVo9Pue30geovBVpH5fs= -k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 h1:jGnCPejIetjiy2gqaJ5V0NLwTpF4wbQ6cZIItJCSHno= -k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/cluster-api v1.8.5 h1:lNA2fPN4fkXEs+oOQlnwxT/4VwRFBpv5kkSoJG8nqBA= -sigs.k8s.io/cluster-api v1.8.5/go.mod h1:pXv5LqLxuIbhGIXykyNKiJh+KrLweSBajVHHitPLyoY= -sigs.k8s.io/controller-runtime v0.19.2 h1:3sPrF58XQEPzbE8T81TN6selQIMGbtYwuaJ6eDssDF8= -sigs.k8s.io/controller-runtime v0.19.2/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 h1:hcha5B1kVACrLujCKLbr8XWMxCxzQx42DY8QKYJrDLg= +k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7/go.mod h1:GewRfANuJ70iYzvn+i4lezLDAFzvjxZYK1gn1lWcfas= +k8s.io/kubectl v0.32.0 h1:rpxl+ng9qeG79YA4Em9tLSfX0G8W0vfaiPVrc/WR7Xw= +k8s.io/kubectl v0.32.0/go.mod h1:qIjSX+QgPQUgdy8ps6eKsYNF+YmFOAO3WygfucIqFiE= +k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0= +k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/cluster-api v1.9.3 h1:lKWbrXzyNmJh++IcX54ZbAmnO7tZ2wKgds7WvskpiXY= +sigs.k8s.io/cluster-api v1.9.3/go.mod h1:5iojv38PSvOd4cxqu08Un5TQmy2yBkd3+0U7R/e+msk= +sigs.k8s.io/controller-runtime v0.19.4 h1:SUmheabttt0nx8uJtoII4oIP27BVVvAKFvdvGFwV/Qo= +sigs.k8s.io/controller-runtime v0.19.4/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/structured-merge-diff/v4 v4.5.0 h1:nbCitCK2hfnhyiKo6uf2HxUPTCodY6Qaf85SbDIaMBk= +sigs.k8s.io/structured-merge-diff/v4 v4.5.0/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/hack/tools/go.mod b/hack/tools/go.mod index dca0bb16..2da9aa35 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -1,29 +1,28 @@ module github.com/projectsveltos/sveltosctl/hack/tools -go 1.22.7 +go 1.23.4 require ( - github.com/onsi/ginkgo/v2 v2.22.0 + github.com/onsi/ginkgo/v2 v2.22.2 golang.org/x/oauth2 v0.24.0 - k8s.io/client-go v0.31.3 - sigs.k8s.io/controller-tools v0.16.5 - sigs.k8s.io/kind v0.25.0 + k8s.io/client-go v0.32.0 + sigs.k8s.io/controller-tools v0.17.0 + sigs.k8s.io/kind v0.26.0 ) require ( - cloud.google.com/go/compute/metadata v0.5.0 // indirect - github.com/BurntSushi/toml v1.4.0 // indirect - github.com/alessio/shellescape v1.4.2 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect + github.com/BurntSushi/toml v1.0.0 // indirect + github.com/alessio/shellescape v1.4.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/evanphx/json-patch/v5 v5.6.0 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gobuffalo/flect v1.0.3 // indirect + github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect + github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect github.com/google/safetext v0.0.0-20240722112252-5a72de7e7962 // indirect github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -32,29 +31,30 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pborman/uuid v1.2.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/spf13/cobra v1.8.1 // indirect + github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/time v0.6.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/mod v0.22.0 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/time v0.7.0 // indirect + golang.org/x/tools v0.28.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.31.3 // indirect - k8s.io/apiextensions-apiserver v0.31.2 // indirect - k8s.io/apimachinery v0.31.3 // indirect + k8s.io/api v0.32.0 // indirect + k8s.io/apiextensions-apiserver v0.32.0 // indirect + k8s.io/apimachinery v0.32.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/hack/tools/go.sum b/hack/tools/go.sum index fee46d03..0c3c1631 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -1,36 +1,34 @@ -cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= -cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= -github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= +github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= -github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= +github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= -github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= -github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= @@ -43,8 +41,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= -github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= +github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/safetext v0.0.0-20240722112252-5a72de7e7962 h1:+9C/TgFfcCmZBV7Fjb3kQCGlkpFrhtvFDgbdQHB9RaA= github.com/google/safetext v0.0.0-20240722112252-5a72de7e7962/go.mod h1:H3K1Iu/utuCfa10JO+GsmKUYSWi7ug57Rk6GaDRHaaQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -52,6 +50,7 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -80,24 +79,23 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= -github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= -github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= -github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= +github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= +github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk= +github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= +github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -107,10 +105,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -118,82 +114,83 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= -golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.31.3 h1:umzm5o8lFbdN/hIXbrK9oRpOproJO62CV1zqxXrLgk8= -k8s.io/api v0.31.3/go.mod h1:UJrkIp9pnMOI9K2nlL6vwpxRzzEX5sWgn8kGQe92kCE= -k8s.io/apiextensions-apiserver v0.31.2 h1:W8EwUb8+WXBLu56ser5IudT2cOho0gAKeTOnywBLxd0= -k8s.io/apiextensions-apiserver v0.31.2/go.mod h1:i+Geh+nGCJEGiCGR3MlBDkS7koHIIKWVfWeRFiOsUcM= -k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= -k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= -k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= +k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE= +k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0= +k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0= +k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw= +k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg= +k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8= +k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= -k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 h1:b2FmK8YH+QEwq/Sy2uAEhmqL5nPfGYbJOcaqjeYYZoA= -k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-tools v0.16.5 h1:5k9FNRqziBPwqr17AMEPPV/En39ZBplLAdOwwQHruP4= -sigs.k8s.io/controller-tools v0.16.5/go.mod h1:8vztuRVzs8IuuJqKqbXCSlXcw+lkAv/M2sTpg55qjMY= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kind v0.25.0 h1:ugUvgesHKKA0yKmD6QtYTiEev+kPUpGxdTPbMGf8VTU= -sigs.k8s.io/kind v0.25.0/go.mod h1:t7ueEpzPYJvHA8aeLtI52rtFftNgUYUaCwvxjk7phfw= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/controller-tools v0.17.0 h1:KaEQZbhrdY6J3zLBHplt+0aKUp8PeIttlhtF2UDo6bI= +sigs.k8s.io/controller-tools v0.17.0/go.mod h1:SKoWY8rwGWDzHtfnhmOwljn6fViG0JF7/xmnxpklgjo= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/kind v0.26.0 h1:8fS6I0Q5WGlmLprSpH0DarlOSdcsv0txnwc93J2BP7M= +sigs.k8s.io/kind v0.26.0/go.mod h1:t7ueEpzPYJvHA8aeLtI52rtFftNgUYUaCwvxjk7phfw= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/collector/client.go b/internal/collector/client.go index 57f2c175..3ce7de7d 100644 --- a/internal/collector/client.go +++ b/internal/collector/client.go @@ -61,7 +61,7 @@ type Collector struct { mu *sync.Mutex // A request represents a request to collect resources/logs (for instance - // a snapshot request or a techsupport request). + // a snapshot request). // dirty contains all requests which are currently waiting to be served. dirty []string diff --git a/internal/collector/client_test.go b/internal/collector/client_test.go index a9a256f1..a2b93a35 100644 --- a/internal/collector/client_test.go +++ b/internal/collector/client_test.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/klog/v2/textlogger" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/collector" ) @@ -91,16 +91,16 @@ var _ = Describe("Client", func() { }) It("GetResult returns InProgress when request is still queued (currently in progress)", func() { - techsupportName := randomString() + snapshotName := randomString() d := collector.GetClient() defer d.ClearInternalStruct() - key := collector.GetKey(techsupportName, collector.Techsupport) + key := collector.GetKey(snapshotName, collector.Snapshot) d.SetInProgress([]string{key}) Expect(len(d.GetInProgress())).To(Equal(1)) - result := d.GetResult(context.TODO(), techsupportName, collector.Techsupport) + result := d.GetResult(context.TODO(), snapshotName, collector.Snapshot) Expect(result.Err).To(BeNil()) Expect(result.ResultStatus).To(Equal(collector.InProgress)) }) @@ -129,8 +129,8 @@ var _ = Describe("Client", func() { Expect(result.Err).To(BeNil()) Expect(result.ResultStatus).To(Equal(collector.Unavailable)) - techsupportName := randomString() - result = d.GetResult(context.TODO(), techsupportName, collector.Techsupport) + snapshotName2 := randomString() + result = d.GetResult(context.TODO(), snapshotName2, collector.Snapshot) Expect(result.Err).To(BeNil()) Expect(result.ResultStatus).To(Equal(collector.Unavailable)) }) @@ -242,11 +242,11 @@ var _ = Describe("Client", func() { u, err := instance.GetUnstructured([]byte(clusterConfigurationInstance)) Expect(err).To(BeNil()) Expect(u).ToNot(BeNil()) - Expect(u.GetKind()).To(Equal(configv1alpha1.ClusterConfigurationKind)) + Expect(u.GetKind()).To(Equal(configv1beta1.ClusterConfigurationKind)) }) It("getResourcesForKind returns all resources of a given namespaced kind", func() { - snapshotFolder := createDirectoryWithClusterConfigurations(randomString(), randomString(), collector.Techsupport) + snapshotFolder := createDirectoryWithClusterConfigurations(randomString(), randomString()) defer os.RemoveAll(snapshotFolder) By(fmt.Sprintf("reading content of directory %s", snapshotFolder)) @@ -258,7 +258,7 @@ var _ = Describe("Client", func() { namespaceFolder := filepath.Join(snapshotFolder, files[i].Name()) By(fmt.Sprintf("finding resources in folder %s", namespaceFolder)) instance := collector.GetClient() - list, err := collector.GetResourcesForKind(instance, namespaceFolder, configv1alpha1.ClusterConfigurationKind, + list, err := collector.GetResourcesForKind(instance, namespaceFolder, configv1beta1.ClusterConfigurationKind, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) Expect(list).ToNot(BeNil()) @@ -267,7 +267,7 @@ var _ = Describe("Client", func() { }) It("getResourcesForKind returns all resources of a given cluster kind", func() { - snapshotFolder := createDirectoryWithClusterProfiles(randomString(), randomString(), collector.Snapshot) + snapshotFolder := createDirectoryWithClusterProfiles(randomString(), randomString()) defer os.RemoveAll(snapshotFolder) By(fmt.Sprintf("reading content of directory %s", snapshotFolder)) @@ -277,7 +277,7 @@ var _ = Describe("Client", func() { By(fmt.Sprintf("finding resources in folder %s", snapshotFolder)) instance := collector.GetClient() - list, err := collector.GetResourcesForKind(instance, snapshotFolder, configv1alpha1.ClusterProfileKind, + list, err := collector.GetResourcesForKind(instance, snapshotFolder, configv1beta1.ClusterProfileKind, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) Expect(list).ToNot(BeNil()) @@ -285,11 +285,11 @@ var _ = Describe("Client", func() { }) It("GetNamespacedResources returns all resource of a given Kind in a snapshot folder", func() { - snapshotFolder := createDirectoryWithClusterConfigurations(randomString(), randomString(), collector.Snapshot) + snapshotFolder := createDirectoryWithClusterConfigurations(randomString(), randomString()) defer os.RemoveAll(snapshotFolder) d := collector.GetClient() - resourceMap, err := d.GetNamespacedResources(snapshotFolder, configv1alpha1.ClusterConfigurationKind, + resourceMap, err := d.GetNamespacedResources(snapshotFolder, configv1beta1.ClusterConfigurationKind, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) Expect(resourceMap).ToNot(BeNil()) @@ -300,7 +300,7 @@ var _ = Describe("Client", func() { for j := range resources { u := resources[j] Expect(u.GetNamespace()).To(Equal(k)) - Expect(u.GetKind()).To(Equal(configv1alpha1.ClusterConfigurationKind)) + Expect(u.GetKind()).To(Equal(configv1beta1.ClusterConfigurationKind)) } } }) @@ -310,7 +310,7 @@ var _ = Describe("Client", func() { snapshotStorage := randomString() By(fmt.Sprintf("snapshot instance %s (storage %s)", snapshotName, snapshotStorage)) - snapshotFolder := createDirectoryWithClusterConfigurations(snapshotStorage, snapshotName, collector.Snapshot) + snapshotFolder := createDirectoryWithClusterConfigurations(snapshotStorage, snapshotName) defer os.RemoveAll(snapshotFolder) // createDirectoryWithClusterConfigurations creates a temporary directory and then creates following subdirectories: @@ -348,7 +348,7 @@ var _ = Describe("Client", func() { storage := randomString() By(fmt.Sprintf("snapshot instance %s (storage %s)", snapshotName, storage)) - snapshotFolder := createDirectoryWithClusterConfigurations(storage, snapshotName, collector.Snapshot) + snapshotFolder := createDirectoryWithClusterConfigurations(storage, snapshotName) defer os.RemoveAll(snapshotFolder) // createDirectoryWithClusterConfigurations creates a temporary directory and then creates following subdirectories: @@ -369,8 +369,8 @@ var _ = Describe("Client", func() { }) }) -func createDirectoryWithClusterConfigurations(storage, requestorName string, collectionType collector.CollectionType) string { - snapshotDir := createDirectory(storage, requestorName, collectionType) +func createDirectoryWithClusterConfigurations(storage, requestorName string) string { + snapshotDir := createDirectory(storage, requestorName) By(fmt.Sprintf("Created temporary directory %s", snapshotDir)) d := collector.GetClient() @@ -387,8 +387,8 @@ func createDirectoryWithClusterConfigurations(storage, requestorName string, col return snapshotDir } -func createDirectoryWithClusterProfiles(storage, requestorName string, collectionType collector.CollectionType) string { - snapshotDir := createDirectory(storage, requestorName, collectionType) +func createDirectoryWithClusterProfiles(storage, requestorName string) string { + snapshotDir := createDirectory(storage, requestorName) By(fmt.Sprintf("Created temporary directory %s", snapshotDir)) d := collector.GetClient() @@ -404,13 +404,10 @@ func createDirectoryWithClusterProfiles(storage, requestorName string, collectio return snapshotDir } -func createDirectory(storage, requestorName string, collectionType collector.CollectionType) string { +func createDirectory(storage, requestorName string) string { dir, err := os.MkdirTemp("", randomString()) Expect(err).To(BeNil()) timeFolder := time.Now().Format(collector.TimeFormat) - if collectionType == collector.Snapshot { - return filepath.Join(dir, storage, "snapshot", requestorName, timeFolder) - } - return filepath.Join(dir, storage, "techsupport", requestorName, timeFolder) + return filepath.Join(dir, storage, "snapshot", requestorName, timeFolder) } diff --git a/internal/collector/collector_suite_test.go b/internal/collector/collector_suite_test.go index 3b5270f5..600587a2 100644 --- a/internal/collector/collector_suite_test.go +++ b/internal/collector/collector_suite_test.go @@ -25,7 +25,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/cluster-api/util" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" ) @@ -39,30 +39,30 @@ func randomString() string { return util.RandomString(length) } -func generateClusterProfile() *configv1alpha1.ClusterProfile { - return &configv1alpha1.ClusterProfile{ +func generateClusterProfile() *configv1beta1.ClusterProfile { + return &configv1beta1.ClusterProfile{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: configv1alpha1.Spec{ + Spec: configv1beta1.Spec{ ClusterSelector: libsveltosv1beta1.Selector{ LabelSelector: metav1.LabelSelector{ MatchLabels: map[string]string{"zone": "west"}, }, }, - SyncMode: configv1alpha1.SyncModeContinuous, + SyncMode: configv1beta1.SyncModeContinuous, }, } } -func generateClusterConfiguration() *configv1alpha1.ClusterConfiguration { - return &configv1alpha1.ClusterConfiguration{ +func generateClusterConfiguration() *configv1beta1.ClusterConfiguration { + return &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Status: configv1alpha1.ClusterConfigurationStatus{ - ClusterProfileResources: []configv1alpha1.ClusterProfileResource{ + Status: configv1beta1.ClusterConfigurationStatus{ + ClusterProfileResources: []configv1beta1.ClusterProfileResource{ { ClusterProfileName: randomString(), }, diff --git a/internal/collector/request_interface.go b/internal/collector/request_interface.go index 73f63e5a..7875806c 100644 --- a/internal/collector/request_interface.go +++ b/internal/collector/request_interface.go @@ -32,15 +32,12 @@ type CollectionType int64 const ( Snapshot CollectionType = iota - Techsupport ) func (c CollectionType) string() string { switch c { case Snapshot: return "snapshot" - case Techsupport: - return "techsupport" default: panic(1) } diff --git a/internal/collector/worker.go b/internal/collector/worker.go index 17db8280..7a40b762 100644 --- a/internal/collector/worker.go +++ b/internal/collector/worker.go @@ -32,8 +32,7 @@ import ( "github.com/projectsveltos/sveltosctl/internal/utils" ) -// A "request" represents the need to collect resources (for instance a snapshot request -// or a techsupport request). +// A "request" represents the need to collect resources (for instance a snapshot request). // // The flow is following: // - when a request arrives, it is first added to the dirty set or dropped if it already diff --git a/internal/commands/command_suite_test.go b/internal/commands/command_suite_test.go index dc0191f9..06c6cd1b 100644 --- a/internal/commands/command_suite_test.go +++ b/internal/commands/command_suite_test.go @@ -21,16 +21,9 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "sigs.k8s.io/cluster-api/util" ) func TestUtils(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Command Suite") } - -func randomString() string { - const length = 10 - return util.RandomString(length) -} diff --git a/internal/commands/loglevel/set.go b/internal/commands/loglevel/set.go index b125a0c8..dffee841 100644 --- a/internal/commands/loglevel/set.go +++ b/internal/commands/loglevel/set.go @@ -22,31 +22,31 @@ import ( "strings" docopt "github.com/docopt/docopt-go" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" + "github.com/projectsveltos/sveltosctl/internal/utils" ) -func updateDebuggingConfiguration(ctx context.Context, logSeverity libsveltosv1beta1.LogLevel, - component string) error { +func updateDebuggingConfiguration(ctx context.Context, logSeverity libsveltosv1alpha1.LogLevel, + component, namespace, clusterName, clusterType string) error { - cc, err := collectLogLevelConfiguration(ctx) + cc, err := collectLogLevelConfiguration(ctx, namespace, clusterName, clusterType) if err != nil { return nil } found := false - spec := make([]libsveltosv1beta1.ComponentConfiguration, len(cc)) + spec := make([]libsveltosv1alpha1.ComponentConfiguration, len(cc)) for i, c := range cc { if string(c.component) == component { - spec[i] = libsveltosv1beta1.ComponentConfiguration{ + spec[i] = libsveltosv1alpha1.ComponentConfiguration{ Component: c.component, LogLevel: logSeverity, } found = true break } else { - spec[i] = libsveltosv1beta1.ComponentConfiguration{ + spec[i] = libsveltosv1alpha1.ComponentConfiguration{ Component: c.component, LogLevel: c.logSeverity, } @@ -55,29 +55,32 @@ func updateDebuggingConfiguration(ctx context.Context, logSeverity libsveltosv1b if !found { spec = append(spec, - libsveltosv1beta1.ComponentConfiguration{ - Component: libsveltosv1beta1.Component(component), + libsveltosv1alpha1.ComponentConfiguration{ + Component: libsveltosv1alpha1.Component(component), LogLevel: logSeverity, }, ) } - return updateLogLevelConfiguration(ctx, spec) + return updateLogLevelConfiguration(ctx, spec, namespace, clusterName, clusterType) } // Set displays/changes log verbosity for a given component func Set(ctx context.Context, args []string) error { doc := `Usage: - sveltosctl log-level set --component= (--info|--debug|--verbose) + sveltosctl log-level set --component= [--namespace=] [--cluster=] [--cluster-type=] (--info|--debug|--verbose) Options: - -h --help Show this screen. - --component= Name of the component for which log severity is being set. - --info Set log severity to info. - --debug Set log severity to debug. - --verbose Set log severity to verbose. + -h --help Show this screen. + --component= Name of the component for which log severity is being set. + --namespace= Namespace of the cluster. + --cluster= Name of the cluster. + --cluster-type= Type of the cluster (Capi or Sveltos). + --info Set log severity to info. + --debug Set log severity to debug. + --verbose Set log severity to verbose. Description: - The log-level set command set log severity for the specified component. + The log-level set command sets log severity for the specified component in the specified cluster. ` parsedArgs, err := docopt.ParseArgs(doc, nil, "1.0") if err != nil { @@ -94,19 +97,31 @@ Description: if passedComponent := parsedArgs["--component"]; passedComponent != nil { component = passedComponent.(string) } + namespace := "" + if passedNamespace := parsedArgs["--namespace"]; passedNamespace != nil { + namespace = passedNamespace.(string) + } + clusterName := "" + if passedClusterName := parsedArgs["--cluster"]; passedClusterName != nil { + clusterName = passedClusterName.(string) + } + clusterType := "" + if passedClusterType := parsedArgs["--cluster-type"]; passedClusterType != nil { + clusterType = passedClusterType.(string) + } info := parsedArgs["--info"].(bool) debug := parsedArgs["--debug"].(bool) verbose := parsedArgs["--verbose"].(bool) - var logSeverity libsveltosv1beta1.LogLevel + var logSeverity libsveltosv1alpha1.LogLevel if info { - logSeverity = libsveltosv1beta1.LogLevelInfo + logSeverity = libsveltosv1alpha1.LogLevelInfo } else if debug { - logSeverity = libsveltosv1beta1.LogLevelDebug + logSeverity = libsveltosv1alpha1.LogLevelDebug } else if verbose { - logSeverity = libsveltosv1beta1.LogLevelVerbose + logSeverity = libsveltosv1alpha1.LogLevelVerbose } - return updateDebuggingConfiguration(ctx, logSeverity, component) + return updateDebuggingConfiguration(ctx, logSeverity, component, namespace, clusterName, clusterType) } diff --git a/internal/commands/loglevel/set_test.go b/internal/commands/loglevel/set_test.go index 83a875a3..78fdb2fb 100644 --- a/internal/commands/loglevel/set_test.go +++ b/internal/commands/loglevel/set_test.go @@ -23,40 +23,39 @@ import ( . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/commands/loglevel" "github.com/projectsveltos/sveltosctl/internal/utils" ) var _ = Describe("Set", func() { It("set updates default DebuggingConfiguration instance", func() { - scheme, err := utils.GetScheme() Expect(err).To(BeNil()) c := fake.NewClientBuilder().WithScheme(scheme).Build() utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - Expect(loglevel.UpdateDebuggingConfiguration(context.TODO(), libsveltosv1beta1.LogLevelDebug, - string(libsveltosv1beta1.ComponentAddonManager))).To(Succeed()) + Expect(loglevel.UpdateDebuggingConfiguration(context.TODO(), libsveltosv1alpha1.LogLevelDebug, + string(libsveltosv1alpha1.ComponentAddonManager), "", "", "")).To(Succeed()) k8sAccess := utils.GetAccessInstance() - currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO()) + currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO(), "", "", "") Expect(err).To(BeNil()) Expect(currentDC).ToNot(BeNil()) Expect(currentDC.Spec.Configuration).ToNot(BeNil()) Expect(len(currentDC.Spec.Configuration)).To(Equal(1)) - Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1beta1.ComponentAddonManager)) - Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1beta1.LogLevelDebug)) + Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1alpha1.ComponentAddonManager)) + Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1alpha1.LogLevelDebug)) - Expect(loglevel.UpdateDebuggingConfiguration(context.TODO(), libsveltosv1beta1.LogLevelInfo, - string(libsveltosv1beta1.ComponentAddonManager))).To(Succeed()) - currentDC, err = k8sAccess.GetDebuggingConfiguration(context.TODO()) + Expect(loglevel.UpdateDebuggingConfiguration(context.TODO(), libsveltosv1alpha1.LogLevelInfo, + string(libsveltosv1alpha1.ComponentAddonManager), "", "", "")).To(Succeed()) + currentDC, err = k8sAccess.GetDebuggingConfiguration(context.TODO(), "", "", "") Expect(err).To(BeNil()) Expect(currentDC).ToNot(BeNil()) Expect(currentDC.Spec.Configuration).ToNot(BeNil()) Expect(len(currentDC.Spec.Configuration)).To(Equal(1)) - Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1beta1.ComponentAddonManager)) - Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1beta1.LogLevelInfo)) + Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1alpha1.ComponentAddonManager)) + Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1alpha1.LogLevelInfo)) }) }) diff --git a/internal/commands/loglevel/show.go b/internal/commands/loglevel/show.go index c45caf70..45faa899 100644 --- a/internal/commands/loglevel/show.go +++ b/internal/commands/loglevel/show.go @@ -26,8 +26,8 @@ import ( "github.com/olekukonko/tablewriter" ) -func showLogSettings(ctx context.Context) error { - componentConfiguration, err := collectLogLevelConfiguration(ctx) +func showLogSettings(ctx context.Context, namespace, clusterName, clusterType string) error { + componentConfiguration, err := collectLogLevelConfiguration(ctx, namespace, clusterName, clusterType) if err != nil { return err } @@ -52,12 +52,15 @@ func showLogSettings(ctx context.Context) error { // Show displays information about log verbosity (if set) func Show(ctx context.Context, args []string) error { doc := `Usage: - sveltosctl log-level show + sveltosctl log-level show [--namespace=] [--cluster=] [--cluster-type=] Options: - -h --help Show this screen. + -h --help Show this screen. + --namespace= Namespace of the cluster. + --cluster= Name of the cluster. + --cluster-type= Type of the cluster (Capi or Sveltos). Description: - The log-level show command shows information about current log verbosity. + The log-level show command shows information about current log verbosity in the specified cluster. ` parsedArgs, err := docopt.ParseArgs(doc, nil, "1.0") if err != nil { @@ -70,5 +73,19 @@ Description: return nil } - return showLogSettings(ctx) -} + namespace := "" + if passedNamespace := parsedArgs["--namespace"]; passedNamespace != nil { + namespace = passedNamespace.(string) + } + clusterName := "" + if passedClusterName := parsedArgs["--cluster"]; passedClusterName != nil { + clusterName = passedClusterName.(string) + } + clusterType := "" + if passedClusterType := parsedArgs["--cluster-type"]; passedClusterType != nil { + clusterType = passedClusterType.(string) + } + + + return showLogSettings(ctx, namespace, clusterName, clusterType) +} \ No newline at end of file diff --git a/internal/commands/loglevel/show_test.go b/internal/commands/loglevel/show_test.go index 7cb04af4..9ca84523 100644 --- a/internal/commands/loglevel/show_test.go +++ b/internal/commands/loglevel/show_test.go @@ -35,10 +35,10 @@ import ( ) var _ = Describe("Show", func() { - It("show displays current log level settings", func() { + It("show displays current log level settings in managed cluster", func() { dc := getDebuggingConfiguration() - dc.Spec.Configuration = []libsveltosv1beta1.ComponentConfiguration{ - {Component: libsveltosv1beta1.ComponentClassifier, LogLevel: libsveltosv1beta1.LogLevelDebug}, + dc.Spec.Configuration = []libsveltosv1alpha1.ComponentConfiguration{ + {Component: libsveltosv1alpha1.ComponentClassifier, LogLevel: libsveltosv1alpha1.LogLevelDebug}, } old := os.Stdout // keep backup of the real stdout @@ -52,7 +52,7 @@ var _ = Describe("Show", func() { c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build() utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - err = loglevel.ShowLogSettings(context.TODO()) + err = loglevel.ShowLogSettings(context.TODO(), "", "", "") Expect(err).To(BeNil()) w.Close() @@ -61,7 +61,7 @@ var _ = Describe("Show", func() { Expect(err).To(BeNil()) /* - // This is an example of how the table needs to look like + // This is an example of how the table needs to look like +------------------+---------------+ | COMPONENT | VERBOSIRY | +------------------+---------------+ @@ -82,4 +82,4 @@ var _ = Describe("Show", func() { Expect(found).To(BeTrue()) os.Stdout = old }) -}) +}) \ No newline at end of file diff --git a/internal/commands/loglevel/unset.go b/internal/commands/loglevel/unset.go index b8a2cad2..c8db0891 100644 --- a/internal/commands/loglevel/unset.go +++ b/internal/commands/loglevel/unset.go @@ -22,18 +22,17 @@ import ( "strings" docopt "github.com/docopt/docopt-go" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" ) -func unsetDebuggingConfiguration(ctx context.Context, component string) error { - cc, err := collectLogLevelConfiguration(ctx) +func unsetDebuggingConfiguration(ctx context.Context, component, namespace, clusterName, clusterType string) error { + cc, err := collectLogLevelConfiguration(ctx, namespace, clusterName, clusterType) if err != nil { return nil } found := false - spec := make([]libsveltosv1beta1.ComponentConfiguration, 0) + spec := make([]libsveltosv1alpha1.ComponentConfiguration, 0) for _, c := range cc { if string(c.component) == component { @@ -41,7 +40,7 @@ func unsetDebuggingConfiguration(ctx context.Context, component string) error { continue } else { spec = append(spec, - libsveltosv1beta1.ComponentConfiguration{ + libsveltosv1alpha1.ComponentConfiguration{ Component: c.component, LogLevel: c.logSeverity, }, @@ -50,7 +49,7 @@ func unsetDebuggingConfiguration(ctx context.Context, component string) error { } if found { - return updateLogLevelConfiguration(ctx, spec) + return updateLogLevelConfiguration(ctx, spec, namespace, clusterName, clusterType) } return nil } @@ -58,13 +57,16 @@ func unsetDebuggingConfiguration(ctx context.Context, component string) error { // Unset resets log verbosity for a given component func Unset(ctx context.Context, args []string) error { doc := `Usage: - sveltosctl log-level unset --component= + sveltosctl log-level unset --component= [--namespace=] [--cluster=] [--cluster-type=] Options: - -h --help Show this screen. - --component= Name of the component for which log severity is being set. + -h --help Show this screen. + --component= Name of the component for which log severity is being unset. + --namespace= Namespace of the cluster. + --cluster= Name of the cluster. + --cluster-type= Type of the cluster (Capi or Sveltos). Description: - The log-level set command set log severity for the specified component. + The log-level unset command unset log severity for the specified component in the specified cluster. ` parsedArgs, err := docopt.ParseArgs(doc, nil, "1.0") if err != nil { @@ -81,6 +83,18 @@ Description: if passedComponent := parsedArgs["--component"]; passedComponent != nil { component = passedComponent.(string) } + namespace := "" + if passedNamespace := parsedArgs["--namespace"]; passedNamespace != nil { + namespace = passedNamespace.(string) + } + clusterName := "" + if passedClusterName := parsedArgs["--cluster"]; passedClusterName != nil { + clusterName = passedClusterName.(string) + } + clusterType := "" + if passedClusterType := parsedArgs["--cluster-type"]; passedClusterType != nil { + clusterType = passedClusterType.(string) + } - return unsetDebuggingConfiguration(ctx, component) -} + return unsetDebuggingConfiguration(ctx, component, namespace, clusterName, clusterType) +} \ No newline at end of file diff --git a/internal/commands/loglevel/unset_test.go b/internal/commands/loglevel/unset_test.go index 19d12d4c..00b631d9 100644 --- a/internal/commands/loglevel/unset_test.go +++ b/internal/commands/loglevel/unset_test.go @@ -30,11 +30,11 @@ import ( ) var _ = Describe("Unset", func() { - It("unset removes log level settings", func() { + It("unset removes log level settings in managed cluster", func() { dc := getDebuggingConfiguration() - dc.Spec.Configuration = []libsveltosv1beta1.ComponentConfiguration{ - {Component: libsveltosv1beta1.ComponentClassifier, LogLevel: libsveltosv1beta1.LogLevelInfo}, - {Component: libsveltosv1beta1.ComponentAddonManager, LogLevel: libsveltosv1beta1.LogLevelInfo}, + dc.Spec.Configuration = []libsveltosv1alpha1.ComponentConfiguration{ + {Component: libsveltosv1alpha1.ComponentClassifier, LogLevel: libsveltosv1alpha1.LogLevelInfo}, + {Component: libsveltosv1alpha1.ComponentAddonManager, LogLevel: libsveltosv1alpha1.LogLevelInfo}, } initObjects := []client.Object{dc} @@ -45,17 +45,17 @@ var _ = Describe("Unset", func() { utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - Expect(loglevel.UnsetDebuggingConfiguration(context.TODO(), string(libsveltosv1beta1.ComponentClassifier))).To(Succeed()) + Expect(loglevel.UnsetDebuggingConfiguration(context.TODO(), string(libsveltosv1alpha1.ComponentClassifier), "", "", "")).To(Succeed()) k8sAccess := utils.GetAccessInstance() - currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO()) + currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO(), "", "", "") Expect(err).To(BeNil()) Expect(currentDC).ToNot(BeNil()) Expect(currentDC.Spec.Configuration).ToNot(BeNil()) Expect(len(currentDC.Spec.Configuration)).To(Equal(1)) - Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1beta1.ComponentAddonManager)) - Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1beta1.LogLevelInfo)) - + Expect(currentDC.Spec.Configuration[0].Component).To(Equal(libsveltosv1alpha1.ComponentAddonManager)) + Expect(currentDC.Spec.Configuration[0].LogLevel).To(Equal(libsveltosv1alpha1.LogLevelInfo)) }) }) + diff --git a/internal/commands/loglevel/utils.go b/internal/commands/loglevel/utils.go index 3058208c..f1e5ca7d 100644 --- a/internal/commands/loglevel/utils.go +++ b/internal/commands/loglevel/utils.go @@ -23,13 +23,13 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) type componentConfiguration struct { - component libsveltosv1beta1.Component - logSeverity libsveltosv1beta1.LogLevel + component libsveltosv1alpha1.Component + logSeverity libsveltosv1alpha1.LogLevel } // byComponent sorts componentConfiguration by name. @@ -41,10 +41,10 @@ func (c byComponent) Less(i, j int) bool { return c[i].component < c[j].component } -func collectLogLevelConfiguration(ctx context.Context) ([]*componentConfiguration, error) { +func collectLogLevelConfiguration(ctx context.Context, namespace, clusterName, clusterType string) ([]*componentConfiguration, error) { instance := utils.GetAccessInstance() - dc, err := instance.GetDebuggingConfiguration(ctx) + dc, err := instance.GetDebuggingConfiguration(ctx, namespace, clusterName, clusterType) if err != nil { if apierrors.IsNotFound(err) { return make([]*componentConfiguration, 0), nil @@ -69,17 +69,19 @@ func collectLogLevelConfiguration(ctx context.Context) ([]*componentConfiguratio func updateLogLevelConfiguration( ctx context.Context, - spec []libsveltosv1beta1.ComponentConfiguration, + spec []libsveltosv1alpha1.ComponentConfiguration, + namespace, clusterName, clusterType string, ) error { instance := utils.GetAccessInstance() - dc, err := instance.GetDebuggingConfiguration(ctx) + dc, err := instance.GetDebuggingConfiguration(ctx, namespace, clusterName, clusterType) if err != nil { if apierrors.IsNotFound(err) { - dc = &libsveltosv1beta1.DebuggingConfiguration{ + dc = &libsveltosv1alpha1.DebuggingConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: "default", + Namespace: namespace, }, } } else { @@ -87,9 +89,9 @@ func updateLogLevelConfiguration( } } - dc.Spec = libsveltosv1beta1.DebuggingConfigurationSpec{ + dc.Spec = libsveltosv1alpha1.DebuggingConfigurationSpec{ Configuration: spec, } - return instance.UpdateDebuggingConfiguration(ctx, dc) -} + return instance.UpdateDebuggingConfiguration(ctx, dc, namespace, clusterName, clusterType) +} \ No newline at end of file diff --git a/internal/commands/onboard/cluster.go b/internal/commands/onboard/cluster.go index 76db60a8..2005dd2f 100644 --- a/internal/commands/onboard/cluster.go +++ b/internal/commands/onboard/cluster.go @@ -64,7 +64,14 @@ func onboardSveltosCluster(ctx context.Context, clusterNamespace, clusterName st return err } - return patchSecret(ctx, clusterNamespace, secretName, kubeconfigData, logger) + err = patchSecret(ctx, clusterNamespace, secretName, kubeconfigData, logger) + if err != nil { + return err + } + + //nolint: forbidigo // print success message + fmt.Printf("cluster %s successfully registered/updated in namespace %s.", clusterName, clusterNamespace) + return nil } func patchSveltosCluster(ctx context.Context, clusterNamespace, clusterName string, @@ -72,7 +79,7 @@ func patchSveltosCluster(ctx context.Context, clusterNamespace, clusterName stri instance := utils.GetAccessInstance() - currentSveltosCluster := &libsveltosv1beta1.SveltosCluster{} + currentSveltosCluster := &libsveltosv1alpha1.SveltosCluster{} err := instance.GetResource(ctx, types.NamespacedName{Namespace: clusterNamespace, Name: clusterName}, currentSveltosCluster) if err != nil { @@ -82,7 +89,7 @@ func patchSveltosCluster(ctx context.Context, clusterNamespace, clusterName stri currentSveltosCluster.Name = clusterName currentSveltosCluster.Labels = labels if renew { - currentSveltosCluster.Spec.TokenRequestRenewalOption = &libsveltosv1beta1.TokenRequestRenewalOption{ + currentSveltosCluster.Spec.TokenRequestRenewalOption = &libsveltosv1alpha1.TokenRequestRenewalOption{ RenewTokenRequestInterval: metav1.Duration{Duration: 24 * time.Hour}, } } diff --git a/internal/commands/reconciler_utils.go b/internal/commands/reconciler_utils.go index 567c68b8..bf24dab9 100644 --- a/internal/commands/reconciler_utils.go +++ b/internal/commands/reconciler_utils.go @@ -20,20 +20,13 @@ import ( "context" "fmt" "os" - "sync" - "syscall" "time" "github.com/go-logr/logr" "github.com/robfig/cron/v3" - corev1 "k8s.io/api/core/v1" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2/textlogger" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -44,11 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - "github.com/projectsveltos/libsveltos/lib/crd" - "github.com/projectsveltos/libsveltos/lib/logsettings" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - libsveltosset "github.com/projectsveltos/libsveltos/lib/set" utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/utils" @@ -69,7 +58,7 @@ type collection interface { getStartingDeadlineSeconds() *int64 - setLastRunStatus(utilsv1beta1.CollectionStatus) + setLastRunStatus(utilsv1alpha1.CollectionStatus) setFailureMessage(string) } @@ -79,25 +68,7 @@ const ( requeueAfter = 20 * time.Second ) -var ( - mux sync.Mutex - - // key: Sveltos/CAPI Cluster; value: set of all Techsupport matching the Cluster - clusterMap map[corev1.ObjectReference]*libsveltosset.Set - - // key: Techsupport; value: set of Sveltos/CAPI Clusters matched - techsupportMap map[corev1.ObjectReference]*libsveltosset.Set - - // key: techsupport; value techsupport's Selector - techsupports map[corev1.ObjectReference]libsveltosv1beta1.Selector -) - func watchResources(ctx context.Context, logger logr.Logger) error { - mux = sync.Mutex{} - clusterMap = make(map[corev1.ObjectReference]*libsveltosset.Set) - techsupportMap = make(map[corev1.ObjectReference]*libsveltosset.Set) - techsupports = make(map[corev1.ObjectReference]libsveltosv1beta1.Selector) - scheme, _ := utils.GetScheme() mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, @@ -117,14 +88,6 @@ func watchResources(ctx context.Context, logger logr.Logger) error { logger.Error(err, "failed to start snapshot reconciler") } - var techsupportController controller.Controller - techsupportController, err = startTechsupportReconciler(ctx, mgr, logger) - if err != nil { - logger.Error(err, "failed to start snapshot reconciler") - } - - go capiWatchers(ctx, mgr, techsupportController, logger) - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { logger.Error(err, "unable to continue running manager") return err @@ -145,9 +108,9 @@ func startSnapshotReconciler(ctx context.Context, mgr manager.Manager, logger lo return err } - sourceSnapshot := source.Kind[*utilsv1beta1.Snapshot]( + sourceSnapshot := source.Kind[*utilsv1alpha1.Snapshot]( mgr.GetCache(), - &utilsv1beta1.Snapshot{}, + &utilsv1alpha1.Snapshot{}, handler.TypedEnqueueRequestsFromMapFunc(handlerSnapshotMapFun), SnapshotPredicate{Logger: mgr.GetLogger().WithValues("predicate", "clusterpredicate")}, ) @@ -170,71 +133,6 @@ func startSnapshotReconciler(ctx context.Context, mgr manager.Manager, logger lo return nil } -func startTechsupportReconciler(ctx context.Context, mgr manager.Manager, logger logr.Logger) (controller.Controller, error) { - // Create an un-managed controller - c, err := controller.NewUnmanaged("techsupport-watcher", mgr, controller.Options{ - Reconciler: reconcile.Func(TechsupportReconciler), - MaxConcurrentReconciles: 1, - }) - - if err != nil { - logger.Error(err, "unable to create techsupport watcher") - return nil, err - } - - sourceTechsupport := source.Kind[*utilsv1beta1.Techsupport]( - mgr.GetCache(), - &utilsv1beta1.Techsupport{}, - handler.TypedEnqueueRequestsFromMapFunc(handlerTechsupportMapFun), - TechsupportPredicate{Logger: mgr.GetLogger().WithValues("predicate", "techsupportpredicate")}, - ) - - if err := c.Watch(sourceTechsupport); err != nil { - return nil, err - } - - sourceSveltosCluster := source.Kind[*libsveltosv1beta1.SveltosCluster]( - mgr.GetCache(), - &libsveltosv1beta1.SveltosCluster{}, - handler.TypedEnqueueRequestsFromMapFunc(requeueTechsupportForSveltosCluster), - SveltosClusterPredicate{Logger: mgr.GetLogger().WithValues("predicate", "sveltosclusterpredicate")}, - ) - - if err := c.Watch(sourceSveltosCluster); err != nil { - return nil, err - } - - // Start controller in a goroutine so not to block. - go func() { - // Start controller. This will block until the context is - // closed, or the controller returns an error. - logger.Info("Starting watcher controller") - if err := c.Start(ctx); err != nil { - logger.Error(err, "cannot run controller") - panic(1) - } - }() - - return c, nil -} - -func watchForCAPI(mgr ctrl.Manager, c controller.Controller) error { - sourceCluster := source.Kind[*clusterv1.Cluster]( - mgr.GetCache(), - &clusterv1.Cluster{}, - handler.TypedEnqueueRequestsFromMapFunc(requeueTechsupportForCluster), - ClusterPredicate{Logger: mgr.GetLogger().WithValues("predicate", "clusterpredicate")}, - ) - - // When cluster-api cluster changes, according to ClusterPredicates, - // one or more ClusterProfiles need to be reconciled. - if err := c.Watch(sourceCluster); err != nil { - return err - } - - return nil -} - // getNextScheduleTime gets the time of next schedule after last scheduled and before now func getNextScheduleTime(collectionInstance collection, now time.Time) (*time.Time, error) { sched, err := cron.ParseStandard(collectionInstance.getSchedule()) @@ -312,14 +210,10 @@ func addFinalizer(ctx context.Context, instance client.Object, finalizer string) types.NamespacedName{Name: instance.GetName()}, instance) } -func handlerSnapshotMapFun(ctx context.Context, snapshot *utilsv1beta1.Snapshot) []reconcile.Request { +func handlerSnapshotMapFun(ctx context.Context, snapshot *utilsv1alpha1.Snapshot) []reconcile.Request { return handlerMapFun(snapshot) } -func handlerTechsupportMapFun(ctx context.Context, techsupport *utilsv1beta1.Techsupport) []reconcile.Request { - return handlerMapFun(techsupport) -} - func handlerMapFun(o client.Object) []reconcile.Request { logger := textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))).WithValues( "objectMapper", @@ -340,16 +234,16 @@ func handlerMapFun(o client.Object) []reconcile.Request { } func updateStatus(result collector.Result, collectionInstance collection) { - var status utilsv1beta1.CollectionStatus + var status utilsv1alpha1.CollectionStatus var message string switch result.ResultStatus { case collector.Collected: - status = utilsv1beta1.CollectionStatusCollected + status = utilsv1alpha1.CollectionStatusCollected case collector.InProgress: - status = utilsv1beta1.CollectionStatusInProgress + status = utilsv1alpha1.CollectionStatusInProgress case collector.Failed: - status = utilsv1beta1.CollectionStatusFailed + status = utilsv1alpha1.CollectionStatusFailed message = result.Err.Error() case collector.Unavailable: return @@ -359,9 +253,9 @@ func updateStatus(result collector.Result, collectionInstance collection) { collectionInstance.setFailureMessage(message) } -func isCollectionInProgress(lastRunStatus *utilsv1beta1.CollectionStatus) bool { +func isCollectionInProgress(lastRunStatus *utilsv1alpha1.CollectionStatus) bool { return lastRunStatus != nil && - *lastRunStatus == utilsv1beta1.CollectionStatusInProgress + *lastRunStatus == utilsv1alpha1.CollectionStatusInProgress } func removeQueuedJobsAndFinalizer(c *collector.Collector, instance client.Object, collectionType collector.CollectionType, @@ -404,7 +298,7 @@ type SnapshotPredicate struct { Logger logr.Logger } -func (p SnapshotPredicate) Create(obj event.TypedCreateEvent[*utilsv1beta1.Snapshot]) bool { +func (p SnapshotPredicate) Create(obj event.TypedCreateEvent[*utilsv1alpha1.Snapshot]) bool { o := obj.Object p.Logger.Info(fmt.Sprintf("Create kind: %s Info: %s/%s", o.GetObjectKind().GroupVersionKind().Kind, @@ -412,11 +306,11 @@ func (p SnapshotPredicate) Create(obj event.TypedCreateEvent[*utilsv1beta1.Snaps return true } -func (p SnapshotPredicate) Update(obj event.TypedUpdateEvent[*utilsv1beta1.Snapshot]) bool { +func (p SnapshotPredicate) Update(obj event.TypedUpdateEvent[*utilsv1alpha1.Snapshot]) bool { return updateSnaphotPredicate(obj.ObjectNew, obj.ObjectOld) } -func (p SnapshotPredicate) Delete(obj event.TypedDeleteEvent[*utilsv1beta1.Snapshot]) bool { +func (p SnapshotPredicate) Delete(obj event.TypedDeleteEvent[*utilsv1alpha1.Snapshot]) bool { o := obj.Object p.Logger.Info(fmt.Sprintf("Delete kind: %s Info: %s/%s", o.GetObjectKind().GroupVersionKind().Kind, @@ -424,35 +318,7 @@ func (p SnapshotPredicate) Delete(obj event.TypedDeleteEvent[*utilsv1beta1.Snaps return true } -func (p SnapshotPredicate) Generic(obj event.TypedGenericEvent[*utilsv1beta1.Snapshot]) bool { - return false -} - -type TechsupportPredicate struct { - Logger logr.Logger -} - -func (p TechsupportPredicate) Create(obj event.TypedCreateEvent[*utilsv1beta1.Techsupport]) bool { - o := obj.Object - p.Logger.Info(fmt.Sprintf("Create kind: %s Info: %s/%s", - o.GetObjectKind().GroupVersionKind().Kind, - o.GetNamespace(), o.GetName())) - return true -} - -func (p TechsupportPredicate) Update(obj event.TypedUpdateEvent[*utilsv1beta1.Techsupport]) bool { - return updateTechsupportPredicate(obj.ObjectNew, obj.ObjectOld) -} - -func (p TechsupportPredicate) Delete(obj event.TypedDeleteEvent[*utilsv1beta1.Techsupport]) bool { - o := obj.Object - p.Logger.Info(fmt.Sprintf("Delete kind: %s Info: %s/%s", - o.GetObjectKind().GroupVersionKind().Kind, - o.GetNamespace(), o.GetName())) - return true -} - -func (p TechsupportPredicate) Generic(obj event.TypedGenericEvent[*utilsv1beta1.Techsupport]) bool { +func (p SnapshotPredicate) Generic(obj event.TypedGenericEvent[*utilsv1alpha1.Snapshot]) bool { return false } @@ -491,56 +357,3 @@ func schedule(ctx context.Context, instance client.Object, collectionType collec return nextRun, nil } - -// isCAPIInstalled returns true if CAPI is installed, false otherwise -func isCAPIInstalled(ctx context.Context, c client.Client) (bool, error) { - clusterCRD := &apiextensionsv1.CustomResourceDefinition{} - - err := c.Get(ctx, types.NamespacedName{Name: "clusters.cluster.x-k8s.io"}, clusterCRD) - if err != nil { - if apierrors.IsNotFound(err) { - return false, nil - } - return false, err - } - - return true, nil -} - -func capiWatchers(ctx context.Context, mgr ctrl.Manager, techsupportController controller.Controller, - logger logr.Logger) { - - const maxRetries = 20 - retries := 0 - for { - capiPresent, err := isCAPIInstalled(ctx, mgr.GetClient()) - if err != nil { - if retries < maxRetries { - logger.Info(fmt.Sprintf("failed to verify if CAPI is present: %v", err)) - time.Sleep(time.Second) - } - retries++ - } else { - if !capiPresent { - logger.V(logs.LogDebug).Info("CAPI currently not present. Starting CRD watcher") - go crd.WatchCustomResourceDefinition(ctx, mgr.GetConfig(), capiCRDHandler, logger) - } else { - logger.V(logsettings.LogInfo).Info("CAPI present.") - err = watchForCAPI(mgr, techsupportController) - if err != nil { - continue - } - } - return - } - } -} - -// capiCRDHandler restarts process if a CAPI CRD is updated -func capiCRDHandler(gvk *schema.GroupVersionKind) { - if gvk.Group == clusterv1.GroupVersion.Group { - if killErr := syscall.Kill(syscall.Getpid(), syscall.SIGTERM); killErr != nil { - panic("kill -TERM failed") - } - } -} diff --git a/internal/commands/show/addons.go b/internal/commands/show/addons.go index 0c2db463..f54f8e37 100644 --- a/internal/commands/show/addons.go +++ b/internal/commands/show/addons.go @@ -27,7 +27,7 @@ import ( "github.com/go-logr/logr" "github.com/olekukonko/tablewriter" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -118,7 +118,7 @@ func displayAddOnsInNamespace(ctx context.Context, namespace, passedCluster, pas return nil } -func displayAddOnsForCluster(clusterConfiguration *configv1alpha1.ClusterConfiguration, passedProfile string, +func displayAddOnsForCluster(clusterConfiguration *configv1beta1.ClusterConfiguration, passedProfile string, table *tablewriter.Table, logger logr.Logger) { instance := utils.GetAccessInstance() diff --git a/internal/commands/show/addons_test.go b/internal/commands/show/addons_test.go index 31213563..dad90c84 100644 --- a/internal/commands/show/addons_test.go +++ b/internal/commands/show/addons_test.go @@ -33,19 +33,19 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/commands/show" "github.com/projectsveltos/sveltosctl/internal/utils" ) var _ = Describe("AddOnss", func() { - var clusterConfiguration *configv1alpha1.ClusterConfiguration + var clusterConfiguration *configv1beta1.ClusterConfiguration var ns *corev1.Namespace BeforeEach(func() { namespace := namePrefix + randomString() - clusterConfiguration = &configv1alpha1.ClusterConfiguration{ + clusterConfiguration = &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: randomString(), @@ -61,13 +61,13 @@ var _ = Describe("AddOnss", func() { It("show addons displays deployed helm charts", func() { clusterProfileName1 := randomString() - charts1 := []configv1alpha1.Chart{ + charts1 := []configv1beta1.Chart{ *generateChart(), *generateChart(), } clusterConfiguration = addDeployedHelmCharts(clusterConfiguration, clusterProfileName1, charts1) clusterProfileName2 := randomString() - charts2 := []configv1alpha1.Chart{ + charts2 := []configv1beta1.Chart{ *generateChart(), *generateChart(), *generateChart(), } clusterConfiguration = addDeployedHelmCharts(clusterConfiguration, clusterProfileName2, charts2) @@ -112,13 +112,13 @@ var _ = Describe("AddOnss", func() { It("show addonss display deployed resources", func() { clusterProfileName1 := randomString() - resource1 := []configv1alpha1.Resource{ + resource1 := []configv1beta1.Resource{ *generateResource(), *generateResource(), *generateResource(), } clusterConfiguration = addDeployedResources(clusterConfiguration, clusterProfileName1, resource1) clusterProfileName2 := randomString() - resource2 := []configv1alpha1.Resource{ + resource2 := []configv1beta1.Resource{ *generateResource(), *generateResource(), *generateResource(), } clusterConfiguration = addDeployedResources(clusterConfiguration, clusterProfileName2, resource2) @@ -163,7 +163,7 @@ var _ = Describe("AddOnss", func() { }) func verifyCharts(lines []string, clusterInfo, clusterProfileName string, - charts []configv1alpha1.Chart) { + charts []configv1beta1.Chart) { for i := range charts { verifyChart(lines, clusterInfo, clusterProfileName, &charts[i]) @@ -171,7 +171,7 @@ func verifyCharts(lines []string, clusterInfo, clusterProfileName string, } func verifyChart(lines []string, clusterInfo, clusterProfileName string, - chart *configv1alpha1.Chart) { + chart *configv1beta1.Chart) { found := false for i := range lines { @@ -192,7 +192,7 @@ func verifyChart(lines []string, clusterInfo, clusterProfileName string, } func verifyResources(lines []string, clusterInfo, clusterProfileName string, - resources []configv1alpha1.Resource) { + resources []configv1beta1.Resource) { for i := range resources { verifyResource(lines, clusterInfo, clusterProfileName, &resources[i]) @@ -200,7 +200,7 @@ func verifyResources(lines []string, clusterInfo, clusterProfileName string, } func verifyResource(lines []string, clusterInfo, clusterProfileName string, - resource *configv1alpha1.Resource) { + resource *configv1beta1.Resource) { found := false for i := range lines { diff --git a/internal/commands/show/admin_rbacs.go b/internal/commands/show/admin_rbacs.go index 48d7dddb..f3130490 100644 --- a/internal/commands/show/admin_rbacs.go +++ b/internal/commands/show/admin_rbacs.go @@ -106,9 +106,9 @@ func createRoleRequestsPerClusterMap(roleRequests *libsveltosv1beta1.RoleRequest return clusterMap } -func parseMatchihgCluster(rr *libsveltosv1beta1.RoleRequest, - clusterMap map[corev1.ObjectReference][]*libsveltosv1beta1.RoleRequest, logger logr.Logger, -) map[corev1.ObjectReference][]*libsveltosv1beta1.RoleRequest { +func parseMatchihgCluster(rr *libsveltosv1alpha1.RoleRequest, + clusterMap map[corev1.ObjectReference][]*libsveltosv1alpha1.RoleRequest, logger logr.Logger, +) map[corev1.ObjectReference][]*libsveltosv1alpha1.RoleRequest { logger = logger.WithValues("rolerequest", rr.Name) logger.V(logs.LogDebug).Info("parsing matching clusters for roleRequets") @@ -122,7 +122,7 @@ func parseMatchihgCluster(rr *libsveltosv1beta1.RoleRequest, } func parseCluster(ctx context.Context, cluster *corev1.ObjectReference, - roleRequests []*libsveltosv1beta1.RoleRequest, + roleRequests []*libsveltosv1alpha1.RoleRequest, passedNamespace, passedCluster, passedServiceAccountNamespace, passedServiceAccountName string, table *tablewriter.Table, logger logr.Logger) error { @@ -142,7 +142,7 @@ func parseCluster(ctx context.Context, cluster *corev1.ObjectReference, return nil } -func shouldParseRoleRequest(roleRequest *libsveltosv1beta1.RoleRequest, +func shouldParseRoleRequest(roleRequest *libsveltosv1alpha1.RoleRequest, passedServiceAccountNamespace, passedServiceAccountName string) bool { if passedServiceAccountNamespace != "" { @@ -160,7 +160,7 @@ func shouldParseRoleRequest(roleRequest *libsveltosv1beta1.RoleRequest, return true } -func parseRoleRequest(ctx context.Context, roleRequest *libsveltosv1beta1.RoleRequest, +func parseRoleRequest(ctx context.Context, roleRequest *libsveltosv1alpha1.RoleRequest, clusterNamespace, clusterName, clusterKind, passedServiceAccountNamespace, passedServiceAccountName string, table *tablewriter.Table, logger logr.Logger) error { @@ -183,7 +183,7 @@ func parseRoleRequest(ctx context.Context, roleRequest *libsveltosv1beta1.RoleRe func parseReferencedResource(ctx context.Context, clusterNamespace, clusterName, clusterKind, serviceAccountNamespace, serviceAccountName string, - resource libsveltosv1beta1.PolicyRef, table *tablewriter.Table, logger logr.Logger) error { + resource libsveltosv1alpha1.PolicyRef, table *tablewriter.Table, logger logr.Logger) error { // fetch resource content, err := collectResourceContent(ctx, resource, logger) diff --git a/internal/commands/show/admin_rbacs_test.go b/internal/commands/show/admin_rbacs_test.go index 41dd7dd9..4601d8ea 100644 --- a/internal/commands/show/admin_rbacs_test.go +++ b/internal/commands/show/admin_rbacs_test.go @@ -152,14 +152,14 @@ var _ = Describe("Admin RBACs", func() { func getRoleRequest(matchingClusters []corev1.ObjectReference, configMaps []corev1.ConfigMap, secrets []corev1.Secret, - serviceAccountNamespace, serviceAccountName string) *libsveltosv1beta1.RoleRequest { + serviceAccountNamespace, serviceAccountName string) *libsveltosv1alpha1.RoleRequest { roleRequest := libsveltosv1beta1.RoleRequest{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: libsveltosv1beta1.RoleRequestSpec{ - RoleRefs: make([]libsveltosv1beta1.PolicyRef, 0), + Spec: libsveltosv1alpha1.RoleRequestSpec{ + RoleRefs: make([]libsveltosv1alpha1.PolicyRef, 0), ServiceAccountNamespace: serviceAccountNamespace, ServiceAccountName: serviceAccountName, }, diff --git a/internal/commands/show/dryrun.go b/internal/commands/show/dryrun.go index 60dffe56..a003f3e3 100644 --- a/internal/commands/show/dryrun.go +++ b/internal/commands/show/dryrun.go @@ -27,8 +27,11 @@ import ( "github.com/docopt/docopt-go" "github.com/go-logr/logr" "github.com/olekukonko/tablewriter" + "github.com/pkg/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -54,13 +57,13 @@ var ( ) func displayDryRun(ctx context.Context, passedNamespace, passedCluster, passedProfile string, - rawDiff bool, logger logr.Logger) error { + logger logr.Logger) error { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"CLUSTER", "RESOURCE TYPE", "NAMESPACE", "NAME", "ACTION", "MESSAGE", "PROFILE"}) if err := displayDryRunInNamespaces(ctx, passedNamespace, passedCluster, - passedProfile, table, rawDiff, logger); err != nil { + passedProfile, table, logger); err != nil { return err } @@ -72,7 +75,7 @@ func displayDryRun(ctx context.Context, passedNamespace, passedCluster, passedPr } func displayDryRunInNamespaces(ctx context.Context, passedNamespace, passedCluster, passedProfile string, - table *tablewriter.Table, rawDiff bool, logger logr.Logger) error { + table *tablewriter.Table, logger logr.Logger) error { instance := utils.GetAccessInstance() @@ -86,7 +89,7 @@ func displayDryRunInNamespaces(ctx context.Context, passedNamespace, passedClust if doConsiderNamespace(ns, passedNamespace) { logger.V(logs.LogDebug).Info(fmt.Sprintf("Considering namespace: %s", ns.Name)) err = displayDryRunInNamespace(ctx, ns.Name, passedCluster, passedProfile, - table, rawDiff, logger) + table, logger) if err != nil { return err } @@ -97,7 +100,7 @@ func displayDryRunInNamespaces(ctx context.Context, passedNamespace, passedClust } func displayDryRunInNamespace(ctx context.Context, namespace, passedCluster, passedProfile string, - table *tablewriter.Table, rawDiff bool, logger logr.Logger) error { + table *tablewriter.Table, logger logr.Logger) error { instance := utils.GetAccessInstance() @@ -114,7 +117,7 @@ func displayDryRunInNamespace(ctx context.Context, namespace, passedCluster, pas for i := range clusterReports.Items { cr := &clusterReports.Items[i] - profileLabel := cr.Labels["projectsveltos.io/cluster-profile-name"] + profileLabel := cr.Labels[controllers.ClusterProfileLabelName] // TODO: find a better way to identify clusterreports created by ClusterProfile // vs clusterreports created by Profile @@ -131,39 +134,58 @@ func displayDryRunInNamespace(ctx context.Context, namespace, passedCluster, pas doConsiderProfile([]string{profileName}, passedProfile) { logger.V(logs.LogDebug).Info(fmt.Sprintf("Considering ClusterReport: %s", cr.Name)) - displayDryRunForCluster(cr, profileName, table, rawDiff) + err = displayDryRunForCluster(cr, profileName, table, rawDiff) + if err != nil { + return err + } } } return nil } -func displayDryRunForCluster(clusterReport *configv1alpha1.ClusterReport, profileName string, - table *tablewriter.Table, rawDiff bool) { +func displayDryRunForCluster(clusterReport *configv1beta1.ClusterReport, profileName string, + table *tablewriter.Table, rawDiff bool) error { clusterInfo := fmt.Sprintf("%s/%s", clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName) + profileOwner, err := getProfileOwnerReference(clusterReport) + if err != nil { + return err + } + updateMessage := "use --raw-diff to see full diff for helm values" for i := range clusterReport.Status.ReleaseReports { report := &clusterReport.Status.ReleaseReports[i] + message := report.Message + if report.Action == string(configv1beta1.UpdateHelmValuesAction) { + message = updateMessage + } table.Append(genDryRunRow(clusterInfo, "helm release", report.ReleaseNamespace, report.ReleaseName, - report.Action, report.Message, profileName)) + report.Action, message, profileName)) + if rawDiff { + if rawDiff && report.Message != "" && report.Action == string(configv1beta1.UpdateHelmValuesAction) { + //nolint: forbidigo // print diff + fmt.Printf("Profile: %s:%s Cluster: %s/%s\n%s\n", profileOwner.Kind, profileOwner.Name, + clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName, report.Message) + } + } } - updateMessage := "use --raw-diff to see full diff" + updateMessage = "use --raw-diff to see full diff" for i := range clusterReport.Status.ResourceReports { report := &clusterReport.Status.ResourceReports[i] groupKind := fmt.Sprintf("%s:%s", report.Resource.Group, report.Resource.Kind) message := report.Message - if report.Action == string(configv1alpha1.UpdateResourceAction) { + if report.Action == string(configv1beta1.UpdateResourceAction) { message = updateMessage } table.Append(genDryRunRow(clusterInfo, groupKind, report.Resource.Namespace, report.Resource.Name, report.Action, message, profileName)) if rawDiff { - if rawDiff && report.Message != "" && report.Action == string(configv1alpha1.UpdateResourceAction) { + if rawDiff && report.Message != "" && report.Action == string(configv1beta1.UpdateResourceAction) { //nolint: forbidigo // print diff - fmt.Printf("Cluster: %s/%s\n%s\n", clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName, - report.Message) + fmt.Printf("Profile: %s:%s Cluster: %s/%s\n%s\n", profileOwner.Kind, profileOwner.Name, + clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName, report.Message) } } } @@ -172,26 +194,28 @@ func displayDryRunForCluster(clusterReport *configv1alpha1.ClusterReport, profil report := &clusterReport.Status.KustomizeResourceReports[i] groupKind := fmt.Sprintf("%s:%s", report.Resource.Group, report.Resource.Kind) message := report.Message - if report.Action == string(configv1alpha1.UpdateResourceAction) { + if report.Action == string(configv1beta1.UpdateResourceAction) { message = updateMessage } table.Append(genDryRunRow(clusterInfo, groupKind, report.Resource.Namespace, report.Resource.Name, report.Action, message, profileName)) if rawDiff { - if rawDiff && report.Message != "" && report.Action == string(configv1alpha1.UpdateResourceAction) { + if rawDiff && report.Message != "" && report.Action == string(configv1beta1.UpdateResourceAction) { //nolint: forbidigo // print diff - fmt.Printf("Cluster: %s/%s\n%s\n", clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName, - report.Message) + fmt.Printf("Profile: %s:%s Cluster: %s/%s\n%s\n", profileOwner.Kind, profileOwner.Name, + clusterReport.Spec.ClusterNamespace, clusterReport.Spec.ClusterName, report.Message) } } } + + return nil } // DryRun displays information about which Kubernetes addons would change in which cluster due // to a ClusterProfile currently in DryRun mode, func DryRun(ctx context.Context, args []string, logger logr.Logger) error { doc := `Usage: - sveltosctl show dryrun [options] [--namespace=] [--cluster=] [--profile=] [--raw-diff] [--verbose] + sveltosctl show dryrun [options] [--namespace=] [--cluster=] [--profile=] [--verbose] --namespace= Show which Kubernetes addons would change in clusters in this namespace. If not specified all namespaces are considered. @@ -199,7 +223,6 @@ func DryRun(ctx context.Context, args []string, logger logr.Logger) error { If not specified all cluster names are considered. --profile= Show which Kubernetes addons would change because of this clusterprofile/profile. If not specified all clusterprofiles/profiles are considered. - --raw-diff With this flag, for each resource that would be update, full diff will be displayed. Options: -h --help Show this screen. @@ -245,7 +268,25 @@ Description: profile = passedProfile.(string) } - rawDiff := parsedArgs["--raw-diff"].(bool) + return displayDryRun(ctx, namespace, cluster, profile, logger) +} + +// getProfileOwnerReference returns the ClusterProfile/Profile owning a given ClusterReport +func getProfileOwnerReference(clusterReport *configv1beta1.ClusterReport) (*metav1.OwnerReference, error) { + for _, ref := range clusterReport.OwnerReferences { + if ref.Kind != configv1beta1.ClusterProfileKind && + ref.Kind != configv1beta1.ProfileKind { + + continue + } + gv, err := schema.ParseGroupVersion(ref.APIVersion) + if err != nil { + return nil, errors.WithStack(err) + } + if gv.Group == configv1beta1.GroupVersion.Group { + return &ref, nil + } + } - return displayDryRun(ctx, namespace, cluster, profile, rawDiff, logger) + return nil, fmt.Errorf("(Cluster)Profile owner not found") } diff --git a/internal/commands/show/dryrun_test.go b/internal/commands/show/dryrun_test.go index 2e6cdfc9..5313c5f9 100644 --- a/internal/commands/show/dryrun_test.go +++ b/internal/commands/show/dryrun_test.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/commands/show" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -55,49 +55,63 @@ var _ = Describe("DryRun", func() { clusterNamespace := ns.Name clusterName := randomString() - releaseReports1 := []configv1alpha1.ReleaseReport{ - *generateReleaseReport(string(configv1alpha1.HelmChartActionInstall)), - *generateReleaseReport(string(configv1alpha1.NoHelmAction)), + releaseReports1 := []configv1beta1.ReleaseReport{ + *generateReleaseReport(string(configv1beta1.HelmChartActionInstall)), + *generateReleaseReport(string(configv1beta1.NoHelmAction)), } clusterProfileName1 := randomString() - clusterReport1 := &configv1alpha1.ClusterReport{ + clusterReport1 := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns.Name, Name: randomString(), Labels: map[string]string{ "projectsveltos.io/cluster-profile-name": clusterProfileName1, }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: configv1beta1.ClusterProfileKind, + Name: randomString(), + APIVersion: configv1beta1.GroupVersion.String(), + }, + }, }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterNamespace: clusterNamespace, ClusterName: clusterName, }, - Status: configv1alpha1.ClusterReportStatus{ + Status: configv1beta1.ClusterReportStatus{ ReleaseReports: releaseReports1, }, } - releaseReports2 := []configv1alpha1.ReleaseReport{ - *generateReleaseReport(string(configv1alpha1.HelmChartActionInstall)), - *generateReleaseReport(string(configv1alpha1.HelmChartActionUninstall)), - *generateReleaseReport(string(configv1alpha1.NoHelmAction)), + releaseReports2 := []configv1beta1.ReleaseReport{ + *generateReleaseReport(string(configv1beta1.HelmChartActionInstall)), + *generateReleaseReport(string(configv1beta1.HelmChartActionUninstall)), + *generateReleaseReport(string(configv1beta1.NoHelmAction)), } clusterProfileName2 := randomString() - clusterReport2 := &configv1alpha1.ClusterReport{ + clusterReport2 := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns.Name, Name: randomString(), Labels: map[string]string{ "projectsveltos.io/cluster-profile-name": clusterProfileName2, }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: configv1beta1.ClusterProfileKind, + Name: randomString(), + APIVersion: configv1beta1.GroupVersion.String(), + }, + }, }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterNamespace: clusterNamespace, ClusterName: clusterName, }, - Status: configv1alpha1.ClusterReportStatus{ + Status: configv1beta1.ClusterReportStatus{ ReleaseReports: releaseReports2, }, } @@ -113,7 +127,7 @@ var _ = Describe("DryRun", func() { c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build() utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - err = show.DisplayDryRun(context.TODO(), "", "", "", false, + err = show.DisplayDryRun(context.TODO(), "", "", "", textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) @@ -150,50 +164,64 @@ var _ = Describe("DryRun", func() { clusterNamespace := ns.Name clusterName := randomString() - resourceReports1 := []configv1alpha1.ResourceReport{ - *generateResourceReport(string(configv1alpha1.HelmChartActionInstall)), - *generateResourceReport(string(configv1alpha1.NoHelmAction)), + resourceReports1 := []configv1beta1.ResourceReport{ + *generateResourceReport(string(configv1beta1.HelmChartActionInstall)), + *generateResourceReport(string(configv1beta1.NoHelmAction)), } clusterProfileName1 := randomString() - clusterReport1 := &configv1alpha1.ClusterReport{ + clusterReport1 := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns.Name, Name: randomString(), Labels: map[string]string{ "projectsveltos.io/cluster-profile-name": clusterProfileName1, }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: configv1beta1.ClusterProfileKind, + Name: randomString(), + APIVersion: configv1beta1.GroupVersion.String(), + }, + }, }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterNamespace: clusterNamespace, ClusterName: clusterName, }, - Status: configv1alpha1.ClusterReportStatus{ + Status: configv1beta1.ClusterReportStatus{ ResourceReports: resourceReports1, }, } - resourceReports2 := []configv1alpha1.ResourceReport{ - *generateResourceReport(string(configv1alpha1.CreateResourceAction)), - *generateResourceReport(string(configv1alpha1.UpdateResourceAction)), - *generateResourceReport(string(configv1alpha1.NoResourceAction)), - *generateResourceReport(string(configv1alpha1.DeleteResourceAction)), + resourceReports2 := []configv1beta1.ResourceReport{ + *generateResourceReport(string(configv1beta1.CreateResourceAction)), + *generateResourceReport(string(configv1beta1.UpdateResourceAction)), + *generateResourceReport(string(configv1beta1.NoResourceAction)), + *generateResourceReport(string(configv1beta1.DeleteResourceAction)), } clusterProfileName2 := randomString() - clusterReport2 := &configv1alpha1.ClusterReport{ + clusterReport2 := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns.Name, Name: randomString(), Labels: map[string]string{ "projectsveltos.io/cluster-profile-name": clusterProfileName2, }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: configv1beta1.ClusterProfileKind, + Name: randomString(), + APIVersion: configv1beta1.GroupVersion.String(), + }, + }, }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterNamespace: clusterNamespace, ClusterName: clusterName, }, - Status: configv1alpha1.ClusterReportStatus{ + Status: configv1beta1.ClusterReportStatus{ ResourceReports: resourceReports2, }, } @@ -209,7 +237,7 @@ var _ = Describe("DryRun", func() { c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build() utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - err = show.DisplayDryRun(context.TODO(), "", "", "", false, + err = show.DisplayDryRun(context.TODO(), "", "", "", textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) @@ -238,7 +266,7 @@ var _ = Describe("DryRun", func() { }) func verifyReleaseReports(lines []string, clusterInfo, clusterProfileName string, - releaseReports []configv1alpha1.ReleaseReport) { + releaseReports []configv1beta1.ReleaseReport) { for i := range releaseReports { verifyReleaseReport(lines, clusterInfo, clusterProfileName, &releaseReports[i]) @@ -246,7 +274,7 @@ func verifyReleaseReports(lines []string, clusterInfo, clusterProfileName string } func verifyReleaseReport(lines []string, clusterInfo, clusterProfileName string, - releaseReport *configv1alpha1.ReleaseReport) { + releaseReport *configv1beta1.ReleaseReport) { found := false for i := range lines { @@ -269,7 +297,7 @@ func verifyReleaseReport(lines []string, clusterInfo, clusterProfileName string, } func verifyResourceReports(lines []string, clusterInfo, clusterProfileName string, - resourceReports []configv1alpha1.ResourceReport) { + resourceReports []configv1beta1.ResourceReport) { for i := range resourceReports { verifyResourceReport(lines, clusterInfo, clusterProfileName, &resourceReports[i]) @@ -277,7 +305,7 @@ func verifyResourceReports(lines []string, clusterInfo, clusterProfileName strin } func verifyResourceReport(lines []string, clusterInfo, clusterProfileName string, - resourceReport *configv1alpha1.ResourceReport) { + resourceReport *configv1beta1.ResourceReport) { found := false for i := range lines { diff --git a/internal/commands/show/resources.go b/internal/commands/show/resources.go index f6e70c8b..077f700f 100644 --- a/internal/commands/show/resources.go +++ b/internal/commands/show/resources.go @@ -27,11 +27,11 @@ import ( "github.com/fatih/color" "github.com/go-logr/logr" "github.com/olekukonko/tablewriter" - "gopkg.in/yaml.v3" + "gopkg.in/yaml.v2" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - "github.com/projectsveltos/libsveltos/lib/k8s_utils" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" + libsveltosutils "github.com/projectsveltos/libsveltos/lib/utils" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -107,7 +107,7 @@ func displayResourcesInNamespaces(ctx context.Context, return nil } -func displayResourcesInReport(healthCheckReport *libsveltosv1beta1.HealthCheckReport, +func displayResourcesInReport(healthCheckReport *libsveltosv1alpha1.HealthCheckReport, passedGroup, passedKind, passedNamespace string, full bool, table *tablewriter.Table, logger logr.Logger) error { @@ -134,7 +134,7 @@ func displayResourcesInReport(healthCheckReport *libsveltosv1beta1.HealthCheckRe return nil } -func displayResource(resourceStatus *libsveltosv1beta1.ResourceStatus, +func displayResource(resourceStatus *libsveltosv1alpha1.ResourceStatus, clusterNamespace, clusterName string, table *tablewriter.Table) { clusterInfo := fmt.Sprintf("%s/%s", clusterNamespace, clusterName) @@ -143,7 +143,7 @@ func displayResource(resourceStatus *libsveltosv1beta1.ResourceStatus, resourceName := resourceStatus.ObjectRef.Name message := resourceStatus.Message - if resourceStatus.HealthStatus != libsveltosv1beta1.HealthStatusHealthy { + if resourceStatus.HealthStatus != libsveltosv1alpha1.HealthStatusHealthy { data := []string{clusterInfo, gvk, resourceNamespace, resourceName, message} table.Rich(data, []tablewriter.Colors{{tablewriter.Bold, tablewriter.FgBlackColor}, {tablewriter.Bold, tablewriter.FgBlackColor}, {tablewriter.Bold, tablewriter.BgRedColor}, @@ -154,7 +154,7 @@ func displayResource(resourceStatus *libsveltosv1beta1.ResourceStatus, table.Append(genResourceRow(clusterInfo, gvk, resourceNamespace, resourceName, message)) } -func printResource(resourceStatus *libsveltosv1beta1.ResourceStatus, +func printResource(resourceStatus *libsveltosv1alpha1.ResourceStatus, clusterNamespace, clusterName string, logger logr.Logger) error { clusterInfo := fmt.Sprintf("%s/%s", clusterNamespace, clusterName) @@ -167,7 +167,7 @@ func printResource(resourceStatus *libsveltosv1beta1.ResourceStatus, return nil } - resource, err := k8s_utils.GetUnstructured(resourceStatus.Resource) + resource, err := libsveltosutils.GetUnstructured(resourceStatus.Resource) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to get resource %s:%s/%s", gvk, resourceNamespace, resourceName)) @@ -179,7 +179,7 @@ func printResource(resourceStatus *libsveltosv1beta1.ResourceStatus, return err } - if resourceStatus.HealthStatus != libsveltosv1beta1.HealthStatusHealthy { + if resourceStatus.HealthStatus != libsveltosv1alpha1.HealthStatusHealthy { red := color.New(color.FgRed).SprintfFunc() //nolint: forbidigo // printing results to stdout fmt.Println("Cluster: ", red(clusterInfo)) @@ -195,7 +195,7 @@ func printResource(resourceStatus *libsveltosv1beta1.ResourceStatus, return nil } -func doConsiderResourceStatus(resourceStatus *libsveltosv1beta1.ResourceStatus, +func doConsiderResourceStatus(resourceStatus *libsveltosv1alpha1.ResourceStatus, passedGroup, passedKind, passedNamespace string) bool { if passedGroup != "" { diff --git a/internal/commands/show/resources_test.go b/internal/commands/show/resources_test.go index 2c490c56..93b1efc1 100644 --- a/internal/commands/show/resources_test.go +++ b/internal/commands/show/resources_test.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/commands/show" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -43,16 +43,16 @@ var _ = Describe("Resources", func() { It("show resources displays resources from various managed clusters", func() { message := "All replicas 1 are healthy" - hcr := &libsveltosv1beta1.HealthCheckReport{ + hcr := &libsveltosv1alpha1.HealthCheckReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: libsveltosv1beta1.HealthCheckReportSpec{ + Spec: libsveltosv1alpha1.HealthCheckReportSpec{ ClusterNamespace: randomString(), ClusterName: randomString(), - ClusterType: libsveltosv1beta1.ClusterTypeSveltos, - ResourceStatuses: []libsveltosv1beta1.ResourceStatus{ + ClusterType: libsveltosv1alpha1.ClusterTypeSveltos, + ResourceStatuses: []libsveltosv1alpha1.ResourceStatus{ { Resource: nil, ObjectRef: corev1.ObjectReference{ @@ -62,7 +62,7 @@ var _ = Describe("Resources", func() { Name: randomString(), }, Message: message, - HealthStatus: libsveltosv1beta1.HealthStatusHealthy, + HealthStatus: libsveltosv1alpha1.HealthStatusHealthy, }, { Resource: nil, @@ -73,7 +73,7 @@ var _ = Describe("Resources", func() { Name: randomString(), }, Message: message, - HealthStatus: libsveltosv1beta1.HealthStatusHealthy, + HealthStatus: libsveltosv1alpha1.HealthStatusHealthy, }, }, }, diff --git a/internal/commands/show/usage.go b/internal/commands/show/usage.go index 74a02a66..55ffaecc 100644 --- a/internal/commands/show/usage.go +++ b/internal/commands/show/usage.go @@ -28,7 +28,7 @@ import ( "github.com/olekukonko/tablewriter" corev1 "k8s.io/api/core/v1" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" "github.com/projectsveltos/sveltosctl/internal/utils" @@ -53,17 +53,17 @@ func showUsage(ctx context.Context, kind, passedNamespace, passedName string, lo table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"RESOURCE KIND", "RESOURCE NAMESPACE", "RESOURCE NAME", "CLUSTERS"}) - if kind == "" || kind == configv1alpha1.ClusterProfileKind { + if kind == "" || kind == configv1beta1.ClusterProfileKind { if err := showUsageForClusterProfiles(ctx, passedName, table, logger); err != nil { return err } } - if kind == "" || kind == configv1alpha1.ProfileKind { + if kind == "" || kind == configv1beta1.ProfileKind { if err := showUsageForProfiles(ctx, passedName, table, logger); err != nil { return err } } - if kind == "" || kind == string(libsveltosv1beta1.ConfigMapReferencedResourceKind) { + if kind == "" || kind == string(libsveltosv1alpha1.ConfigMapReferencedResourceKind) { if err := showUsageForConfigMaps(ctx, passedNamespace, passedName, table, logger); err != nil { return err } @@ -106,14 +106,14 @@ func showUsageForClusterProfiles(ctx context.Context, passedName string, table * return nil } -func showUsageForClusterProfile(clusterProfile *configv1alpha1.ClusterProfile, table *tablewriter.Table, +func showUsageForClusterProfile(clusterProfile *configv1beta1.ClusterProfile, table *tablewriter.Table, logger logr.Logger) { logger.V(logs.LogDebug).Info(fmt.Sprintf("Considering ClusterProfile %s", clusterProfile.Name)) clusters := getMatchingClusters(clusterProfile.Status.MatchingClusterRefs) - table.Append(genUsageRow(configv1alpha1.ClusterProfileKind, "", clusterProfile.Name, clusters)) + table.Append(genUsageRow(configv1beta1.ClusterProfileKind, "", clusterProfile.Name, clusters)) } func showUsageForProfiles(ctx context.Context, passedName string, table *tablewriter.Table, logger logr.Logger) error { @@ -134,21 +134,21 @@ func showUsageForProfiles(ctx context.Context, passedName string, table *tablewr return nil } -func showUsageForProfile(profile *configv1alpha1.Profile, table *tablewriter.Table, +func showUsageForProfile(profile *configv1beta1.Profile, table *tablewriter.Table, logger logr.Logger) { logger.V(logs.LogDebug).Info(fmt.Sprintf("Considering Profile %s", profile.Name)) clusters := getMatchingClusters(profile.Status.MatchingClusterRefs) - table.Append(genUsageRow(configv1alpha1.ProfileKind, "", profile.Name, clusters)) + table.Append(genUsageRow(configv1beta1.ProfileKind, "", profile.Name, clusters)) } func showUsageForConfigMaps(ctx context.Context, passedNamespace, passedName string, table *tablewriter.Table, logger logr.Logger) error { instance := utils.GetAccessInstance() - result := make(map[configv1alpha1.PolicyRef][]string) + result := make(map[configv1beta1.PolicyRef][]string) cps, err := instance.ListClusterProfiles(ctx, logger) if err != nil { @@ -186,7 +186,7 @@ func showUsageForSecrets(ctx context.Context, passedNamespace, passedName string table *tablewriter.Table, logger logr.Logger) error { instance := utils.GetAccessInstance() - result := make(map[configv1alpha1.PolicyRef][]string) + result := make(map[configv1beta1.PolicyRef][]string) cps, err := instance.ListClusterProfiles(ctx, logger) if err != nil { @@ -220,13 +220,13 @@ func showUsageForSecrets(ctx context.Context, passedNamespace, passedName string return nil } -func getConfigMaps(passedNamespace, passedName string, policyRefs []configv1alpha1.PolicyRef, - matchingClusterRefs []corev1.ObjectReference, result map[configv1alpha1.PolicyRef][]string, logger logr.Logger) { +func getConfigMaps(passedNamespace, passedName string, policyRefs []configv1beta1.PolicyRef, + matchingClusterRefs []corev1.ObjectReference, result map[configv1beta1.PolicyRef][]string, logger logr.Logger) { - configMaps := make([]configv1alpha1.PolicyRef, 0) + configMaps := make([]configv1beta1.PolicyRef, 0) for i := range policyRefs { pr := &policyRefs[i] - if pr.Kind == string(libsveltosv1beta1.ConfigMapReferencedResourceKind) { + if pr.Kind == string(libsveltosv1alpha1.ConfigMapReferencedResourceKind) { if shouldAddPolicyRef(passedNamespace, passedName, pr) { logger.V(logs.LogDebug).Info(fmt.Sprintf("considering reference configMap %s/%s", pr.Namespace, pr.Name)) @@ -246,13 +246,13 @@ func getConfigMaps(passedNamespace, passedName string, policyRefs []configv1alph } } -func getSecrets(passedNamespace, passedName string, policyRefs []configv1alpha1.PolicyRef, - matchingClusterRefs []corev1.ObjectReference, result map[configv1alpha1.PolicyRef][]string, logger logr.Logger) { +func getSecrets(passedNamespace, passedName string, policyRefs []configv1beta1.PolicyRef, + matchingClusterRefs []corev1.ObjectReference, result map[configv1beta1.PolicyRef][]string, logger logr.Logger) { - secrets := make([]configv1alpha1.PolicyRef, 0) + secrets := make([]configv1beta1.PolicyRef, 0) for i := range policyRefs { pr := &policyRefs[i] - if pr.Kind == string(libsveltosv1beta1.SecretReferencedResourceKind) { + if pr.Kind == string(libsveltosv1alpha1.SecretReferencedResourceKind) { if shouldAddPolicyRef(passedNamespace, passedName, pr) { logger.V(logs.LogDebug).Info(fmt.Sprintf("considering reference secret %s/%s", pr.Namespace, pr.Name)) @@ -272,7 +272,7 @@ func getSecrets(passedNamespace, passedName string, policyRefs []configv1alpha1. } } -func shouldAddPolicyRef(passedNamespace, passedName string, pr *configv1alpha1.PolicyRef) bool { +func shouldAddPolicyRef(passedNamespace, passedName string, pr *configv1beta1.PolicyRef) bool { if passedNamespace != "" && pr.Namespace != passedNamespace { @@ -344,13 +344,13 @@ Description: kind := "" if passedKind := parsedArgs["--kind"]; passedKind != nil { kind = passedKind.(string) - if kind != configv1alpha1.ClusterProfileKind && - kind != configv1alpha1.ProfileKind && + if kind != configv1beta1.ClusterProfileKind && + kind != configv1beta1.ProfileKind && kind != string(libsveltosv1beta1.ConfigMapReferencedResourceKind) && kind != string(libsveltosv1beta1.SecretReferencedResourceKind) { return fmt.Errorf("possible values for kind are: %s, %s, %s, %s", - configv1alpha1.ClusterProfileKind, configv1alpha1.ProfileKind, + configv1beta1.ClusterProfileKind, configv1beta1.ProfileKind, string(libsveltosv1beta1.ConfigMapReferencedResourceKind), string(libsveltosv1beta1.SecretReferencedResourceKind), ) diff --git a/internal/commands/show/usage_test.go b/internal/commands/show/usage_test.go index f7ffb1d5..84e8fe49 100644 --- a/internal/commands/show/usage_test.go +++ b/internal/commands/show/usage_test.go @@ -33,7 +33,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2/textlogger" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/commands/show" "github.com/projectsveltos/sveltosctl/internal/utils" @@ -41,20 +41,20 @@ import ( var _ = Describe("Usage", func() { It("showUsage displays per resource, associated list of CAPI clusters", func() { - configMap := configv1alpha1.PolicyRef{ + configMap := configv1beta1.PolicyRef{ Namespace: randomString(), Name: randomString(), Kind: string(libsveltosv1beta1.ConfigMapReferencedResourceKind), } - secret := configv1alpha1.PolicyRef{ + secret := configv1beta1.PolicyRef{ Namespace: randomString(), Name: randomString(), Kind: string(libsveltosv1beta1.SecretReferencedResourceKind), } clusterProfile1 := generateClusterProfile() - clusterProfile1.Spec.PolicyRefs = []configv1alpha1.PolicyRef{ + clusterProfile1.Spec.PolicyRefs = []configv1beta1.PolicyRef{ configMap, } clusterProfile1.Status.MatchingClusterRefs = []corev1.ObjectReference{ @@ -62,7 +62,7 @@ var _ = Describe("Usage", func() { } clusterProfile2 := generateClusterProfile() - clusterProfile2.Spec.PolicyRefs = []configv1alpha1.PolicyRef{ + clusterProfile2.Spec.PolicyRefs = []configv1beta1.PolicyRef{ secret, } clusterProfile2.Status.MatchingClusterRefs = []corev1.ObjectReference{ @@ -111,9 +111,9 @@ var _ = Describe("Usage", func() { }) }) -func verifyClusterProfileUsage(lines []string, clusterProfile *configv1alpha1.ClusterProfile) { +func verifyClusterProfileUsage(lines []string, clusterProfile *configv1beta1.ClusterProfile) { for i := range clusterProfile.Status.MatchingClusterRefs { - verifyUsage(lines, configv1alpha1.ClusterProfileKind, "", clusterProfile.Name, + verifyUsage(lines, configv1beta1.ClusterProfileKind, "", clusterProfile.Name, &clusterProfile.Status.MatchingClusterRefs[i]) } } @@ -133,18 +133,18 @@ func verifyUsage(lines []string, kind, namespace, name string, matchingCluster * Expect(found).To(BeTrue()) } -func generateClusterProfile() *configv1alpha1.ClusterProfile { - return &configv1alpha1.ClusterProfile{ +func generateClusterProfile() *configv1beta1.ClusterProfile { + return &configv1beta1.ClusterProfile{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: configv1alpha1.Spec{ + Spec: configv1beta1.Spec{ ClusterSelector: libsveltosv1beta1.Selector{ LabelSelector: metav1.LabelSelector{ MatchLabels: map[string]string{"zone": "west"}, }, }, - SyncMode: configv1alpha1.SyncModeContinuous, + SyncMode: configv1beta1.SyncModeContinuous, }, } } diff --git a/internal/commands/show/utils.go b/internal/commands/show/utils.go index 5b9d573b..d639b6ad 100644 --- a/internal/commands/show/utils.go +++ b/internal/commands/show/utils.go @@ -19,7 +19,7 @@ package show import ( corev1 "k8s.io/api/core/v1" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" ) func doConsiderNamespace(ns *corev1.Namespace, passedNamespace string) bool { @@ -30,7 +30,7 @@ func doConsiderNamespace(ns *corev1.Namespace, passedNamespace string) bool { return ns.Name == passedNamespace } -func doConsiderClusterConfiguration(clusterConfiguration *configv1alpha1.ClusterConfiguration, +func doConsiderClusterConfiguration(clusterConfiguration *configv1beta1.ClusterConfiguration, passedCluster string) bool { if passedCluster == "" { @@ -41,11 +41,11 @@ func doConsiderClusterConfiguration(clusterConfiguration *configv1alpha1.Cluster return false } - clusterName := clusterConfiguration.Labels[configv1alpha1.ClusterNameLabel] + clusterName := clusterConfiguration.Labels[configv1beta1.ClusterNameLabel] return clusterName == passedCluster } -func doConsiderClusterReport(clusterReport *configv1alpha1.ClusterReport, +func doConsiderClusterReport(clusterReport *configv1beta1.ClusterReport, passedCluster string) bool { if passedCluster == "" { diff --git a/internal/commands/show/utils_test.go b/internal/commands/show/utils_test.go index 22b85787..716872ef 100644 --- a/internal/commands/show/utils_test.go +++ b/internal/commands/show/utils_test.go @@ -30,27 +30,27 @@ import ( "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/controller-runtime/pkg/client" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/utils" ) // addDeployedHelmCharts adds provided charts as deployed in clusterConfiguration status -func addDeployedHelmCharts(clusterConfiguration *configv1alpha1.ClusterConfiguration, - clusterProfileName string, charts []configv1alpha1.Chart) *configv1alpha1.ClusterConfiguration { +func addDeployedHelmCharts(clusterConfiguration *configv1beta1.ClusterConfiguration, + clusterProfileName string, charts []configv1beta1.Chart) *configv1beta1.ClusterConfiguration { if clusterConfiguration.Status.ClusterProfileResources == nil { - clusterConfiguration.Status.ClusterProfileResources = make([]configv1alpha1.ClusterProfileResource, 0) + clusterConfiguration.Status.ClusterProfileResources = make([]configv1beta1.ClusterProfileResource, 0) } for i := range clusterConfiguration.Status.ClusterProfileResources { cfr := &clusterConfiguration.Status.ClusterProfileResources[i] if cfr.ClusterProfileName == clusterProfileName { if cfr.Features == nil { - cfr.Features = make([]configv1alpha1.Feature, 0) + cfr.Features = make([]configv1beta1.Feature, 0) } cfr.Features = append(cfr.Features, - configv1alpha1.Feature{ - FeatureID: configv1alpha1.FeatureHelm, + configv1beta1.Feature{ + FeatureID: configv1beta1.FeatureHelm, Charts: charts, }) @@ -58,10 +58,10 @@ func addDeployedHelmCharts(clusterConfiguration *configv1alpha1.ClusterConfigura } } - cfr := &configv1alpha1.ClusterProfileResource{ + cfr := &configv1beta1.ClusterProfileResource{ ClusterProfileName: clusterProfileName, - Features: []configv1alpha1.Feature{ - {FeatureID: configv1alpha1.FeatureHelm, Charts: charts}, + Features: []configv1beta1.Feature{ + {FeatureID: configv1beta1.FeatureHelm, Charts: charts}, }, } clusterConfiguration.Status.ClusterProfileResources = append(clusterConfiguration.Status.ClusterProfileResources, *cfr) @@ -70,22 +70,22 @@ func addDeployedHelmCharts(clusterConfiguration *configv1alpha1.ClusterConfigura } // addDeployedResources adds provided resources as deployed in clusterConfiguration status -func addDeployedResources(clusterConfiguration *configv1alpha1.ClusterConfiguration, - clusterProfileName string, resources []configv1alpha1.Resource) *configv1alpha1.ClusterConfiguration { +func addDeployedResources(clusterConfiguration *configv1beta1.ClusterConfiguration, + clusterProfileName string, resources []configv1beta1.Resource) *configv1beta1.ClusterConfiguration { if clusterConfiguration.Status.ClusterProfileResources == nil { - clusterConfiguration.Status.ClusterProfileResources = make([]configv1alpha1.ClusterProfileResource, 0) + clusterConfiguration.Status.ClusterProfileResources = make([]configv1beta1.ClusterProfileResource, 0) } for i := range clusterConfiguration.Status.ClusterProfileResources { cfr := &clusterConfiguration.Status.ClusterProfileResources[i] if cfr.ClusterProfileName == clusterProfileName { if cfr.Features == nil { - cfr.Features = make([]configv1alpha1.Feature, 0) + cfr.Features = make([]configv1beta1.Feature, 0) } cfr.Features = append(cfr.Features, - configv1alpha1.Feature{ - FeatureID: configv1alpha1.FeatureResources, + configv1beta1.Feature{ + FeatureID: configv1beta1.FeatureResources, Resources: resources, }) @@ -93,10 +93,10 @@ func addDeployedResources(clusterConfiguration *configv1alpha1.ClusterConfigurat } } - cfr := &configv1alpha1.ClusterProfileResource{ + cfr := &configv1beta1.ClusterProfileResource{ ClusterProfileName: clusterProfileName, - Features: []configv1alpha1.Feature{ - {FeatureID: configv1alpha1.FeatureResources, Resources: resources}, + Features: []configv1beta1.Feature{ + {FeatureID: configv1beta1.FeatureResources, Resources: resources}, }, } clusterConfiguration.Status.ClusterProfileResources = append(clusterConfiguration.Status.ClusterProfileResources, *cfr) @@ -104,9 +104,9 @@ func addDeployedResources(clusterConfiguration *configv1alpha1.ClusterConfigurat return clusterConfiguration } -func generateChart() *configv1alpha1.Chart { +func generateChart() *configv1beta1.Chart { t := metav1.Time{Time: time.Now()} - return &configv1alpha1.Chart{ + return &configv1beta1.Chart{ RepoURL: randomString(), ReleaseName: randomString(), Namespace: randomString(), @@ -115,9 +115,9 @@ func generateChart() *configv1alpha1.Chart { } } -func generateResource() *configv1alpha1.Resource { +func generateResource() *configv1beta1.Resource { t := metav1.Time{Time: time.Now()} - return &configv1alpha1.Resource{ + return &configv1beta1.Resource{ Name: randomString(), Namespace: randomString(), Group: randomString(), @@ -126,8 +126,8 @@ func generateResource() *configv1alpha1.Resource { } } -func generateReleaseReport(action string) *configv1alpha1.ReleaseReport { - return &configv1alpha1.ReleaseReport{ +func generateReleaseReport(action string) *configv1beta1.ReleaseReport { + return &configv1beta1.ReleaseReport{ ReleaseName: randomString(), ReleaseNamespace: randomString(), ChartVersion: randomString(), @@ -135,9 +135,9 @@ func generateReleaseReport(action string) *configv1alpha1.ReleaseReport { } } -func generateResourceReport(action string) *configv1alpha1.ResourceReport { - return &configv1alpha1.ResourceReport{ - Resource: configv1alpha1.Resource{ +func generateResourceReport(action string) *configv1beta1.ResourceReport { + return &configv1beta1.ResourceReport{ + Resource: configv1beta1.Resource{ Name: randomString(), Namespace: randomString(), Group: randomString(), diff --git a/internal/commands/snapshot.go b/internal/commands/snapshot.go index 1c017f08..9b31d81a 100644 --- a/internal/commands/snapshot.go +++ b/internal/commands/snapshot.go @@ -76,7 +76,6 @@ See 'sveltosctl snapshot --help' to read about a specific subcomman select {} } else if opts[""] != nil { switch command { - //nolint: goconst // same command name case "list": err = snapshot.List(ctx, arguments, logger) case "diff": diff --git a/internal/commands/snapshot/diff.go b/internal/commands/snapshot/diff.go index e9209b4a..f7aaec76 100644 --- a/internal/commands/snapshot/diff.go +++ b/internal/commands/snapshot/diff.go @@ -38,10 +38,10 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2/textlogger" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -252,7 +252,7 @@ func listSnapshotDiffsBewteenSamples(fromFolder, toFolder, passedNamespace, pass // There is one ClusterConfigurations per Cluster snapshotClient := collector.GetClient() fromClusterConfigurationMap, err := snapshotClient.GetNamespacedResources(fromFolder, - configv1alpha1.ClusterConfigurationKind, logger) + configv1beta1.ClusterConfigurationKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect ClusterConfigurations from folder %s", fromFolder)) return err @@ -261,7 +261,7 @@ func listSnapshotDiffsBewteenSamples(fromFolder, toFolder, passedNamespace, pass len(fromClusterConfigurationMap), fromFolder)) toClusterConfigurationMap, err := snapshotClient.GetNamespacedResources(toFolder, - configv1alpha1.ClusterConfigurationKind, logger) + configv1beta1.ClusterConfigurationKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect ClusterConfigurations from folder %s", toFolder)) return err @@ -337,17 +337,17 @@ func listFeatureDiffInNamespace(fromFolder, toFolder, namespace string, } func getClusterConfigurationsInNamespace(namespace, passedCluster string, clusterConfigurationMap map[string][]*unstructured.Unstructured, - logger logr.Logger) ([]*configv1alpha1.ClusterConfiguration, error) { + logger logr.Logger) ([]*configv1beta1.ClusterConfiguration, error) { resources, ok := clusterConfigurationMap[namespace] if !ok { return nil, nil } - results := make([]*configv1alpha1.ClusterConfiguration, 0) + results := make([]*configv1beta1.ClusterConfiguration, 0) for i := range resources { resource := resources[i] - var clusterConfiguration configv1alpha1.ClusterConfiguration + var clusterConfiguration configv1beta1.ClusterConfiguration err := runtime.DefaultUnstructuredConverter. FromUnstructured(resource.UnstructuredContent(), &clusterConfiguration) if err != nil { @@ -362,17 +362,17 @@ func getClusterConfigurationsInNamespace(namespace, passedCluster string, cluste return results, nil } -func listDiffInClusterConfigurations(fromFolder, toFolder string, fromClusterConfigurations, toClusterConfigurations []*configv1alpha1.ClusterConfiguration, +func listDiffInClusterConfigurations(fromFolder, toFolder string, fromClusterConfigurations, toClusterConfigurations []*configv1beta1.ClusterConfiguration, rawDiff bool, table *tablewriter.Table, logger logr.Logger) error { // Create maps - fromClusterConfigurationMaps := make(map[string]*configv1alpha1.ClusterConfiguration) + fromClusterConfigurationMaps := make(map[string]*configv1beta1.ClusterConfiguration) for i := range fromClusterConfigurations { cc := fromClusterConfigurations[i] fromClusterConfigurationMaps[cc.Name] = cc } - toClusterConfigurationMaps := make(map[string]*configv1alpha1.ClusterConfiguration) + toClusterConfigurationMaps := make(map[string]*configv1beta1.ClusterConfiguration) for i := range toClusterConfigurations { cc := toClusterConfigurations[i] toClusterConfigurationMaps[cc.Name] = cc @@ -397,11 +397,11 @@ func listDiffInClusterConfigurations(fromFolder, toFolder string, fromClusterCon return nil } -func listClusterConfigurationDiff(fromFolder, toFolder string, fromClusterConfiguration, toClusterConfiguration *configv1alpha1.ClusterConfiguration, +func listClusterConfigurationDiff(fromFolder, toFolder string, fromClusterConfiguration, toClusterConfiguration *configv1beta1.ClusterConfiguration, rawDiff bool, table *tablewriter.Table, logger logr.Logger) error { - toCharts := make([]configv1alpha1.Chart, 0) - toResources := make([]configv1alpha1.Resource, 0) + toCharts := make([]configv1beta1.Chart, 0) + toResources := make([]configv1beta1.Resource, 0) if toClusterConfiguration != nil { for i := range toClusterConfiguration.Status.ClusterProfileResources { cpr := &toClusterConfiguration.Status.ClusterProfileResources[i] @@ -413,8 +413,8 @@ func listClusterConfigurationDiff(fromFolder, toFolder string, fromClusterConfig } } - fromCharts := make([]configv1alpha1.Chart, 0) - fromResources := make([]configv1alpha1.Resource, 0) + fromCharts := make([]configv1beta1.Chart, 0) + fromResources := make([]configv1beta1.Resource, 0) if fromClusterConfiguration != nil { for i := range fromClusterConfiguration.Status.ClusterProfileResources { cpr := &fromClusterConfiguration.Status.ClusterProfileResources[i] @@ -446,11 +446,11 @@ func listClusterConfigurationDiff(fromFolder, toFolder string, fromClusterConfig return nil } -func addChartEntry(fromClusterConfiguration, toClusterConfiguration *configv1alpha1.ClusterConfiguration, - charts []*configv1alpha1.Chart, action string, message map[configv1alpha1.Chart]string, table *tablewriter.Table) { +func addChartEntry(fromClusterConfiguration, toClusterConfiguration *configv1beta1.ClusterConfiguration, + charts []*configv1beta1.Chart, action string, message map[configv1beta1.Chart]string, table *tablewriter.Table) { instance := utils.GetAccessInstance() - clusterInfo := func(fromClusterConfiguration, toClusterConfiguration *configv1alpha1.ClusterConfiguration) string { + clusterInfo := func(fromClusterConfiguration, toClusterConfiguration *configv1beta1.ClusterConfiguration) string { if toClusterConfiguration != nil { clusterName := instance.GetClusterNameFromClusterConfiguration(toClusterConfiguration) return fmt.Sprintf("%s/%s", toClusterConfiguration.Namespace, clusterName) @@ -473,11 +473,11 @@ func addChartEntry(fromClusterConfiguration, toClusterConfiguration *configv1alp } } -func addResourceEntry(fromClusterConfiguration, toClusterConfiguration *configv1alpha1.ClusterConfiguration, - resources []*configv1alpha1.Resource, action, msg string, +func addResourceEntry(fromClusterConfiguration, toClusterConfiguration *configv1beta1.ClusterConfiguration, + resources []*configv1beta1.Resource, action, msg string, table *tablewriter.Table) { - clusterInfo := func(fromClusterConfiguration, toClusterConfiguration *configv1alpha1.ClusterConfiguration) string { + clusterInfo := func(fromClusterConfiguration, toClusterConfiguration *configv1beta1.ClusterConfiguration) string { if toClusterConfiguration != nil { return fmt.Sprintf("%s/%s", toClusterConfiguration.Namespace, toClusterConfiguration.Name) } @@ -494,22 +494,22 @@ func addResourceEntry(fromClusterConfiguration, toClusterConfiguration *configv1 } // chartDifference returns differences between from and to -func chartDifference(from, to []configv1alpha1.Chart) (added, modified, deleted []*configv1alpha1.Chart, - modifiedMessage map[configv1alpha1.Chart]string) { +func chartDifference(from, to []configv1beta1.Chart) (added, modified, deleted []*configv1beta1.Chart, + modifiedMessage map[configv1beta1.Chart]string) { - modifiedMessage = make(map[configv1alpha1.Chart]string) + modifiedMessage = make(map[configv1beta1.Chart]string) - chartInfo := func(chart *configv1alpha1.Chart) string { + chartInfo := func(chart *configv1beta1.Chart) string { return fmt.Sprintf("%s/%s", chart.Namespace, chart.ReleaseName) } - toChartMap := make(map[string]*configv1alpha1.Chart, len(to)) + toChartMap := make(map[string]*configv1beta1.Chart, len(to)) for i := range to { chart := &to[i] toChartMap[chartInfo(chart)] = chart } - fromChartMap := make(map[string]*configv1alpha1.Chart, len(from)) + fromChartMap := make(map[string]*configv1beta1.Chart, len(from)) for i := range from { chart := &from[i] fromChartMap[chartInfo(chart)] = chart @@ -538,28 +538,28 @@ func chartDifference(from, to []configv1alpha1.Chart) (added, modified, deleted } // resourceDifference returns differences between from and to -func resourceDifference(fromFolder, toFolder string, from, to []configv1alpha1.Resource, rawDiff bool, - logger logr.Logger) (added, modified, deleted []*configv1alpha1.Resource, err error) { +func resourceDifference(fromFolder, toFolder string, from, to []configv1beta1.Resource, rawDiff bool, + logger logr.Logger) (added, modified, deleted []*configv1beta1.Resource, err error) { - resourceInfo := func(resource *configv1alpha1.Resource) string { + resourceInfo := func(resource *configv1beta1.Resource) string { return fmt.Sprintf("%s:%s:%s/%s", resource.Group, resource.Kind, resource.Namespace, resource.Name) } - toResourceMap := make(map[string]*configv1alpha1.Resource, len(to)) + toResourceMap := make(map[string]*configv1beta1.Resource, len(to)) for i := range to { resource := &to[i] toResourceMap[resourceInfo(resource)] = resource } - fromResourceMap := make(map[string]*configv1alpha1.Resource, len(from)) + fromResourceMap := make(map[string]*configv1beta1.Resource, len(from)) for i := range from { resource := &from[i] fromResourceMap[resourceInfo(resource)] = resource } - var addedResources []*configv1alpha1.Resource - var deletedResources []*configv1alpha1.Resource - var modifiedResources []*configv1alpha1.Resource + var addedResources []*configv1beta1.Resource + var deletedResources []*configv1beta1.Resource + var modifiedResources []*configv1beta1.Resource for k := range toResourceMap { logger.V(logs.LogDebug).Info(fmt.Sprintf("analyzing resource %s/%s %s/%s", @@ -591,8 +591,8 @@ func resourceDifference(fromFolder, toFolder string, from, to []configv1alpha1.R return addedResources, modifiedResources, deletedResources, nil } -func appendChartsAndResourcesForClusterProfiles(cpr *configv1alpha1.ClusterProfileResource, charts []configv1alpha1.Chart, - resources []configv1alpha1.Resource) ([]configv1alpha1.Chart, []configv1alpha1.Resource) { +func appendChartsAndResourcesForClusterProfiles(cpr *configv1beta1.ClusterProfileResource, charts []configv1beta1.Chart, + resources []configv1beta1.Resource) ([]configv1beta1.Chart, []configv1beta1.Resource) { for i := range cpr.Features { for j := range cpr.Features[i].Charts { @@ -606,8 +606,8 @@ func appendChartsAndResourcesForClusterProfiles(cpr *configv1alpha1.ClusterProfi return charts, resources } -func appendChartsAndResourcesForProfiles(pr *configv1alpha1.ProfileResource, charts []configv1alpha1.Chart, - resources []configv1alpha1.Resource) ([]configv1alpha1.Chart, []configv1alpha1.Resource) { +func appendChartsAndResourcesForProfiles(pr *configv1beta1.ProfileResource, charts []configv1beta1.Chart, + resources []configv1beta1.Resource) ([]configv1beta1.Chart, []configv1beta1.Resource) { for i := range pr.Features { for j := range pr.Features[i].Charts { @@ -622,7 +622,7 @@ func appendChartsAndResourcesForProfiles(pr *configv1alpha1.ProfileResource, cha } // hasDiff returns true if any diff exist -func hasDiff(fromFolder, toFolder string, from, to *configv1alpha1.Resource, rawDiff bool) (bool, error) { +func hasDiff(fromFolder, toFolder string, from, to *configv1beta1.Resource, rawDiff bool) (bool, error) { fromResource, err := getResourceFromResourceOwner(fromFolder, from) if err != nil { return false, err @@ -692,7 +692,7 @@ func hasResourceDiff(from, to *unstructured.Unstructured, rawDiff bool, logger l return false, nil } -func getResourceFromResourceOwner(folder string, resource *configv1alpha1.Resource) (string, error) { +func getResourceFromResourceOwner(folder string, resource *configv1beta1.Resource) (string, error) { ownerPath := buildOwnerPath(folder, resource) owner, err := getResourceOwner(ownerPath) @@ -745,7 +745,7 @@ func getResourceFromResourceOwner(folder string, resource *configv1alpha1.Resour resource.Kind, resource.Namespace, resource.Name, ownerPath) } -func buildOwnerPath(folder string, resource *configv1alpha1.Resource) string { +func buildOwnerPath(folder string, resource *configv1beta1.Resource) string { return filepath.Join(folder, resource.Owner.Namespace, resource.Owner.Kind, diff --git a/internal/commands/snapshot/diff_test.go b/internal/commands/snapshot/diff_test.go index 7bedfc95..e949a7b3 100644 --- a/internal/commands/snapshot/diff_test.go +++ b/internal/commands/snapshot/diff_test.go @@ -39,7 +39,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/collector" @@ -179,14 +179,10 @@ var _ = Describe("Snapshot Diff", func() { ObjectMeta: metav1.ObjectMeta{ Name: classifierName, }, - Spec: libsveltosv1beta1.RoleRequestSpec{ + Spec: libsveltosv1alpha1.RoleRequestSpec{ ServiceAccountNamespace: randomString(), ServiceAccountName: randomString(), - ClusterSelector: libsveltosv1beta1.Selector{ - LabelSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{"zone": "west"}, - }, - }, + ClusterSelector: libsveltosv1alpha1.Selector("zone:west"), }, } Expect(addTypeInformationToObject(roleRequest)).To(Succeed()) @@ -246,7 +242,7 @@ var _ = Describe("Snapshot Diff", func() { fromFolder := filepath.Join(*artifactFolder, timeOne) toFolder := filepath.Join(*artifactFolder, timeTwo) - err = snapshot.ListDiff(fromFolder, toFolder, libsveltosv1beta1.ClassifierKind, false, + err = snapshot.ListDiff(fromFolder, toFolder, libsveltosv1alpha1.ClassifierKind, false, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) @@ -290,7 +286,7 @@ var _ = Describe("Snapshot Diff", func() { r, w, _ = os.Pipe() os.Stdout = w - err = snapshot.ListDiff(fromFolder, toFolder, libsveltosv1beta1.RoleRequestKind, false, + err = snapshot.ListDiff(fromFolder, toFolder, libsveltosv1alpha1.RoleRequestKind, false, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) @@ -325,7 +321,7 @@ var _ = Describe("Snapshot Diff", func() { It("listFeaturesDiffInCluster list differences in collected ClusterConfigurations", func() { newClusterConfiguration := generateClusterConfiguration() - oldClusterConfiguration := &configv1alpha1.ClusterConfiguration{ + oldClusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: newClusterConfiguration.Name, Namespace: newClusterConfiguration.Namespace, @@ -333,8 +329,8 @@ var _ = Describe("Snapshot Diff", func() { } table := tablewriter.NewWriter(os.Stdout) Expect(snapshot.ListDiffInClusterConfigurations("", "", - []*configv1alpha1.ClusterConfiguration{oldClusterConfiguration}, - []*configv1alpha1.ClusterConfiguration{newClusterConfiguration}, + []*configv1beta1.ClusterConfiguration{oldClusterConfiguration}, + []*configv1beta1.ClusterConfiguration{newClusterConfiguration}, false, table, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))))).To(Succeed()) result := fmt.Sprintf("table: %v\n", table) @@ -346,12 +342,12 @@ var _ = Describe("Snapshot Diff", func() { It("listClusterConfigurationDiff list differences between two ClusterConfigurations", func() { newClusterConfiguration := generateClusterConfiguration() newClusterConfiguration.Status.ClusterProfileResources = - []configv1alpha1.ClusterProfileResource{ + []configv1beta1.ClusterProfileResource{ *generateClusterProfileResource(), *generateClusterProfileResource(), } - oldClusterConfiguration := &configv1alpha1.ClusterConfiguration{ + oldClusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: newClusterConfiguration.Name, Namespace: newClusterConfiguration.Namespace, @@ -369,8 +365,8 @@ var _ = Describe("Snapshot Diff", func() { }) It("chartDifference lists added and deleted charts between two slices of charts", func() { - oldCharts := []configv1alpha1.Chart{*generateChart()} - newCharts := []configv1alpha1.Chart{*generateChart()} + oldCharts := []configv1beta1.Chart{*generateChart()} + newCharts := []configv1beta1.Chart{*generateChart()} added, modified, deleted, message := snapshot.ChartDifference(oldCharts, newCharts) Expect(len(added)).To(Equal(1)) @@ -381,10 +377,10 @@ var _ = Describe("Snapshot Diff", func() { It("chartDifference lists modifed charts between two slices of charts", func() { chart := generateChart() - oldCharts := []configv1alpha1.Chart{*chart} + oldCharts := []configv1beta1.Chart{*chart} newChart := *chart newChart.ChartVersion = randomString() - newCharts := []configv1alpha1.Chart{newChart} + newCharts := []configv1beta1.Chart{newChart} added, modified, deleted, message := snapshot.ChartDifference(oldCharts, newCharts) Expect(len(added)).To(Equal(0)) @@ -397,8 +393,8 @@ var _ = Describe("Snapshot Diff", func() { }) It("resourceDifference lists added and delete resources between two slices of resources", func() { - oldResources := []configv1alpha1.Resource{*generateResource()} - newResources := []configv1alpha1.Resource{*generateResource(), *generateResource()} + oldResources := []configv1beta1.Resource{*generateResource()} + newResources := []configv1beta1.Resource{*generateResource(), *generateResource()} added, modified, deleted, err := snapshot.ResourceDifference("", "", oldResources, newResources, false, @@ -437,7 +433,7 @@ var _ = Describe("Snapshot Diff", func() { Expect(collectorClient.DumpObject(newConfigMap, newFolder, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))))).To(Succeed()) - oldResource := &configv1alpha1.Resource{ + oldResource := &configv1beta1.Resource{ Kind: "ClusterRole", Name: clusterRole.GetName(), LastAppliedTime: &metav1.Time{Time: time.Now()}, @@ -452,8 +448,8 @@ var _ = Describe("Snapshot Diff", func() { newResource.LastAppliedTime = &metav1.Time{Time: time.Now().Add(time.Second * time.Duration(2))} added, modified, deleted, err := - snapshot.ResourceDifference(oldFolder, newFolder, []configv1alpha1.Resource{*oldResource}, - []configv1alpha1.Resource{newResource}, false, + snapshot.ResourceDifference(oldFolder, newFolder, []configv1beta1.Resource{*oldResource}, + []configv1beta1.Resource{newResource}, false, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) Expect(err).To(BeNil()) Expect(len(added)).To(Equal(0)) @@ -462,14 +458,14 @@ var _ = Describe("Snapshot Diff", func() { }) It("addChartEntry adds chart entries to table", func() { - clusterConfiguration := &configv1alpha1.ClusterConfiguration{ + clusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, } - charts := make([]*configv1alpha1.Chart, 0) + charts := make([]*configv1beta1.Chart, 0) charts = append(charts, generateChart()) charts = append(charts, generateChart()) @@ -485,14 +481,14 @@ var _ = Describe("Snapshot Diff", func() { }) It("addResourceEntry adds resource entries to table", func() { - clusterConfiguration := &configv1alpha1.ClusterConfiguration{ + clusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, } - resources := make([]*configv1alpha1.Resource, 0) + resources := make([]*configv1beta1.Resource, 0) resources = append(resources, generateResource()) resources = append(resources, generateResource()) @@ -525,8 +521,8 @@ var _ = Describe("Snapshot Diff", func() { Expect(chartNumber).ToNot(BeZero()) Expect(resourceNumber).ToNot(BeZero()) - charts := make([]configv1alpha1.Chart, 0) - resources := make([]configv1alpha1.Resource, 0) + charts := make([]configv1beta1.Chart, 0) + resources := make([]configv1beta1.Resource, 0) charts, resources = snapshot.AppendChartsAndResourcesForClusterProfiles(cpr, charts, resources) Expect(len(charts)).To(Equal(chartNumber)) @@ -557,7 +553,7 @@ var _ = Describe("Snapshot Diff", func() { clusterRoleGroup := "rbac.authorization.k8s.io/v1" clusterRoleKind := "ClusterRole" - resource := &configv1alpha1.Resource{ + resource := &configv1beta1.Resource{ Name: clusterRole.Name, Group: clusterRoleGroup, Kind: clusterRoleKind, @@ -576,9 +572,9 @@ var _ = Describe("Snapshot Diff", func() { }) }) -func generateChart() *configv1alpha1.Chart { +func generateChart() *configv1beta1.Chart { t := metav1.Time{Time: time.Now()} - return &configv1alpha1.Chart{ + return &configv1beta1.Chart{ RepoURL: randomString(), ReleaseName: randomString(), Namespace: randomString(), @@ -587,9 +583,9 @@ func generateChart() *configv1alpha1.Chart { } } -func generateResource() *configv1alpha1.Resource { +func generateResource() *configv1beta1.Resource { t := metav1.Time{Time: time.Now()} - return &configv1alpha1.Resource{ + return &configv1beta1.Resource{ Name: randomString(), Namespace: randomString(), Group: randomString(), @@ -603,36 +599,36 @@ func generateResource() *configv1alpha1.Resource { } } -func generateClusterConfiguration() *configv1alpha1.ClusterConfiguration { - return &configv1alpha1.ClusterConfiguration{ +func generateClusterConfiguration() *configv1beta1.ClusterConfiguration { + return &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Status: configv1alpha1.ClusterConfigurationStatus{ - ClusterProfileResources: []configv1alpha1.ClusterProfileResource{ + Status: configv1beta1.ClusterConfigurationStatus{ + ClusterProfileResources: []configv1beta1.ClusterProfileResource{ *generateClusterProfileResource(), }, - ProfileResources: []configv1alpha1.ProfileResource{ + ProfileResources: []configv1beta1.ProfileResource{ *generateProfileResource(), }, }, } } -func generateClusterProfileResource() *configv1alpha1.ClusterProfileResource { - return &configv1alpha1.ClusterProfileResource{ +func generateClusterProfileResource() *configv1beta1.ClusterProfileResource { + return &configv1beta1.ClusterProfileResource{ ClusterProfileName: randomString(), - Features: []configv1alpha1.Feature{ + Features: []configv1beta1.Feature{ { - FeatureID: configv1alpha1.FeatureHelm, - Charts: []configv1alpha1.Chart{ + FeatureID: configv1beta1.FeatureHelm, + Charts: []configv1beta1.Chart{ *generateChart(), *generateChart(), }, }, { - FeatureID: configv1alpha1.FeatureResources, - Resources: []configv1alpha1.Resource{ + FeatureID: configv1beta1.FeatureResources, + Resources: []configv1beta1.Resource{ *generateResource(), *generateResource(), }, }, @@ -640,19 +636,19 @@ func generateClusterProfileResource() *configv1alpha1.ClusterProfileResource { } } -func generateProfileResource() *configv1alpha1.ProfileResource { - return &configv1alpha1.ProfileResource{ +func generateProfileResource() *configv1beta1.ProfileResource { + return &configv1beta1.ProfileResource{ ProfileName: randomString(), - Features: []configv1alpha1.Feature{ + Features: []configv1beta1.Feature{ { - FeatureID: configv1alpha1.FeatureHelm, - Charts: []configv1alpha1.Chart{ + FeatureID: configv1beta1.FeatureHelm, + Charts: []configv1beta1.Chart{ *generateChart(), *generateChart(), }, }, { - FeatureID: configv1alpha1.FeatureResources, - Resources: []configv1alpha1.Resource{ + FeatureID: configv1beta1.FeatureResources, + Resources: []configv1beta1.Resource{ *generateResource(), *generateResource(), }, }, @@ -660,7 +656,7 @@ func generateProfileResource() *configv1alpha1.ProfileResource { } } -func verifyChartAndResources(result string, cpr configv1alpha1.ClusterProfileResource) { +func verifyChartAndResources(result string, cpr configv1beta1.ClusterProfileResource) { for i := range cpr.Features { if cpr.Features[i].Charts != nil { verifyCharts(result, cpr.Features[i].Charts) @@ -671,13 +667,13 @@ func verifyChartAndResources(result string, cpr configv1alpha1.ClusterProfileRes } } -func verifyCharts(result string, charts []configv1alpha1.Chart) { +func verifyCharts(result string, charts []configv1beta1.Chart) { for i := range charts { verifyChart(result, &charts[i]) } } -func verifyChart(result string, chart *configv1alpha1.Chart) { +func verifyChart(result string, chart *configv1beta1.Chart) { found := false lines := strings.Split(result, "\n") for i := range lines { @@ -692,13 +688,13 @@ func verifyChart(result string, chart *configv1alpha1.Chart) { Expect(found).To(BeTrue()) } -func verifyResources(result string, resources []configv1alpha1.Resource) { +func verifyResources(result string, resources []configv1beta1.Resource) { for i := range resources { verifyResource(result, &resources[i]) } } -func verifyResource(result string, resources *configv1alpha1.Resource) { +func verifyResource(result string, resources *configv1beta1.Resource) { found := false lines := strings.Split(result, "\n") for i := range lines { diff --git a/internal/commands/snapshot/list_test.go b/internal/commands/snapshot/list_test.go index ed02d180..15a278a8 100644 --- a/internal/commands/snapshot/list_test.go +++ b/internal/commands/snapshot/list_test.go @@ -32,7 +32,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/commands/snapshot" "github.com/projectsveltos/sveltosctl/internal/utils" diff --git a/internal/commands/snapshot/rollback.go b/internal/commands/snapshot/rollback.go index 82e1eb8e..97e52cce 100644 --- a/internal/commands/snapshot/rollback.go +++ b/internal/commands/snapshot/rollback.go @@ -34,10 +34,10 @@ import ( "k8s.io/klog/v2/textlogger" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -200,7 +200,7 @@ func getAndRollbackCAPIClusters(ctx context.Context, folder, passedNamespace, pa func getAndRollbackSveltosClusters(ctx context.Context, folder, passedNamespace, passedCluster string, logger logr.Logger) error { snapshotClient := collector.GetClient() - clusterMap, err := snapshotClient.GetNamespacedResources(folder, libsveltosv1beta1.SveltosClusterKind, logger) + clusterMap, err := snapshotClient.GetNamespacedResources(folder, libsveltosv1alpha1.SveltosClusterKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect SveltosCluster from folder %s", folder)) return err @@ -221,7 +221,7 @@ func getAndRollbackSveltosClusters(ctx context.Context, folder, passedNamespace, func getAndRollbackProfiles(ctx context.Context, folder, passedNamespace, passedProfile string, logger logr.Logger) error { snapshotClient := collector.GetClient() - clusterProfiles, err := snapshotClient.GetClusterResources(folder, configv1alpha1.ClusterProfileKind, logger) + clusterProfiles, err := snapshotClient.GetClusterResources(folder, configv1beta1.ClusterProfileKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect ClusterProfile from folder %s", folder)) return err @@ -238,7 +238,7 @@ func getAndRollbackProfiles(ctx context.Context, folder, passedNamespace, passed } } - profiles, err := snapshotClient.GetNamespacedResources(folder, configv1alpha1.ProfileKind, logger) + profiles, err := snapshotClient.GetNamespacedResources(folder, configv1beta1.ProfileKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect Profile from folder %s", folder)) return err @@ -276,7 +276,7 @@ func rollbackProfiles(ctx context.Context, resources []*unstructured.Unstructure func getAndRollbackClassifiers(ctx context.Context, folder, passedClassifier string, logger logr.Logger) error { snapshotClient := collector.GetClient() - classifiers, err := snapshotClient.GetClusterResources(folder, libsveltosv1beta1.ClassifierKind, logger) + classifiers, err := snapshotClient.GetClusterResources(folder, libsveltosv1alpha1.ClassifierKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect Classifiers from folder %s", folder)) return err @@ -298,7 +298,7 @@ func getAndRollbackClassifiers(ctx context.Context, folder, passedClassifier str func getAndRollbackRoleRequests(ctx context.Context, folder, passedRoleRequest string, logger logr.Logger) error { snapshotClient := collector.GetClient() - roleRequests, err := snapshotClient.GetClusterResources(folder, libsveltosv1beta1.RoleRequestKind, logger) + roleRequests, err := snapshotClient.GetClusterResources(folder, libsveltosv1alpha1.RoleRequestKind, logger) if err != nil { logger.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect RoleRequests from folder %s", folder)) return err @@ -502,7 +502,7 @@ func rollbackSveltosCluster(ctx context.Context, resource *unstructured.Unstruct func rollbackClusterProfile(ctx context.Context, resource *unstructured.Unstructured, logger logr.Logger) error { instance := utils.GetAccessInstance() - currentClusterProfile := &configv1alpha1.ClusterProfile{} + currentClusterProfile := &configv1beta1.ClusterProfile{} err := instance.GetResource(ctx, types.NamespacedName{Name: resource.GetName()}, currentClusterProfile) if err != nil { @@ -514,7 +514,7 @@ func rollbackClusterProfile(ctx context.Context, resource *unstructured.Unstruct return err } - passedClusterProfile := &configv1alpha1.ClusterProfile{} + passedClusterProfile := &configv1beta1.ClusterProfile{} err = runtime.DefaultUnstructuredConverter. FromUnstructured(resource.UnstructuredContent(), passedClusterProfile) if err != nil { @@ -534,7 +534,7 @@ func rollbackClusterProfile(ctx context.Context, resource *unstructured.Unstruct func rollbackProfile(ctx context.Context, resource *unstructured.Unstructured, logger logr.Logger) error { instance := utils.GetAccessInstance() - currentProfile := &configv1alpha1.Profile{} + currentProfile := &configv1beta1.Profile{} err := instance.GetResource(ctx, types.NamespacedName{Namespace: resource.GetNamespace(), Name: resource.GetName()}, currentProfile) @@ -547,7 +547,7 @@ func rollbackProfile(ctx context.Context, resource *unstructured.Unstructured, l return err } - passedProfile := &configv1alpha1.Profile{} + passedProfile := &configv1beta1.Profile{} err = runtime.DefaultUnstructuredConverter. FromUnstructured(resource.UnstructuredContent(), passedProfile) if err != nil { diff --git a/internal/commands/snapshot/rollback_test.go b/internal/commands/snapshot/rollback_test.go index 00a9b8ec..6893640b 100644 --- a/internal/commands/snapshot/rollback_test.go +++ b/internal/commands/snapshot/rollback_test.go @@ -35,7 +35,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/commands/snapshot" @@ -231,7 +231,7 @@ var _ = Describe("Snapshot Rollback", func() { instance := utils.GetAccessInstance() - currentCP := &configv1alpha1.ClusterProfile{} + currentCP := &configv1beta1.ClusterProfile{} Expect(instance.GetResource(context.TODO(), types.NamespacedName{Name: name}, currentCP)).To(Succeed()) @@ -277,7 +277,7 @@ var _ = Describe("Snapshot Rollback", func() { // Rollback Expect(snapshot.RollbackClusters(context.TODO(), []*unstructured.Unstructured{cluster}, "", - libsveltosv1beta1.ClusterTypeCapi, + libsveltosv1alpha1.ClusterTypeCapi, textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))))).To(Succeed()) Expect(instance.GetResource(context.TODO(), @@ -334,7 +334,7 @@ var _ = Describe("Snapshot Rollback", func() { originalClusterLabels[k] = currentCluster.Labels[k] } - currentClusterProfile := &configv1alpha1.ClusterProfile{} + currentClusterProfile := &configv1beta1.ClusterProfile{} Expect(instance.GetResource(context.TODO(), types.NamespacedName{Name: name}, currentClusterProfile)).To(Succeed()) @@ -415,7 +415,7 @@ var _ = Describe("Snapshot Rollback", func() { Expect(snapshot.GetAndRollbackProfiles(context.TODO(), folder, "", "", textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))))).To(Succeed()) - currentClusterProfile := &configv1alpha1.ClusterProfile{} + currentClusterProfile := &configv1beta1.ClusterProfile{} Expect(c.Get(context.TODO(), types.NamespacedName{Name: name}, currentClusterProfile)).To(Succeed()) }) @@ -488,10 +488,10 @@ func updateClusterLabels(currentCluster *clusterv1.Cluster) { Expect(instance.UpdateResource(context.TODO(), currentCluster)).To(Succeed()) } -func updateClusterProfileSpec(currentClusterProfile *configv1alpha1.ClusterProfile) { +func updateClusterProfileSpec(currentClusterProfile *configv1beta1.ClusterProfile) { instance := utils.GetAccessInstance() - currentClusterProfile.Spec.SyncMode = configv1alpha1.SyncModeDryRun + currentClusterProfile.Spec.SyncMode = configv1beta1.SyncModeDryRun currentClusterProfile.Spec.HelmCharts = nil Expect(instance.UpdateResource(context.TODO(), currentClusterProfile)).To(Succeed()) } diff --git a/internal/commands/snapshot_reconciler.go b/internal/commands/snapshot_reconciler.go index 1f49c570..4287dc88 100644 --- a/internal/commands/snapshot_reconciler.go +++ b/internal/commands/snapshot_reconciler.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -49,17 +49,17 @@ func SnapshotReconciler(ctx context.Context, req reconcile.Request) (reconcile.R if !snapshotInstance.DeletionTimestamp.IsZero() { return reconcileDelete(ctx, snapshotInstance, collector.Snapshot, snapshotInstance.Spec.Storage, - utilsv1beta1.SnapshotFinalizer, logger) + utilsv1alpha1.SnapshotFinalizer, logger) } return reconcileSnapshotNormal(ctx, snapshotInstance, logger) } -func reconcileSnapshotNormal(ctx context.Context, snapshotInstance *utilsv1beta1.Snapshot, +func reconcileSnapshotNormal(ctx context.Context, snapshotInstance *utilsv1alpha1.Snapshot, logger logr.Logger) (reconcile.Result, error) { logger.V(logs.LogInfo).Info("reconcileSnapshotNormal") - if err := addFinalizer(ctx, snapshotInstance, utilsv1beta1.SnapshotFinalizer); err != nil { + if err := addFinalizer(ctx, snapshotInstance, utilsv1alpha1.SnapshotFinalizer); err != nil { logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to add finalizer: %s", err)) return reconcile.Result{}, err } diff --git a/internal/commands/snapshot_reconciler_utils.go b/internal/commands/snapshot_reconciler_utils.go index 668167e9..b61278e2 100644 --- a/internal/commands/snapshot_reconciler_utils.go +++ b/internal/commands/snapshot_reconciler_utils.go @@ -30,16 +30,16 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/collector" "github.com/projectsveltos/sveltosctl/internal/utils" ) type collectionSnapshot struct { - snapshotInstance *utilsv1beta1.Snapshot + snapshotInstance *utilsv1alpha1.Snapshot } func (c *collectionSnapshot) getCreationTimestamp() *metav1.Time { @@ -70,7 +70,7 @@ func (c *collectionSnapshot) getStartingDeadlineSeconds() *int64 { return c.snapshotInstance.Spec.StartingDeadlineSeconds } -func (c *collectionSnapshot) setLastRunStatus(s utilsv1beta1.CollectionStatus) { +func (c *collectionSnapshot) setLastRunStatus(s utilsv1alpha1.CollectionStatus) { c.snapshotInstance.Status.LastRunStatus = &s } @@ -83,7 +83,7 @@ func collectSnapshot(ctx context.Context, c client.Client, snapshotName string, logger.V(logs.LogInfo).Info("collect snapshot") // Get Snapshot instance - snapshotInstance := &utilsv1beta1.Snapshot{} + snapshotInstance := &utilsv1alpha1.Snapshot{} err := c.Get(ctx, types.NamespacedName{Name: snapshotName}, snapshotInstance) if err != nil { if apierrors.IsNotFound(err) { @@ -317,13 +317,13 @@ func dumpProfiles(collectorClient *collector.Collector, ctx context.Context, fol } func dumpReferencedObjects(collectorClient *collector.Collector, ctx context.Context, - referencedObjects []libsveltosv1beta1.PolicyRef, folder string, logger logr.Logger) error { + referencedObjects []libsveltosv1alpha1.PolicyRef, folder string, logger logr.Logger) error { logger.V(logs.LogDebug).Info("storing ClusterProfiles's referenced resources") var object client.Object for i := range referencedObjects { ref := &referencedObjects[i] - if ref.Kind == string(libsveltosv1beta1.ConfigMapReferencedResourceKind) { + if ref.Kind == string(libsveltosv1alpha1.ConfigMapReferencedResourceKind) { configMap := &corev1.ConfigMap{} err := utils.GetAccessInstance().GetResource(ctx, types.NamespacedName{Namespace: ref.Namespace, Name: ref.Name}, configMap) @@ -397,7 +397,7 @@ func dumpCAPIClusters(collectorClient *collector.Collector, ctx context.Context, func dumpSveltosClusters(collectorClient *collector.Collector, ctx context.Context, folder string, logger logr.Logger) error { logger.V(logs.LogDebug).Info("storing Sveltos Clusters") - clusterList := &libsveltosv1beta1.SveltosClusterList{} + clusterList := &libsveltosv1alpha1.SveltosClusterList{} err := utils.GetAccessInstance().ListResources(ctx, clusterList) if err != nil { return err @@ -426,7 +426,7 @@ func dumpClusters(collectorClient *collector.Collector, ctx context.Context, fol return nil } -func updateSnaphotPredicate(newObject, oldObject *utilsv1beta1.Snapshot) bool { +func updateSnaphotPredicate(newObject, oldObject *utilsv1alpha1.Snapshot) bool { if oldObject == nil || !reflect.DeepEqual(newObject.Spec, oldObject.Spec) { @@ -436,11 +436,11 @@ func updateSnaphotPredicate(newObject, oldObject *utilsv1beta1.Snapshot) bool { return false } -func convertConfigPolicyRefsToLibsveltosPolicyRefs(input []configv1alpha1.PolicyRef) []libsveltosv1beta1.PolicyRef { +func convertConfigPolicyRefsToLibsveltosPolicyRefs(input []configv1beta1.PolicyRef) []libsveltosv1beta1.PolicyRef { policyRefs := make([]libsveltosv1beta1.PolicyRef, len(input)) for i := range input { - policyRefs[i] = libsveltosv1beta1.PolicyRef{ + policyRefs[i] = libsveltosv1alpha1.PolicyRef{ Kind: input[i].Kind, Namespace: input[i].Namespace, Name: input[i].Name, diff --git a/internal/commands/techsupport.go b/internal/commands/techsupport.go deleted file mode 100644 index c384bca9..00000000 --- a/internal/commands/techsupport.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package commands - -import ( - "context" - "errors" - "fmt" - "os" - "strings" - - docopt "github.com/docopt/docopt-go" - "github.com/go-logr/logr" - - logs "github.com/projectsveltos/libsveltos/lib/logsettings" - "github.com/projectsveltos/sveltosctl/internal/commands/techsupport" -) - -// Techsupport takes keyword then calls subcommand. -func Techsupport(ctx context.Context, args []string, logger logr.Logger) error { - doc := `Usage: - sveltosctl techsupport [options] [...] - - list Displays all available collected techsupports. - -Options: - -h --help Show this screen. - -Description: -See 'sveltosctl techsupport --help' to read about a specific subcommand. -` - - parser := &docopt.Parser{ - HelpHandler: docopt.PrintHelpAndExit, - OptionsFirst: true, - SkipHelpFlags: false, - } - - opts, err := parser.ParseArgs(doc, nil, "1.0") - if err != nil { - var userError docopt.UserError - if errors.As(err, &userError) { - logger.V(logs.LogInfo).Info(fmt.Sprintf( - "Invalid option: 'sveltosctl %s'. Use flag '--help' to read about a specific subcommand.\n", - strings.Join(os.Args[1:], " "), - )) - } - os.Exit(1) - } - - command := opts[""].(string) - arguments := append([]string{"techsupport", command}, opts[""].([]string)...) - - if opts[""] != nil { - switch command { - case "list": - err = techsupport.List(ctx, arguments, logger) - default: - //nolint: forbidigo // print doc - fmt.Println(doc) - } - - return err - } - return nil -} diff --git a/internal/commands/techsupport/export_test.go b/internal/commands/techsupport/export_test.go deleted file mode 100644 index 4d3a9fc8..00000000 --- a/internal/commands/techsupport/export_test.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package techsupport - -var ( - ListTechsupports = listTechsupports -) diff --git a/internal/commands/techsupport/list.go b/internal/commands/techsupport/list.go deleted file mode 100644 index a2c1be50..00000000 --- a/internal/commands/techsupport/list.go +++ /dev/null @@ -1,148 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package techsupport - -import ( - "context" - "flag" - "fmt" - "os" - "strings" - - "github.com/docopt/docopt-go" - "github.com/go-logr/logr" - "github.com/olekukonko/tablewriter" - - logs "github.com/projectsveltos/libsveltos/lib/logsettings" - "github.com/projectsveltos/sveltosctl/internal/collector" - "github.com/projectsveltos/sveltosctl/internal/utils" - - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" -) - -var ( - // techsupportName is the name of the techsupport instance which caused a techsupport to be collected - // techsupportDate is a string containing the Date a techsupport was taken - genListTechsupportRow = func(techsupportName, techsupportDate string, - ) []string { - return []string{ - techsupportName, - techsupportDate, - } - } -) - -func doConsiderTechsupport(techsupportInstance *utilsv1beta1.Techsupport, passedTechsupport string) bool { - if passedTechsupport == "" { - return true - } - - return techsupportInstance.Name == passedTechsupport -} - -func listTechsupports(ctx context.Context, passedTechsupportName string, logger logr.Logger) error { - table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"TECHSUPPORT POLICY", "DATE"}) - - if err := displayTechsupports(ctx, passedTechsupportName, table, logger); err != nil { - return err - } - - table.Render() - - return nil -} - -func displayTechsupports(ctx context.Context, passedTechsupportName string, - table *tablewriter.Table, logger logr.Logger) error { - - techsupportList := &utilsv1beta1.TechsupportList{} - logger.V(logs.LogDebug).Info("List all Techsupport instances") - instance := utils.GetAccessInstance() - err := instance.ListResources(ctx, techsupportList) - if err != nil { - return err - } - for i := range techsupportList.Items { - if doConsiderTechsupport(&techsupportList.Items[i], passedTechsupportName) { - err = displayTechsupport(&techsupportList.Items[i], table, logger) - if err != nil { - return nil - } - } - } - - return nil -} - -func displayTechsupport(techsupportInstance *utilsv1beta1.Techsupport, - table *tablewriter.Table, logger logr.Logger) error { - - logger.V(logs.LogDebug).Info(fmt.Sprintf("Considering Techsupport instance %s", techsupportInstance.Name)) - techsupportClient := collector.GetClient() - results, err := techsupportClient.ListCollections(techsupportInstance.Spec.Storage, techsupportInstance.Name, - collector.Techsupport, logger) - if err != nil { - return err - } - for i := range results { - table.Append(genListTechsupportRow(techsupportInstance.Name, results[i])) - } - return nil -} - -// List collects techsupport -func List(ctx context.Context, args []string, logger logr.Logger) error { - doc := `Usage: - sveltosctl techsupport list [options] [--techsupport=] [--verbose] - - --techsupport= List techsupports taken because of Techsupport instance with that name - -Options: - -h --help Show this screen. - --verbose Verbose mode. Print each step. - -Description: - The techsupport list command lists all techsupports taken. -` - - parsedArgs, err := docopt.ParseArgs(doc, nil, "1.0") - if err != nil { - logger.V(logs.LogInfo).Error(err, "failed to parse args") - return fmt.Errorf( - "invalid option: 'sveltosctl %s'. Use flag '--help' to read about a specific subcommand. Error: %w", - strings.Join(args, " "), - err, - ) - } - - _ = flag.Lookup("v").Value.Set(fmt.Sprint(logs.LogInfo)) - verbose := parsedArgs["--verbose"].(bool) - if verbose { - err = flag.Lookup("v").Value.Set(fmt.Sprint(logs.LogDebug)) - if err != nil { - return err - } - } - - snapshostName := "" - if passedTechsupportName := parsedArgs["--techsupport"]; passedTechsupportName != nil { - snapshostName = passedTechsupportName.(string) - } - - return listTechsupports(ctx, snapshostName, logger) -} diff --git a/internal/commands/techsupport/list_test.go b/internal/commands/techsupport/list_test.go deleted file mode 100644 index 4aafe99c..00000000 --- a/internal/commands/techsupport/list_test.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package techsupport_test - -import ( - "bytes" - "context" - "fmt" - "io" - "os" - "strings" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/klog/v2/textlogger" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" - - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" - "github.com/projectsveltos/sveltosctl/internal/collector" - "github.com/projectsveltos/sveltosctl/internal/commands/techsupport" - "github.com/projectsveltos/sveltosctl/internal/utils" -) - -var _ = Describe("Techsupport List", func() { - BeforeEach(func() { - }) - - It("techsupport list displays all techsupports collected per Techsupport instance", func() { - techsupportInstance := &utilsv1beta1.Techsupport{ - ObjectMeta: metav1.ObjectMeta{ - Name: randomString(), - }, - Spec: utilsv1beta1.TechsupportSpec{ - Storage: randomString(), - }, - } - - numOfCollection := 4 - techsupportDir := createTechsupportDirectories(techsupportInstance.Name, techsupportInstance.Spec.Storage, - numOfCollection) - techsupportInstance.Spec.Storage = techsupportDir - By(fmt.Sprintf("Created techsupport instance %s (storage %s)", techsupportInstance.Name, techsupportInstance.Spec.Storage)) - - old := os.Stdout // keep backup of the real stdout - r, w, _ := os.Pipe() - os.Stdout = w - - initObjects := []client.Object{techsupportInstance} - - scheme, err := utils.GetScheme() - Expect(err).To(BeNil()) - c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build() - - utils.InitalizeManagementClusterAcces(scheme, nil, nil, c) - collector.InitializeClient(context.TODO(), - textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))), c, 10) - - err = techsupport.ListTechsupports(context.TODO(), "", - textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1)))) - Expect(err).To(BeNil()) - - w.Close() - var buf bytes.Buffer - _, err = io.Copy(&buf, r) - Expect(err).To(BeNil()) - /* - // Following is an example of techsupport list - +-----------------+---------------------+ - | SNAPSHOT POLICY | DATE | - +-----------------+---------------------+ - | daily | 2022-10-07:01:10:59 | - | daily | 2022-10-07:02:10:56 | - +-----------------+---------------------+ - */ - - foundCollection := 0 - lines := strings.Split(buf.String(), "\n") - for i := range lines { - if strings.Contains(lines[i], techsupportInstance.Name) { - foundCollection++ - } - } - - Expect(foundCollection).To(Equal(numOfCollection)) - - os.Stdout = old - }) -}) diff --git a/internal/commands/techsupport/techsupport_suite_test.go b/internal/commands/techsupport/techsupport_suite_test.go deleted file mode 100644 index 2c236a15..00000000 --- a/internal/commands/techsupport/techsupport_suite_test.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package techsupport_test - -import ( - "fmt" - "os" - "path/filepath" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/cluster-api/util" -) - -const ( - timeFormat = "2006-01-02:15:04:05" -) - -func TestTechsupport(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Techsupport Suite") -} - -func createTechsupportDirectories(techsupportName, techsupportStorage string, numOfDirs int) string { - techsupportDir, err := os.MkdirTemp("", randomString()) - Expect(err).To(BeNil()) - techsupportDir = filepath.Join(techsupportDir, techsupportStorage) - Expect(os.Mkdir(techsupportDir, os.ModePerm)).To(Succeed()) - tmpDir := filepath.Join(techsupportDir, "techsupport") - Expect(os.Mkdir(tmpDir, os.ModePerm)).To(Succeed()) - tmpDir = filepath.Join(tmpDir, techsupportName) - Expect(os.Mkdir(tmpDir, os.ModePerm)).To(Succeed()) - - now := time.Now() - for i := 0; i < numOfDirs; i++ { - timeFolder := now.Add(-time.Second * time.Duration(2*i)).Format(timeFormat) - tmpDir := filepath.Join(techsupportDir, "techsupport", techsupportName, timeFolder) - Expect(os.Mkdir(tmpDir, os.ModePerm)).To(Succeed()) - By(fmt.Sprintf("Created temporary directory %s", tmpDir)) - } - - By(fmt.Sprintf("Techsupport directory: %s", techsupportDir)) - return techsupportDir -} - -func randomString() string { - const length = 10 - return util.RandomString(length) -} diff --git a/internal/commands/techsupport_reconciler.go b/internal/commands/techsupport_reconciler.go deleted file mode 100644 index 09b18dc7..00000000 --- a/internal/commands/techsupport_reconciler.go +++ /dev/null @@ -1,460 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package commands - -import ( - "context" - "fmt" - "reflect" - "time" - - "github.com/go-logr/logr" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2/textlogger" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/event" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - logs "github.com/projectsveltos/libsveltos/lib/logsettings" - libsveltosset "github.com/projectsveltos/libsveltos/lib/set" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" - "github.com/projectsveltos/sveltosctl/internal/collector" - "github.com/projectsveltos/sveltosctl/internal/utils" -) - -func TechsupportReconciler(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { - logger := textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))) - logger.V(logs.LogInfo).Info("Reconciling") - - accessInstance := utils.GetAccessInstance() - - techsupportInstance := &utilsv1beta1.Techsupport{} - if err := accessInstance.GetResource(ctx, req.NamespacedName, techsupportInstance); err != nil { - logger.Error(err, "unable to fetch Techsupport") - return ctrl.Result{}, client.IgnoreNotFound(err) - } - - logger = logger.WithValues("techsupport", techsupportInstance.Name) - - if !techsupportInstance.DeletionTimestamp.IsZero() { - if result, err := reconcileDelete(ctx, techsupportInstance, collector.Techsupport, techsupportInstance.Spec.Storage, - utilsv1beta1.TechsupportFinalizer, logger); err != nil { - return result, err - } - cleanMaps(techsupportInstance) - return reconcile.Result{}, nil - } - - return reconcileTechsupportNormal(ctx, techsupportInstance, logger) -} - -func reconcileTechsupportNormal(ctx context.Context, techsupportInstance *utilsv1beta1.Techsupport, - logger logr.Logger) (reconcile.Result, error) { - - logger.V(logs.LogInfo).Info("reconcileTechsupportNormal") - if err := addFinalizer(ctx, techsupportInstance, utilsv1beta1.TechsupportFinalizer); err != nil { - logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to add finalizer: %s", err)) - return reconcile.Result{}, err - } - - matchingClusters, err := getMatchingClusters(ctx, techsupportInstance) - if err != nil { - return reconcile.Result{}, err - } - - techsupportInstance.Status.MatchingClusterRefs = matchingClusters - - updateMaps(techsupportInstance) - - collectionTechsupport := collectionTechsupport{techsupportInstance: techsupportInstance} - techsupportClient := collector.GetClient() - // Get result, if any, from previous run - result := techsupportClient.GetResult(ctx, techsupportInstance.Name, collector.Techsupport) - updateStatus(result, &collectionTechsupport) - - now := time.Now() - nextRun, err := schedule(ctx, techsupportInstance, collector.Techsupport, - collectTechsupport, &collectionTechsupport, logger) - if err != nil { - logger.V(logs.LogInfo).Info("failed to get next run. Err: %v", err) - return ctrl.Result{}, err - } - - techsupportInstance = collectionTechsupport.techsupportInstance - - logger.V(logs.LogInfo).Info("patching techsupport instance") - err = utils.GetAccessInstance().UpdateResourceStatus(ctx, techsupportInstance) - if err != nil { - logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to patch. Err: %v", err)) - return reconcile.Result{Requeue: true, RequeueAfter: requeueAfter}, nil - } - if isCollectionInProgress(techsupportInstance.Status.LastRunStatus) { - logger.V(logs.LogInfo).Info("techsupport collection still in progress") - return reconcile.Result{Requeue: true, RequeueAfter: requeueAfter}, nil - } - - logger.V(logs.LogInfo).Info("reconcile techsupport succeeded") - scheduledResult := ctrl.Result{RequeueAfter: nextRun.Sub(now)} - return scheduledResult, nil -} - -type ClusterPredicate struct { - Logger logr.Logger -} - -func (p ClusterPredicate) Create(obj event.TypedCreateEvent[*clusterv1.Cluster]) bool { - cluster := obj.Object - log := p.Logger.WithValues("predicate", "createEvent", - "namespace", cluster.Namespace, - "cluster", cluster.Name, - ) - - // Only need to trigger a reconcile if the Cluster.Spec.Paused is false - if !cluster.Spec.Paused { - log.V(logs.LogVerbose).Info( - "Cluster is not paused. Will attempt to reconcile associated ClusterProfiles.", - ) - return true - } - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -func (p ClusterPredicate) Update(obj event.TypedUpdateEvent[*clusterv1.Cluster]) bool { - newCluster := obj.ObjectNew - oldCluster := obj.ObjectOld - log := p.Logger.WithValues("predicate", "updateEvent", - "namespace", newCluster.Namespace, - "cluster", newCluster.Name, - ) - - if oldCluster == nil { - log.V(logs.LogVerbose).Info("Old Cluster is nil. Reconcile ClusterProfile") - return true - } - - // return true if Cluster.Spec.Paused has changed from true to false - if oldCluster.Spec.Paused && !newCluster.Spec.Paused { - log.V(logs.LogVerbose).Info( - "Cluster was unpaused. Will attempt to reconcile associated ClusterProfiles.") - return true - } - - if !reflect.DeepEqual(oldCluster.Labels, newCluster.Labels) { - log.V(logs.LogVerbose).Info( - "Cluster labels changed. Will attempt to reconcile associated ClusterProfiles.", - ) - return true - } - - // otherwise, return false - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -func (p ClusterPredicate) Delete(obj event.TypedDeleteEvent[*clusterv1.Cluster]) bool { - log := p.Logger.WithValues("predicate", "deleteEvent", - "namespace", obj.Object.GetNamespace(), - "cluster", obj.Object.GetName(), - ) - log.V(logs.LogVerbose).Info( - "Cluster deleted. Will attempt to reconcile associated ClusterProfiles.") - return true -} - -func (p ClusterPredicate) Generic(obj event.TypedGenericEvent[*clusterv1.Cluster]) bool { - log := p.Logger.WithValues("predicate", "genericEvent", - "namespace", obj.Object.GetNamespace(), - "cluster", obj.Object.GetName(), - ) - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -type SveltosClusterPredicate struct { - Logger logr.Logger -} - -func (p SveltosClusterPredicate) Create(obj event.TypedCreateEvent[*libsveltosv1beta1.SveltosCluster]) bool { - cluster := obj.Object - log := p.Logger.WithValues("predicate", "createEvent", - "namespace", cluster.Namespace, - "cluster", cluster.Name, - ) - - // Only need to trigger a reconcile if the Cluster.Spec.Paused is false - if !cluster.Spec.Paused { - log.V(logs.LogVerbose).Info( - "Cluster is not paused. Will attempt to reconcile associated ClusterProfiles.", - ) - return true - } - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -func (p SveltosClusterPredicate) Update(obj event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]) bool { - newCluster := obj.ObjectNew - oldCluster := obj.ObjectOld - log := p.Logger.WithValues("predicate", "updateEvent", - "namespace", newCluster.Namespace, - "cluster", newCluster.Name, - ) - - if oldCluster == nil { - log.V(logs.LogVerbose).Info("Old Cluster is nil. Reconcile ClusterProfile") - return true - } - - // return true if Cluster.Spec.Paused has changed from true to false - if oldCluster.Spec.Paused && !newCluster.Spec.Paused { - log.V(logs.LogVerbose).Info( - "Cluster was unpaused. Will attempt to reconcile associated ClusterProfiles.") - return true - } - - if !oldCluster.Status.Ready && newCluster.Status.Ready { - log.V(logs.LogVerbose).Info( - "Cluster was not ready. Will attempt to reconcile associated ClusterProfiles.") - return true - } - - if !reflect.DeepEqual(oldCluster.Labels, newCluster.Labels) { - log.V(logs.LogVerbose).Info( - "Cluster labels changed. Will attempt to reconcile associated ClusterProfiles.", - ) - return true - } - - // otherwise, return false - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -func (p SveltosClusterPredicate) Delete(obj event.TypedDeleteEvent[*libsveltosv1beta1.SveltosCluster]) bool { - log := p.Logger.WithValues("predicate", "deleteEvent", - "namespace", obj.Object.GetNamespace(), - "cluster", obj.Object.GetName(), - ) - log.V(logs.LogVerbose).Info( - "Cluster deleted. Will attempt to reconcile associated ClusterProfiles.") - return true -} - -func (p SveltosClusterPredicate) Generic(obj event.TypedGenericEvent[*libsveltosv1beta1.SveltosCluster]) bool { - log := p.Logger.WithValues("predicate", "genericEvent", - "namespace", obj.Object.GetNamespace(), - "cluster", obj.Object.GetName(), - ) - log.V(logs.LogVerbose).Info( - "Cluster did not match expected conditions. Will not attempt to reconcile associated ClusterProfiles.") - return false -} - -func updateMaps(techsupport *utilsv1beta1.Techsupport) { - currentClusters := &libsveltosset.Set{} - for i := range techsupport.Status.MatchingClusterRefs { - cluster := techsupport.Status.MatchingClusterRefs[i] - clusterInfo := &corev1.ObjectReference{Namespace: cluster.Namespace, Name: cluster.Name, Kind: cluster.Kind, APIVersion: cluster.APIVersion} - currentClusters.Insert(clusterInfo) - } - - mux.Lock() - defer mux.Unlock() - - techsupportInfo := getKeyFromObject(techsupport) - - // Get list of Clusters not matched anymore by Techsupport - var toBeRemoved []corev1.ObjectReference - if v, ok := techsupportMap[*techsupportInfo]; ok { - toBeRemoved = v.Difference(currentClusters) - } - - // For each currently matching Cluster, add Techsupport as consumer - for i := range techsupport.Status.MatchingClusterRefs { - cluster := techsupport.Status.MatchingClusterRefs[i] - clusterInfo := &corev1.ObjectReference{Namespace: cluster.Namespace, Name: cluster.Name, Kind: cluster.Kind, APIVersion: cluster.APIVersion} - getClusterMapForEntry(clusterInfo).Insert(techsupportInfo) - } - - // For each Cluster not matched anymore, remove Techsupport as consumer - for i := range toBeRemoved { - clusterInfo := toBeRemoved[i] - getClusterMapForEntry(&clusterInfo).Erase(techsupportInfo) - } - - techsupportMap[*techsupportInfo] = currentClusters - techsupports[*techsupportInfo] = techsupport.Spec.ClusterSelector -} - -func cleanMaps(techsupport *utilsv1beta1.Techsupport) { - mux.Lock() - defer mux.Unlock() - - techsupportInfo := getKeyFromObject(techsupport) - - delete(techsupportMap, *techsupportInfo) - delete(techsupports, *techsupportInfo) - - for i := range clusterMap { - techsupportSet := clusterMap[i] - techsupportSet.Erase(techsupportInfo) - } -} - -// getKeyFromObject returns the Key that can be used in the internal reconciler maps. -func getKeyFromObject(obj client.Object) *corev1.ObjectReference { - scheme, _ := utils.GetScheme() - addTypeInformationToObject(scheme, obj) - - return &corev1.ObjectReference{ - Namespace: obj.GetNamespace(), - Name: obj.GetName(), - Kind: obj.GetObjectKind().GroupVersionKind().Kind, - APIVersion: obj.GetObjectKind().GroupVersionKind().String(), - } -} - -func addTypeInformationToObject(scheme *runtime.Scheme, obj client.Object) { - gvks, _, err := scheme.ObjectKinds(obj) - if err != nil { - panic(1) - } - - for _, gvk := range gvks { - if gvk.Kind == "" { - continue - } - if gvk.Version == "" || gvk.Version == runtime.APIVersionInternal { - continue - } - obj.GetObjectKind().SetGroupVersionKind(gvk) - break - } -} - -func getClusterMapForEntry(entry *corev1.ObjectReference) *libsveltosset.Set { - s := clusterMap[*entry] - if s == nil { - s = &libsveltosset.Set{} - clusterMap[*entry] = s - } - return s -} - -// getMatchingClusters returns all Sveltos/CAPI Clusters currently matching Techsupport.Spec.ClusterSelector -func getMatchingClusters(ctx context.Context, techsupport *utilsv1beta1.Techsupport, -) ([]corev1.ObjectReference, error) { - - matching := make([]corev1.ObjectReference, 0) - - clusterSelector, err := metav1.LabelSelectorAsSelector(&techsupport.Spec.ClusterSelector.LabelSelector) - if err != nil { - return nil, err - } - - tmpMatching, err := getMatchingCAPIClusters(ctx, clusterSelector) - if err != nil { - return nil, err - } - - matching = append(matching, tmpMatching...) - - tmpMatching, err = getMatchingSveltosClusters(ctx, clusterSelector) - if err != nil { - return nil, err - } - - matching = append(matching, tmpMatching...) - - return matching, nil -} - -func getMatchingCAPIClusters(ctx context.Context, parsedSelector labels.Selector) ([]corev1.ObjectReference, error) { - instance := utils.GetAccessInstance() - - clusterList := &clusterv1.ClusterList{} - if err := instance.ListResources(ctx, clusterList); err != nil { - return nil, err - } - - matching := make([]corev1.ObjectReference, 0) - - for i := range clusterList.Items { - cluster := &clusterList.Items[i] - - if !cluster.DeletionTimestamp.IsZero() { - // Only existing cluster can match - continue - } - - addTypeInformationToObject(instance.GetScheme(), cluster) - if parsedSelector.Matches(labels.Set(cluster.Labels)) { - matching = append(matching, corev1.ObjectReference{ - Kind: cluster.Kind, - Namespace: cluster.Namespace, - Name: cluster.Name, - APIVersion: cluster.APIVersion, - }) - } - } - - return matching, nil -} - -func getMatchingSveltosClusters(ctx context.Context, parsedSelector labels.Selector) ([]corev1.ObjectReference, error) { - instance := utils.GetAccessInstance() - - clusterList := &libsveltosv1beta1.SveltosClusterList{} - if err := instance.ListResources(ctx, clusterList); err != nil { - return nil, err - } - - matching := make([]corev1.ObjectReference, 0) - - for i := range clusterList.Items { - cluster := &clusterList.Items[i] - - if !cluster.DeletionTimestamp.IsZero() { - // Only existing cluster can match - continue - } - - addTypeInformationToObject(instance.GetScheme(), cluster) - if parsedSelector.Matches(labels.Set(cluster.Labels)) { - matching = append(matching, corev1.ObjectReference{ - Kind: cluster.Kind, - Namespace: cluster.Namespace, - Name: cluster.Name, - APIVersion: cluster.APIVersion, - }) - } - } - - return matching, nil -} diff --git a/internal/commands/techsupport_reconciler_test.go b/internal/commands/techsupport_reconciler_test.go deleted file mode 100644 index bee7bcb3..00000000 --- a/internal/commands/techsupport_reconciler_test.go +++ /dev/null @@ -1,268 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package commands_test - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/go-logr/logr" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/klog/v2/textlogger" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/event" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - "github.com/projectsveltos/sveltosctl/internal/commands" -) - -const ( - upstreamClusterNamePrefix = "predicates-" -) - -var _ = Describe("ClusterProfile Predicates: SvelotsClusterPredicates", func() { - var logger logr.Logger - var cluster *libsveltosv1beta1.SveltosCluster - - BeforeEach(func() { - logger = textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))) - cluster = &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: upstreamClusterNamePrefix + randomString(), - Namespace: "scpredicates" + randomString(), - }, - } - }) - - It("Create reprocesses when sveltos Cluster is unpaused", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - - result := clusterPredicate.Create(event.TypedCreateEvent[*libsveltosv1beta1.SveltosCluster]{Object: cluster}) - Expect(result).To(BeTrue()) - }) - It("Create does not reprocess when sveltos Cluster is paused", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Spec.Paused = true - cluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - - result := clusterPredicate.Create(event.TypedCreateEvent[*libsveltosv1beta1.SveltosCluster]{Object: cluster}) - Expect(result).To(BeFalse()) - }) - It("Delete does reprocess ", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - result := clusterPredicate.Delete(event.TypedDeleteEvent[*libsveltosv1beta1.SveltosCluster]{Object: cluster}) - Expect(result).To(BeTrue()) - }) - It("Update reprocesses when sveltos Cluster paused changes from true to false", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - - oldCluster := &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = true - oldCluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - - result := clusterPredicate.Update(event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeTrue()) - }) - It("Update does not reprocess when sveltos Cluster paused changes from false to true", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Spec.Paused = true - cluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - oldCluster := &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = false - - result := clusterPredicate.Update(event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeFalse()) - }) - It("Update does not reprocess when sveltos Cluster paused has not changed", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - oldCluster := &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = false - - result := clusterPredicate.Update(event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeFalse()) - }) - It("Update reprocesses when sveltos Cluster labels change", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Labels = map[string]string{"department": "eng"} - - oldCluster := &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - Labels: map[string]string{}, - }, - } - - result := clusterPredicate.Update(event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeTrue()) - }) - It("Update reprocesses when sveltos Cluster Status Ready changes", func() { - clusterPredicate := commands.SveltosClusterPredicate{Logger: logger} - - cluster.Status.Ready = true - - oldCluster := &libsveltosv1beta1.SveltosCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - Labels: map[string]string{}, - }, - Status: libsveltosv1beta1.SveltosClusterStatus{ - Ready: false, - }, - } - result := clusterPredicate.Update(event.TypedUpdateEvent[*libsveltosv1beta1.SveltosCluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeTrue()) - }) -}) - -var _ = Describe("ClusterProfile Predicates: ClusterPredicates", func() { - var logger logr.Logger - var cluster *clusterv1.Cluster - - BeforeEach(func() { - logger = textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(1))) - cluster = &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: upstreamClusterNamePrefix + randomString(), - Namespace: "cpredicates" + randomString(), - }, - } - }) - - It("Create reprocesses when v1Cluster is unpaused", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - - result := clusterPredicate.Create(event.TypedCreateEvent[*clusterv1.Cluster]{Object: cluster}) - Expect(result).To(BeTrue()) - }) - It("Create does not reprocess when v1Cluster is paused", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Spec.Paused = true - cluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - - result := clusterPredicate.Create(event.TypedCreateEvent[*clusterv1.Cluster]{Object: cluster}) - Expect(result).To(BeFalse()) - }) - It("Delete does reprocess ", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - result := clusterPredicate.Delete(event.TypedDeleteEvent[*clusterv1.Cluster]{Object: cluster}) - Expect(result).To(BeTrue()) - }) - It("Update reprocesses when v1Cluster paused changes from true to false", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - - oldCluster := &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = true - oldCluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - - result := clusterPredicate.Update(event.TypedUpdateEvent[*clusterv1.Cluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeTrue()) - }) - It("Update does not reprocess when v1Cluster paused changes from false to true", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Spec.Paused = true - cluster.Annotations = map[string]string{clusterv1.PausedAnnotation: "true"} - oldCluster := &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = false - - result := clusterPredicate.Update(event.TypedUpdateEvent[*clusterv1.Cluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeFalse()) - }) - It("Update does not reprocess when v1Cluster paused has not changed", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Spec.Paused = false - oldCluster := &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - }, - } - oldCluster.Spec.Paused = false - - result := clusterPredicate.Update(event.TypedUpdateEvent[*clusterv1.Cluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeFalse()) - }) - It("Update reprocesses when v1Cluster labels change", func() { - clusterPredicate := commands.ClusterPredicate{Logger: logger} - - cluster.Labels = map[string]string{"department": "eng"} - - oldCluster := &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cluster.Name, - Namespace: cluster.Namespace, - Labels: map[string]string{}, - }, - } - - result := clusterPredicate.Update(event.TypedUpdateEvent[*clusterv1.Cluster]{ - ObjectNew: cluster, ObjectOld: oldCluster}) - Expect(result).To(BeTrue()) - }) -}) diff --git a/internal/commands/techsupport_reconciler_utils.go b/internal/commands/techsupport_reconciler_utils.go deleted file mode 100644 index a54d78e8..00000000 --- a/internal/commands/techsupport_reconciler_utils.go +++ /dev/null @@ -1,425 +0,0 @@ -/* -Copyright 2023. projectsveltos.io. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package commands - -import ( - "context" - "fmt" - "path" - "reflect" - "time" - - "github.com/go-logr/logr" - "github.com/pkg/errors" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/discovery" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/client-go/restmapper" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" - "github.com/projectsveltos/libsveltos/lib/clusterproxy" - logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" - "github.com/projectsveltos/sveltosctl/internal/collector" - "github.com/projectsveltos/sveltosctl/internal/utils" -) - -type collectionTechsupport struct { - techsupportInstance *utilsv1beta1.Techsupport -} - -func (c *collectionTechsupport) getCreationTimestamp() *metav1.Time { - return &c.techsupportInstance.CreationTimestamp -} - -func (c *collectionTechsupport) getSchedule() string { - return c.techsupportInstance.Spec.Schedule -} - -func (c *collectionTechsupport) getNextScheduleTime() *metav1.Time { - return c.techsupportInstance.Status.NextScheduleTime -} - -func (c *collectionTechsupport) setNextScheduleTime(t *metav1.Time) { - c.techsupportInstance.Status.NextScheduleTime = t -} - -func (c *collectionTechsupport) getLastRunTime() *metav1.Time { - return c.techsupportInstance.Status.LastRunTime -} - -func (c *collectionTechsupport) setLastRunTime(t *metav1.Time) { - c.techsupportInstance.Status.LastRunTime = t -} - -func (c *collectionTechsupport) getStartingDeadlineSeconds() *int64 { - return c.techsupportInstance.Spec.StartingDeadlineSeconds -} - -func (c *collectionTechsupport) setLastRunStatus(s utilsv1beta1.CollectionStatus) { - c.techsupportInstance.Status.LastRunStatus = &s -} - -func (c *collectionTechsupport) setFailureMessage(m string) { - c.techsupportInstance.Status.FailureMessage = &m -} - -func collectTechsupport(ctx context.Context, c client.Client, techsupportName string, - logger logr.Logger) error { - - logger = logger.WithValues("techsupport", techsupportName) - logger.V(logs.LogInfo).Info("collect techsupport") - - techsupportInstance := &utilsv1beta1.Techsupport{} - err := c.Get(ctx, types.NamespacedName{Name: techsupportName}, techsupportInstance) - if err != nil { - if apierrors.IsNotFound(err) { - logger.V(logs.LogDebug).Info( - fmt.Sprintf("Techsupport %s does not exist anymore. Nothing to do.", techsupportName)) - return nil - } - - return err - } - - collectorClient := collector.GetClient() - - if techsupportInstance.Spec.SuccessfulTechsupportLimit != nil { - err = collectorClient.CleanOldCollections(techsupportInstance.Spec.Storage, techsupportInstance.Name, - collector.Techsupport, *techsupportInstance.Spec.SuccessfulTechsupportLimit, logger) - if err != nil { - return err - } - } - - now := time.Now() - folder := collectorClient.GetFolderPath(techsupportInstance.Spec.Storage, techsupportInstance.Name, - collector.Techsupport, now) - - err = nil - for i := range techsupportInstance.Status.MatchingClusterRefs { - cluster := &techsupportInstance.Status.MatchingClusterRefs[i] - l := logger.WithValues("cluster", fmt.Sprintf("%s:%s/%s", clusterproxy.GetClusterType(cluster), - cluster.Namespace, cluster.Name)) - clusterFolder := path.Join(folder, fmt.Sprintf("%s:%s/%s", clusterproxy.GetClusterType(cluster), - cluster.Namespace, cluster.Name)) - if tmpErr := collectTechsupportForCluster(ctx, c, techsupportInstance, cluster, clusterFolder, l); tmpErr != nil { - l.V(logs.LogDebug).Info(fmt.Sprintf("failed to collect techsupport: %v", tmpErr)) - if err == nil { - err = tmpErr - } else { - err = errors.Wrap(err, tmpErr.Error()) - } - } - } - - if techsupportInstance.Spec.Tar { - if tmpErr := collector.GetClient().TarDir(folder, logger); tmpErr != nil { - if err == nil { - err = tmpErr - } else { - err = errors.Wrap(err, tmpErr.Error()) - } - } - } - - if err != nil { - logger.V(logs.LogInfo).Info("done collecting techsupport") - } - - return err -} - -func collectTechsupportForCluster(ctx context.Context, c client.Client, techsupportInstance *utilsv1beta1.Techsupport, - cluster *corev1.ObjectReference, folder string, logger logr.Logger) error { - - ready, err := clusterproxy.IsClusterReadyToBeConfigured(ctx, c, cluster, logger) - if err != nil { - return err - } - if !ready { - logger.V(logs.LogInfo).Info("Cluster is not ready yet") - return nil - } - logger.V(logs.LogInfo).Info("collecting techsupport") - - saNamespace, saName := getClusterSummaryServiceAccountInfo(techsupportInstance) - - remoteRestConfig, err := clusterproxy.GetKubernetesRestConfig(ctx, utils.GetAccessInstance().GetClient(), - cluster.Namespace, cluster.Name, saNamespace, saName, clusterproxy.GetClusterType(cluster), logger) - if err != nil { - return err - } - - remoteClientSet, err := kubernetes.NewForConfig(remoteRestConfig) - if err != nil { - return err - } - - remoteClient, err := clusterproxy.GetKubernetesClient(ctx, utils.GetAccessInstance().GetClient(), - cluster.Namespace, cluster.Name, saNamespace, saName, clusterproxy.GetClusterType(cluster), logger) - if err != nil { - return err - } - - err = nil - for i := range techsupportInstance.Spec.Logs { - tmpErr := collectLogs(ctx, remoteClientSet, remoteClient, &techsupportInstance.Spec.Logs[i], folder, logger) - if tmpErr != nil { - logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to collect logs %v", err)) - if err == nil { - err = tmpErr - } else { - err = errors.Wrap(err, tmpErr.Error()) - } - } - } - - for i := range techsupportInstance.Spec.Resources { - resourceFolder := path.Join(folder, "resources") - tmpErr := dumpResources(ctx, remoteRestConfig, &techsupportInstance.Spec.Resources[i], resourceFolder, logger) - if tmpErr != nil { - logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to dump resources %v", err)) - if err == nil { - err = tmpErr - } else { - err = errors.Wrap(err, tmpErr.Error()) - } - } - } - - return err -} - -func dumpResources(ctx context.Context, remoteRestConfig *rest.Config, resource *utilsv1beta1.Resource, - folder string, logger logr.Logger) error { - - logger = logger.WithValues("gvk", fmt.Sprintf("%s:%s:%s", resource.Group, resource.Version, resource.Kind)) - logger.V(logs.LogInfo).Info("collecting resources") - - gvk := schema.GroupVersionKind{ - Group: resource.Group, - Version: resource.Version, - Kind: resource.Kind, - } - - dc := discovery.NewDiscoveryClientForConfigOrDie(remoteRestConfig) - groupResources, err := restmapper.GetAPIGroupResources(dc) - if err != nil { - return err - } - mapper := restmapper.NewDiscoveryRESTMapper(groupResources) - - d := dynamic.NewForConfigOrDie(remoteRestConfig) - - mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) - if err != nil { - if meta.IsNoMatchError(err) { - return nil - } - return err - } - - resourceId := schema.GroupVersionResource{ - Group: gvk.Group, - Version: gvk.Version, - Resource: mapping.Resource.Resource, - } - - options := metav1.ListOptions{} - - if len(resource.LabelFilters) > 0 { - labelFilter := "" - for i := range resource.LabelFilters { - if labelFilter != "" { - labelFilter += "," - } - f := resource.LabelFilters[i] - if f.Operation == libsveltosv1beta1.OperationEqual { - labelFilter += fmt.Sprintf("%s=%s", f.Key, f.Value) - } else { - labelFilter += fmt.Sprintf("%s!=%s", f.Key, f.Value) - } - } - - options.LabelSelector = labelFilter - } - - if resource.Namespace != "" { - if options.FieldSelector != "" { - options.FieldSelector += "," - } - options.FieldSelector += fmt.Sprintf("metadata.namespace=%s", resource.Namespace) - } - - list, err := d.Resource(resourceId).List(ctx, options) - if err != nil { - return err - } - - logger.V(logs.LogInfo).Info(fmt.Sprintf("collected %d resources", len(list.Items))) - for i := range list.Items { - err = collector.GetClient().DumpObject(&list.Items[i], folder, logger) - if err != nil { - return err - } - } - - return nil -} - -func collectLogs(ctx context.Context, remoteClientSet *kubernetes.Clientset, remoteClient client.Client, - log *utilsv1beta1.Log, folder string, logger logr.Logger) error { - - logger.V(logs.LogInfo).Info("collecting logs") - options := client.ListOptions{} - - if len(log.LabelFilters) > 0 { - labelFilter := "" - for i := range log.LabelFilters { - if labelFilter != "" { - labelFilter += "," - } - f := log.LabelFilters[i] - if f.Operation == libsveltosv1beta1.OperationEqual { - labelFilter += fmt.Sprintf("%s=%s", f.Key, f.Value) - } else { - labelFilter += fmt.Sprintf("%s!=%s", f.Key, f.Value) - } - } - - parsedSelector, err := labels.Parse(labelFilter) - if err != nil { - return err - } - options.LabelSelector = parsedSelector - } - - if log.Namespace != "" { - options.Namespace = log.Namespace - } - - pods := &corev1.PodList{} - if err := remoteClient.List(ctx, pods, &options); err != nil { - return err - } - - logger.V(logs.LogInfo).Info(fmt.Sprintf("found %d pods", len(pods.Items))) - for i := range pods.Items { - if err := collector.GetClient().DumpPodLogs(ctx, remoteClientSet, folder, log.SinceSeconds, - &pods.Items[i]); err != nil { - return err - } - } - - return nil -} - -func updateTechsupportPredicate(newObject, oldObject *utilsv1beta1.Techsupport) bool { - if oldObject == nil || - !reflect.DeepEqual(newObject.Spec, oldObject.Spec) { - - return true - } - - return false -} - -func requeueTechsupportForSveltosCluster( - ctx context.Context, sveltosCluster *libsveltosv1beta1.SveltosCluster, -) []reconcile.Request { - - return requeueTechsupportForACluster(sveltosCluster) -} - -func requeueTechsupportForCluster( - ctx context.Context, cluster *clusterv1.Cluster, -) []reconcile.Request { - - return requeueTechsupportForACluster(cluster) -} - -func requeueTechsupportForACluster( - cluster client.Object, -) []reconcile.Request { - - mux.Lock() - defer mux.Unlock() - - instance := utils.GetAccessInstance() - addTypeInformationToObject(instance.GetScheme(), cluster) - - apiVersion, kind := cluster.GetObjectKind().GroupVersionKind().ToAPIVersionAndKind() - - clusterInfo := corev1.ObjectReference{APIVersion: apiVersion, Kind: kind, - Namespace: cluster.GetNamespace(), Name: cluster.GetName()} - - // Get all Techsupport previously matching this cluster and reconcile those - requests := make([]ctrl.Request, getClusterMapForEntry(&clusterInfo).Len()) - consumers := getClusterMapForEntry(&clusterInfo).Items() - - for i := range consumers { - requests[i] = ctrl.Request{ - NamespacedName: client.ObjectKey{ - Name: consumers[i].Name, - }, - } - } - - // Iterate over all current ClusterProfile and reconcile the ClusterProfile now - // matching the Cluster - for k := range techsupports { - techsupportSelector := techsupports[k] - clusterSelector, err := metav1.LabelSelectorAsSelector(&techsupportSelector.LabelSelector) - if err != nil { - return requests - } - if clusterSelector.Matches(labels.Set(cluster.GetLabels())) { - requests = append(requests, ctrl.Request{ - NamespacedName: client.ObjectKey{ - Name: k.Name, - }, - }) - } - } - - return requests -} - -// getClusterSummaryServiceAccountInfo returns the name of the ServiceAccount -// (presenting a tenant admin) that created the ClusterProfile instance owing this -// ClusterProfile instance -func getClusterSummaryServiceAccountInfo(techsupport *utilsv1beta1.Techsupport) (namespace, name string) { - if techsupport.Labels == nil { - return "", "" - } - - return techsupport.Labels[libsveltosv1beta1.ServiceAccountNamespaceLabel], - techsupport.Labels[libsveltosv1beta1.ServiceAccountNameLabel] -} diff --git a/internal/utils/classifiers_test.go b/internal/utils/classifiers_test.go index 3fa825ea..4c3d4b29 100644 --- a/internal/utils/classifiers_test.go +++ b/internal/utils/classifiers_test.go @@ -48,8 +48,8 @@ var _ = Describe("Classifier", func() { KubernetesVersionConstraints: []libsveltosv1beta1.KubernetesVersionConstraint{ {Version: randomString(), Comparison: string(libsveltosv1beta1.ComparisonEqual)}, }, - DeployedResourceConstraint: &libsveltosv1beta1.DeployedResourceConstraint{ - ResourceSelectors: []libsveltosv1beta1.ResourceSelector{ + DeployedResourceConstraint: &libsveltosv1alpha1.DeployedResourceConstraint{ + ResourceSelectors: []libsveltosv1alpha1.ResourceSelector{ { Group: randomString(), Version: randomString(), diff --git a/internal/utils/client.go b/internal/utils/client.go index e7543244..3b33bc7c 100644 --- a/internal/utils/client.go +++ b/internal/utils/client.go @@ -36,11 +36,11 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" eventv1beta1 "github.com/projectsveltos/event-manager/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" - utilsv1beta1 "github.com/projectsveltos/sveltosctl/api/v1beta1" + utilsv1alpha1 "github.com/projectsveltos/sveltosctl/api/v1alpha1" ) // k8sAccess is used to access resources in the management cluster. @@ -92,7 +92,7 @@ func addToScheme(scheme *runtime.Scheme) error { if err := appsv1.AddToScheme(scheme); err != nil { return err } - if err := configv1alpha1.AddToScheme(scheme); err != nil { + if err := configv1beta1.AddToScheme(scheme); err != nil { return err } if err := utilsv1beta1.AddToScheme(scheme); err != nil { @@ -107,6 +107,9 @@ func addToScheme(scheme *runtime.Scheme) error { if err := eventv1beta1.AddToScheme(scheme); err != nil { return err } + if err := eventv1alpha1.AddToScheme(scheme); err != nil { + return err + } if err := rbacv1.AddToScheme(scheme); err != nil { return err } diff --git a/internal/utils/clusterconfigurations.go b/internal/utils/clusterconfigurations.go index 39099750..610a76e2 100644 --- a/internal/utils/clusterconfigurations.go +++ b/internal/utils/clusterconfigurations.go @@ -24,14 +24,14 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) -func (a *k8sAccess) GetClusterNameFromClusterConfiguration(clusterConfiguration *configv1alpha1.ClusterConfiguration) string { +func (a *k8sAccess) GetClusterNameFromClusterConfiguration(clusterConfiguration *configv1beta1.ClusterConfiguration) string { clusterName := clusterConfiguration.Name if clusterConfiguration.Labels != nil { - if v, ok := clusterConfiguration.Labels[configv1alpha1.ClusterNameLabel]; ok { + if v, ok := clusterConfiguration.Labels[configv1beta1.ClusterNameLabel]; ok { clusterName = v } } @@ -40,76 +40,76 @@ func (a *k8sAccess) GetClusterNameFromClusterConfiguration(clusterConfiguration // ListClusterConfigurations returns all current ClusterConfigurations in a namespace (if specified) func (a *k8sAccess) ListClusterConfigurations(ctx context.Context, namespace string, - logger logr.Logger) (*configv1alpha1.ClusterConfigurationList, error) { + logger logr.Logger) (*configv1beta1.ClusterConfigurationList, error) { listOptions := []client.ListOption{ client.InNamespace(namespace), } logger.V(logs.LogDebug).Info("Get all ClusterConfigurations") - clusterConfigurations := &configv1alpha1.ClusterConfigurationList{} + clusterConfigurations := &configv1beta1.ClusterConfigurationList{} err := a.client.List(ctx, clusterConfigurations, listOptions...) return clusterConfigurations, err } // GetClusterConfiguration returns current ClusterConfiguration for a given Cluster func (a *k8sAccess) GetClusterConfiguration(ctx context.Context, - clusterNamespace, clusterName string, logger logr.Logger) (*configv1alpha1.ClusterConfiguration, error) { + clusterNamespace, clusterName string, logger logr.Logger) (*configv1beta1.ClusterConfiguration, error) { logger = logger.WithValues("namespace", clusterNamespace, "cluster", clusterName) logger.V(logs.LogDebug).Info("Get ClusterConfiguration") - clusterConfiguration := &configv1alpha1.ClusterConfiguration{} + clusterConfiguration := &configv1beta1.ClusterConfiguration{} err := a.client.Get(ctx, types.NamespacedName{Namespace: clusterNamespace, Name: clusterName}, clusterConfiguration) return clusterConfiguration, err } // GetHelmReleases returns list of helm releases deployed in a given cluster -func (a *k8sAccess) GetHelmReleases(clusterConfiguration *configv1alpha1.ClusterConfiguration, - logger logr.Logger) map[configv1alpha1.Chart][]string { +func (a *k8sAccess) GetHelmReleases(clusterConfiguration *configv1beta1.ClusterConfiguration, + logger logr.Logger) map[configv1beta1.Chart][]string { logger = logger.WithValues("namespace", clusterConfiguration.Namespace, "clusterConfiguration", clusterConfiguration.Name) - results := make(map[configv1alpha1.Chart][]string) + results := make(map[configv1beta1.Chart][]string) logger.V(logs.LogDebug).Info("Get Helm Releases deployed in the cluster") for i := range clusterConfiguration.Status.ClusterProfileResources { r := clusterConfiguration.Status.ClusterProfileResources[i] - a.addDeployedCharts(configv1alpha1.ClusterProfileKind, r.ClusterProfileName, r.Features, results) + a.addDeployedCharts(configv1beta1.ClusterProfileKind, r.ClusterProfileName, r.Features, results) } for i := range clusterConfiguration.Status.ProfileResources { r := clusterConfiguration.Status.ProfileResources[i] - a.addDeployedCharts(configv1alpha1.ProfileKind, r.ProfileName, r.Features, results) + a.addDeployedCharts(configv1beta1.ProfileKind, r.ProfileName, r.Features, results) } return results } // GetResources returns list of resources deployed in a given cluster -func (a *k8sAccess) GetResources(clusterConfiguration *configv1alpha1.ClusterConfiguration, - logger logr.Logger) map[configv1alpha1.Resource][]string { +func (a *k8sAccess) GetResources(clusterConfiguration *configv1beta1.ClusterConfiguration, + logger logr.Logger) map[configv1beta1.Resource][]string { logger = logger.WithValues("namespace", clusterConfiguration.Namespace, "clusterConfiguration", clusterConfiguration.Name) - results := make(map[configv1alpha1.Resource][]string) + results := make(map[configv1beta1.Resource][]string) logger.V(logs.LogDebug).Info("Get resources deployed in the cluster") for i := range clusterConfiguration.Status.ClusterProfileResources { r := clusterConfiguration.Status.ClusterProfileResources[i] - a.addDeployedResources(configv1alpha1.ClusterProfileKind, r.ClusterProfileName, r.Features, results) + a.addDeployedResources(configv1beta1.ClusterProfileKind, r.ClusterProfileName, r.Features, results) } for i := range clusterConfiguration.Status.ProfileResources { r := clusterConfiguration.Status.ProfileResources[i] - a.addDeployedResources(configv1alpha1.ProfileKind, r.ProfileName, r.Features, results) + a.addDeployedResources(configv1beta1.ProfileKind, r.ProfileName, r.Features, results) } return results } func (a *k8sAccess) addDeployedCharts(profileKind, profileName string, - features []configv1alpha1.Feature, results map[configv1alpha1.Chart][]string) { + features []configv1beta1.Feature, results map[configv1beta1.Chart][]string) { for i := range features { a.addDeployedChartsForFeature( @@ -119,7 +119,7 @@ func (a *k8sAccess) addDeployedCharts(profileKind, profileName string, } func (a *k8sAccess) addDeployedChartsForFeature(clusterProfilesName string, - charts []configv1alpha1.Chart, results map[configv1alpha1.Chart][]string) { + charts []configv1beta1.Chart, results map[configv1beta1.Chart][]string) { for i := range charts { chart := &charts[i] @@ -133,7 +133,7 @@ func (a *k8sAccess) addDeployedChartsForFeature(clusterProfilesName string, } func (a *k8sAccess) addDeployedResources(profilesKind, profileName string, - features []configv1alpha1.Feature, results map[configv1alpha1.Resource][]string) { + features []configv1beta1.Feature, results map[configv1beta1.Resource][]string) { for i := range features { a.addDeployedResourcesForFeature( @@ -143,7 +143,7 @@ func (a *k8sAccess) addDeployedResources(profilesKind, profileName string, } func (a *k8sAccess) addDeployedResourcesForFeature(profileName string, - resources []configv1alpha1.Resource, results map[configv1alpha1.Resource][]string) { + resources []configv1beta1.Resource, results map[configv1beta1.Resource][]string) { for i := range resources { resource := &resources[i] diff --git a/internal/utils/clusterconfigurations_test.go b/internal/utils/clusterconfigurations_test.go index afbcd1f2..2b65d5fc 100644 --- a/internal/utils/clusterconfigurations_test.go +++ b/internal/utils/clusterconfigurations_test.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -40,7 +40,7 @@ var _ = Describe("ClusterConfiguration", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - clusterConfiguration := &configv1alpha1.ClusterConfiguration{ + clusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), @@ -49,7 +49,7 @@ var _ = Describe("ClusterConfiguration", func() { initObjects = append(initObjects, clusterConfiguration) } - clusterConfiguration := &configv1alpha1.ClusterConfiguration{ + clusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), @@ -74,7 +74,7 @@ var _ = Describe("ClusterConfiguration", func() { }) It("GetClusterConfiguration returns ClusterConfiguration for a given cluster ", func() { - clusterConfiguration := &configv1alpha1.ClusterConfiguration{ + clusterConfiguration := &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), @@ -102,7 +102,7 @@ var _ = Describe("ClusterConfiguration", func() { }) It("GetHelmReleases returns deployed helm releases", func() { - chart1 := &configv1alpha1.Chart{ + chart1 := &configv1beta1.Chart{ RepoURL: randomString(), ReleaseName: randomString(), Namespace: randomString(), @@ -110,7 +110,7 @@ var _ = Describe("ClusterConfiguration", func() { LastAppliedTime: &metav1.Time{Time: time.Now()}, } - chart2 := &configv1alpha1.Chart{ + chart2 := &configv1beta1.Chart{ RepoURL: randomString(), ReleaseName: randomString(), Namespace: randomString(), @@ -119,7 +119,7 @@ var _ = Describe("ClusterConfiguration", func() { } clusterConfiguration := createClusterConfiguration(nil, nil, - []configv1alpha1.Chart{*chart1}, []configv1alpha1.Chart{*chart1, *chart2}) + []configv1beta1.Chart{*chart1}, []configv1beta1.Chart{*chart1, *chart2}) initObjects := []client.Object{clusterConfiguration} scheme := runtime.NewScheme() @@ -136,7 +136,7 @@ var _ = Describe("ClusterConfiguration", func() { }) It("GetResources returns deployed resources", func() { - resource1 := &configv1alpha1.Resource{ + resource1 := &configv1beta1.Resource{ Name: randomString(), Namespace: randomString(), Group: randomString(), @@ -144,7 +144,7 @@ var _ = Describe("ClusterConfiguration", func() { LastAppliedTime: &metav1.Time{Time: time.Now()}, } - resource2 := &configv1alpha1.Resource{ + resource2 := &configv1beta1.Resource{ Name: randomString(), Namespace: randomString(), Group: randomString(), @@ -153,7 +153,7 @@ var _ = Describe("ClusterConfiguration", func() { } clusterConfiguration := createClusterConfiguration( - []configv1alpha1.Resource{*resource1}, []configv1alpha1.Resource{*resource1, *resource2}, + []configv1beta1.Resource{*resource1}, []configv1beta1.Resource{*resource1, *resource2}, nil, nil) initObjects := []client.Object{clusterConfiguration} @@ -171,38 +171,38 @@ var _ = Describe("ClusterConfiguration", func() { }) }) -func createClusterConfiguration(clusterProfile1Resources, clusterProfile2Resources []configv1alpha1.Resource, - clusterProfile1Charts, clusterProfile2Charts []configv1alpha1.Chart) *configv1alpha1.ClusterConfiguration { +func createClusterConfiguration(clusterProfile1Resources, clusterProfile2Resources []configv1beta1.Resource, + clusterProfile1Charts, clusterProfile2Charts []configv1beta1.Chart) *configv1beta1.ClusterConfiguration { - cfr1 := &configv1alpha1.ClusterProfileResource{ + cfr1 := &configv1beta1.ClusterProfileResource{ ClusterProfileName: randomString(), - Features: []configv1alpha1.Feature{ + Features: []configv1beta1.Feature{ { - FeatureID: configv1alpha1.FeatureHelm, + FeatureID: configv1beta1.FeatureHelm, Resources: clusterProfile1Resources, Charts: clusterProfile1Charts, }, }, } - cfr2 := &configv1alpha1.ClusterProfileResource{ + cfr2 := &configv1beta1.ClusterProfileResource{ ClusterProfileName: randomString(), - Features: []configv1alpha1.Feature{ + Features: []configv1beta1.Feature{ { - FeatureID: configv1alpha1.FeatureHelm, + FeatureID: configv1beta1.FeatureHelm, Resources: clusterProfile2Resources, Charts: clusterProfile2Charts, }, }, } - return &configv1alpha1.ClusterConfiguration{ + return &configv1beta1.ClusterConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Status: configv1alpha1.ClusterConfigurationStatus{ - ClusterProfileResources: []configv1alpha1.ClusterProfileResource{ + Status: configv1beta1.ClusterConfigurationStatus{ + ClusterProfileResources: []configv1beta1.ClusterProfileResource{ *cfr1, *cfr2, }, diff --git a/internal/utils/clusterprofiles.go b/internal/utils/clusterprofiles.go index bca26824..04b00172 100644 --- a/internal/utils/clusterprofiles.go +++ b/internal/utils/clusterprofiles.go @@ -21,16 +21,16 @@ import ( "github.com/go-logr/logr" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListClusterProfiles returns all current ClusterProfiles func (a *k8sAccess) ListClusterProfiles(ctx context.Context, - logger logr.Logger) (*configv1alpha1.ClusterProfileList, error) { + logger logr.Logger) (*configv1beta1.ClusterProfileList, error) { logger.V(logs.LogDebug).Info("Get all ClusterProfiles") - clusterProfiles := &configv1alpha1.ClusterProfileList{} + clusterProfiles := &configv1beta1.ClusterProfileList{} err := a.client.List(ctx, clusterProfiles) return clusterProfiles, err } diff --git a/internal/utils/clusterprofiles_test.go b/internal/utils/clusterprofiles_test.go index fdbc8687..501c6d1f 100644 --- a/internal/utils/clusterprofiles_test.go +++ b/internal/utils/clusterprofiles_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -38,17 +38,17 @@ var _ = Describe("ClusterProfile", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - clusterProfile := &configv1alpha1.ClusterProfile{ + clusterProfile := &configv1beta1.ClusterProfile{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: configv1alpha1.Spec{ + Spec: configv1beta1.Spec{ ClusterSelector: libsveltosv1beta1.Selector{ LabelSelector: metav1.LabelSelector{ MatchLabels: map[string]string{"zone": "west"}, }, }, - SyncMode: configv1alpha1.SyncModeContinuous, + SyncMode: configv1beta1.SyncModeContinuous, }, } initObjects = append(initObjects, clusterProfile) diff --git a/internal/utils/clusterreports.go b/internal/utils/clusterreports.go index 3796e7d6..dabadb0f 100644 --- a/internal/utils/clusterreports.go +++ b/internal/utils/clusterreports.go @@ -23,26 +23,26 @@ import ( "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListClusterReports returns all current ClusterReports in a namespace (if specified) func (a *k8sAccess) ListClusterReports(ctx context.Context, namespace string, - logger logr.Logger) (*configv1alpha1.ClusterReportList, error) { + logger logr.Logger) (*configv1beta1.ClusterReportList, error) { listOptions := []client.ListOption{ client.InNamespace(namespace), } logger.V(logs.LogDebug).Info("Get all ClusterReports") - clusterReports := &configv1alpha1.ClusterReportList{} + clusterReports := &configv1beta1.ClusterReportList{} err := a.client.List(ctx, clusterReports, listOptions...) return clusterReports, err } // SortClusterReports sorts ClusterReports by Cluster Namespace/Name -func (a *k8sAccess) SortClusterReports(clusterReports []configv1alpha1.ClusterReport) []configv1alpha1.ClusterReport { +func (a *k8sAccess) SortClusterReports(clusterReports []configv1beta1.ClusterReport) []configv1beta1.ClusterReport { sort.Slice(clusterReports, func(i, j int) bool { if clusterReports[i].Spec.ClusterNamespace == clusterReports[j].Spec.ClusterNamespace { return clusterReports[i].Spec.ClusterName < clusterReports[j].Spec.ClusterName diff --git a/internal/utils/clusterreports_test.go b/internal/utils/clusterreports_test.go index a7b37cf7..c05d9dbb 100644 --- a/internal/utils/clusterreports_test.go +++ b/internal/utils/clusterreports_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -38,7 +38,7 @@ var _ = Describe("ClusterReport", func() { initObjects := []client.Object{} for i := 0; i < 5; i++ { - clusterReport := &configv1alpha1.ClusterReport{ + clusterReport := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), @@ -47,7 +47,7 @@ var _ = Describe("ClusterReport", func() { initObjects = append(initObjects, clusterReport) } - clusterReport := &configv1alpha1.ClusterReport{ + clusterReport := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), @@ -72,29 +72,29 @@ var _ = Describe("ClusterReport", func() { }) It("SortClusterReports sorts clusterReports by Cluster Namespace/Name", func() { - clusterReports := []configv1alpha1.ClusterReport{} + clusterReports := []configv1beta1.ClusterReport{} firstNamespace := "namespace-a" secondNamespace := "namespace-b" - clusterReport := &configv1alpha1.ClusterReport{ + clusterReport := &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterName: randomString(), ClusterNamespace: secondNamespace, }, } clusterReports = append(clusterReports, *clusterReport) - clusterReport = &configv1alpha1.ClusterReport{ + clusterReport = &configv1beta1.ClusterReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: configv1alpha1.ClusterReportSpec{ + Spec: configv1beta1.ClusterReportSpec{ ClusterName: randomString(), ClusterNamespace: firstNamespace, }, diff --git a/internal/utils/debuggingconfigurations.go b/internal/utils/debuggingconfigurations.go index c105545d..4de7ebae 100644 --- a/internal/utils/debuggingconfigurations.go +++ b/internal/utils/debuggingconfigurations.go @@ -17,65 +17,100 @@ limitations under the License. package utils import ( - "context" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/client" - - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + "context" + "sigs.k8s.io/controller-runtime/pkg/client" + "k8s.io/klog/v2" + apierrors "k8s.io/apimachinery/pkg/api/errors" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" + clusterproxy "github.com/projectsveltos/libsveltos/lib/clusterproxy" ) const ( defaultInstanceName = "default" ) -// GetDebuggingConfiguration gets default DebuggingConfiguration +// GetDebuggingConfiguration gets default DebuggingConfiguration in the specified namespace and cluster func (a *k8sAccess) GetDebuggingConfiguration( - ctx context.Context, -) (*libsveltosv1beta1.DebuggingConfiguration, error) { - - req := &libsveltosv1beta1.DebuggingConfiguration{} - - reqName := client.ObjectKey{ - Name: defaultInstanceName, - } - - if err := a.client.Get(ctx, reqName, req); err != nil { - return nil, err - } - - return req, nil + ctx context.Context, + namespace string, + clusterName string, + clusterType string, +) (*libsveltosv1alpha1.DebuggingConfiguration, error) { + + req := &libsveltosv1alpha1.DebuggingConfiguration{} + var c client.Client + var err error + logger := klog.FromContext(ctx) + + if namespace == "" && clusterName == "" && clusterType == "" { + c = a.client + } else { + c, err = clusterproxy.GetKubernetesClient(ctx, a.client, namespace, clusterName, "", "", libsveltosv1alpha1.ClusterType(clusterType), logger) + if err != nil { + return nil, err + } + } + + reqName := client.ObjectKey{ + Name: defaultInstanceName, + Namespace: namespace, + } + + if err := c.Get(ctx, reqName, req); err != nil { + return nil, err + } + + return req, nil } -// UpdateDebuggingConfiguration creates, if not existing already, default DebuggingConfiguration. Otherwise +// UpdateDebuggingConfiguration creates, if not existing already, default DebuggingConfiguration in the specified namespace and cluster. Otherwise // updates it. func (a *k8sAccess) UpdateDebuggingConfiguration( - ctx context.Context, - dc *libsveltosv1beta1.DebuggingConfiguration, + ctx context.Context, + dc *libsveltosv1alpha1.DebuggingConfiguration, + namespace string, + clusterName string, + clusterType string, ) error { - reqName := client.ObjectKey{ - Name: defaultInstanceName, - } - - tmp := &libsveltosv1beta1.DebuggingConfiguration{} - - err := a.client.Get(ctx, reqName, tmp) - if err != nil { - if apierrors.IsNotFound(err) { - err = a.client.Create(ctx, dc) - if err != nil { - return err - } - } else { - return err - } - } - - err = a.client.Update(ctx, dc) - if err != nil { - return err - } - - return nil + var c client.Client + var err error + logger := klog.FromContext(ctx) + + if namespace == "" && clusterName == "" && clusterType == "" { + c = a.client + } else { + c, err = clusterproxy.GetKubernetesClient(ctx, a.client, namespace, clusterName, "", "", libsveltosv1alpha1.ClusterType(clusterType), logger) + if err != nil { + return err + } + } + + reqName := client.ObjectKey{ + Name: defaultInstanceName, + Namespace: namespace, + } + + tmp := &libsveltosv1alpha1.DebuggingConfiguration{} + + err = c.Get(ctx, reqName, tmp) + if err != nil { + if apierrors.IsNotFound(err) { + dc.Namespace = namespace + err = c.Create(ctx, dc) + if err != nil { + return err + } + } else { + return err + } + } + + dc.Namespace = namespace + err = c.Update(ctx, dc) + if err != nil { + return err + } + + return nil } diff --git a/internal/utils/debuggingconfigurations_test.go b/internal/utils/debuggingconfigurations_test.go index f42c1f01..16a1caee 100644 --- a/internal/utils/debuggingconfigurations_test.go +++ b/internal/utils/debuggingconfigurations_test.go @@ -28,13 +28,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) var _ = Describe("DebuggingConfigurations", func() { + It("GetDebuggingConfiguration returns the default instance", func() { - dc := &libsveltosv1beta1.DebuggingConfiguration{ + dc := &libsveltosv1alpha1.DebuggingConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: utils.DefaultInstanceName, }, @@ -46,14 +47,14 @@ var _ = Describe("DebuggingConfigurations", func() { c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build() k8sAccess := utils.GetK8sAccess(scheme, c) - currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO()) + currentDC, err := k8sAccess.GetDebuggingConfiguration(context.TODO(), "", "", "") Expect(err).To(BeNil()) Expect(currentDC).ToNot(BeNil()) Expect(currentDC.Name).To(Equal(dc.Name)) }) It("UpdateDebuggingConfiguration updates default DebuggingConfiguration instance", func() { - dc := &libsveltosv1beta1.DebuggingConfiguration{ + dc := &libsveltosv1alpha1.DebuggingConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: utils.DefaultInstanceName, }, @@ -64,16 +65,17 @@ var _ = Describe("DebuggingConfigurations", func() { c := fake.NewClientBuilder().WithScheme(scheme).Build() k8sAccess := utils.GetK8sAccess(scheme, c) - Expect(k8sAccess.UpdateDebuggingConfiguration(context.TODO(), dc)).To(Succeed()) + Expect(k8sAccess.UpdateDebuggingConfiguration(context.TODO(), dc, "", "", "")).To(Succeed()) - currentDC := &libsveltosv1beta1.DebuggingConfiguration{} + currentDC := &libsveltosv1alpha1.DebuggingConfiguration{} Expect(c.Get(context.TODO(), types.NamespacedName{Name: utils.DefaultInstanceName}, currentDC)).To(Succeed()) - currentDC.Spec.Configuration = []libsveltosv1beta1.ComponentConfiguration{ - {Component: libsveltosv1beta1.ComponentClassifier, LogLevel: libsveltosv1beta1.LogLevelDebug}, + currentDC.Spec.Configuration = []libsveltosv1alpha1.ComponentConfiguration{ + {Component: libsveltosv1alpha1.ComponentClassifier, LogLevel: libsveltosv1alpha1.LogLevelDebug}, } - Expect(k8sAccess.UpdateDebuggingConfiguration(context.TODO(), currentDC)).To(Succeed()) + Expect(k8sAccess.UpdateDebuggingConfiguration(context.TODO(), currentDC, "", "", "")).To(Succeed()) Expect(c.Get(context.TODO(), types.NamespacedName{Name: utils.DefaultInstanceName}, currentDC)).To(Succeed()) Expect(len(currentDC.Spec.Configuration)).To(Equal(1)) }) }) + diff --git a/internal/utils/eventsources.go b/internal/utils/eventsources.go index 841e2c3f..d4909c68 100644 --- a/internal/utils/eventsources.go +++ b/internal/utils/eventsources.go @@ -21,16 +21,16 @@ import ( "github.com/go-logr/logr" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListEventSources returns all current EventSources func (a *k8sAccess) ListEventSources(ctx context.Context, - logger logr.Logger) (*libsveltosv1beta1.EventSourceList, error) { + logger logr.Logger) (*libsveltosv1alpha1.EventSourceList, error) { logger.V(logs.LogDebug).Info("Get all EventSources") - eventSources := &libsveltosv1beta1.EventSourceList{} + eventSources := &libsveltosv1alpha1.EventSourceList{} err := a.client.List(ctx, eventSources) return eventSources, err } diff --git a/internal/utils/eventsources_test.go b/internal/utils/eventsources_test.go index b5409d3d..2ee599fa 100644 --- a/internal/utils/eventsources_test.go +++ b/internal/utils/eventsources_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -37,12 +37,12 @@ var _ = Describe("EventSource", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - es := &libsveltosv1beta1.EventSource{ + es := &libsveltosv1alpha1.EventSource{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: libsveltosv1beta1.EventSourceSpec{ - ResourceSelectors: []libsveltosv1beta1.ResourceSelector{ + Spec: libsveltosv1alpha1.EventSourceSpec{ + ResourceSelectors: []libsveltosv1alpha1.ResourceSelector{ { Group: randomString(), Version: randomString(), diff --git a/internal/utils/eventtriggers.go b/internal/utils/eventtriggers.go index 9f6a4cc1..430e20fe 100644 --- a/internal/utils/eventtriggers.go +++ b/internal/utils/eventtriggers.go @@ -21,16 +21,16 @@ import ( "github.com/go-logr/logr" - eventv1beta1 "github.com/projectsveltos/event-manager/api/v1beta1" + eventv1alpha1 "github.com/projectsveltos/event-manager/api/v1alpha1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListEventTriggers returns all current EventTriggers func (a *k8sAccess) ListEventTriggers(ctx context.Context, - logger logr.Logger) (*eventv1beta1.EventTriggerList, error) { + logger logr.Logger) (*eventv1alpha1.EventTriggerList, error) { logger.V(logs.LogDebug).Info("Get all EventTriggers") - eventTriggers := &eventv1beta1.EventTriggerList{} + eventTriggers := &eventv1alpha1.EventTriggerList{} err := a.client.List(ctx, eventTriggers) return eventTriggers, err } diff --git a/internal/utils/eventtriggers_test.go b/internal/utils/eventtriggers_test.go index 8f32df5b..9430f6c9 100644 --- a/internal/utils/eventtriggers_test.go +++ b/internal/utils/eventtriggers_test.go @@ -28,8 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - eventv1beta1 "github.com/projectsveltos/event-manager/api/v1beta1" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + eventv1alpha1 "github.com/projectsveltos/event-manager/api/v1alpha1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -38,17 +38,13 @@ var _ = Describe("EventTriggers", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - resource := &eventv1beta1.EventTrigger{ + resource := &eventv1alpha1.EventTrigger{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: eventv1beta1.EventTriggerSpec{ - EventSourceName: randomString(), - SourceClusterSelector: libsveltosv1beta1.Selector{ - LabelSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{randomString(): randomString()}, - }, - }, + Spec: eventv1alpha1.EventTriggerSpec{ + EventSourceName: randomString(), + SourceClusterSelector: libsveltosv1alpha1.Selector(randomString()), }, } initObjects = append(initObjects, resource) diff --git a/internal/utils/healthcheckreports.go b/internal/utils/healthcheckreports.go index 3cf05acc..531b0e39 100644 --- a/internal/utils/healthcheckreports.go +++ b/internal/utils/healthcheckreports.go @@ -22,13 +22,13 @@ import ( "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListHealthCheckReports returns all current HealthCheckReports func (a *k8sAccess) ListHealthCheckReports(ctx context.Context, namespace string, - logger logr.Logger) (*libsveltosv1beta1.HealthCheckReportList, error) { + logger logr.Logger) (*libsveltosv1alpha1.HealthCheckReportList, error) { logger.V(logs.LogDebug).Info("Get all HealthCheckReports") @@ -39,7 +39,7 @@ func (a *k8sAccess) ListHealthCheckReports(ctx context.Context, namespace string } } - healthCheckReports := &libsveltosv1beta1.HealthCheckReportList{} + healthCheckReports := &libsveltosv1alpha1.HealthCheckReportList{} err := a.client.List(ctx, healthCheckReports, listOptions...) return healthCheckReports, err } diff --git a/internal/utils/healthcheckreports_test.go b/internal/utils/healthcheckreports_test.go index e9513344..334b08cc 100644 --- a/internal/utils/healthcheckreports_test.go +++ b/internal/utils/healthcheckreports_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -37,15 +37,15 @@ var _ = Describe("HealthCheckReports", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - hcr := &libsveltosv1beta1.HealthCheckReport{ + hcr := &libsveltosv1alpha1.HealthCheckReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: libsveltosv1beta1.HealthCheckReportSpec{ + Spec: libsveltosv1alpha1.HealthCheckReportSpec{ ClusterNamespace: randomString(), ClusterName: randomString(), - ClusterType: libsveltosv1beta1.ClusterTypeSveltos, + ClusterType: libsveltosv1alpha1.ClusterTypeSveltos, HealthCheckName: randomString(), }, } @@ -67,30 +67,30 @@ var _ = Describe("HealthCheckReports", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - hcr := &libsveltosv1beta1.HealthCheckReport{ + hcr := &libsveltosv1alpha1.HealthCheckReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: libsveltosv1beta1.HealthCheckReportSpec{ + Spec: libsveltosv1alpha1.HealthCheckReportSpec{ ClusterNamespace: randomString(), ClusterName: randomString(), - ClusterType: libsveltosv1beta1.ClusterTypeSveltos, + ClusterType: libsveltosv1alpha1.ClusterTypeSveltos, HealthCheckName: randomString(), }, } initObjects = append(initObjects, hcr) } - hcr := &libsveltosv1beta1.HealthCheckReport{ + hcr := &libsveltosv1alpha1.HealthCheckReport{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), Namespace: randomString(), }, - Spec: libsveltosv1beta1.HealthCheckReportSpec{ + Spec: libsveltosv1alpha1.HealthCheckReportSpec{ ClusterNamespace: randomString(), ClusterName: randomString(), - ClusterType: libsveltosv1beta1.ClusterTypeSveltos, + ClusterType: libsveltosv1alpha1.ClusterTypeSveltos, HealthCheckName: randomString(), }, } diff --git a/internal/utils/healthchecks.go b/internal/utils/healthchecks.go index 94096834..a3bfc403 100644 --- a/internal/utils/healthchecks.go +++ b/internal/utils/healthchecks.go @@ -21,16 +21,16 @@ import ( "github.com/go-logr/logr" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListHealthChecks returns all current HealthChecks func (a *k8sAccess) ListHealthChecks(ctx context.Context, - logger logr.Logger) (*libsveltosv1beta1.HealthCheckList, error) { + logger logr.Logger) (*libsveltosv1alpha1.HealthCheckList, error) { logger.V(logs.LogDebug).Info("Get all HealthChecks") - healthCheck := &libsveltosv1beta1.HealthCheckList{} + healthCheck := &libsveltosv1alpha1.HealthCheckList{} err := a.client.List(ctx, healthCheck) return healthCheck, err } diff --git a/internal/utils/healthchecks_test.go b/internal/utils/healthchecks_test.go index d2bf2c72..846a902d 100644 --- a/internal/utils/healthchecks_test.go +++ b/internal/utils/healthchecks_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" + libsveltosv1alpha1 "github.com/projectsveltos/libsveltos/api/v1alpha1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -37,12 +37,12 @@ var _ = Describe("HealthCheck", func() { initObjects := []client.Object{} for i := 0; i < 10; i++ { - hc := &libsveltosv1beta1.HealthCheck{ + hc := &libsveltosv1alpha1.HealthCheck{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: libsveltosv1beta1.HealthCheckSpec{ - ResourceSelectors: []libsveltosv1beta1.ResourceSelector{ + Spec: libsveltosv1alpha1.HealthCheckSpec{ + ResourceSelectors: []libsveltosv1alpha1.ResourceSelector{ { Group: randomString(), Version: randomString(), diff --git a/internal/utils/profiles.go b/internal/utils/profiles.go index 3795a580..201cd8eb 100644 --- a/internal/utils/profiles.go +++ b/internal/utils/profiles.go @@ -21,16 +21,16 @@ import ( "github.com/go-logr/logr" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" logs "github.com/projectsveltos/libsveltos/lib/logsettings" ) // ListClusterProfiles returns all current Profiles func (a *k8sAccess) ListProfiles(ctx context.Context, - logger logr.Logger) (*configv1alpha1.ProfileList, error) { + logger logr.Logger) (*configv1beta1.ProfileList, error) { logger.V(logs.LogDebug).Info("Get all Profiles") - profiles := &configv1alpha1.ProfileList{} + profiles := &configv1beta1.ProfileList{} err := a.client.List(ctx, profiles) return profiles, err } diff --git a/internal/utils/profiles_test.go b/internal/utils/profiles_test.go index d1f1fc99..6822b789 100644 --- a/internal/utils/profiles_test.go +++ b/internal/utils/profiles_test.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - configv1alpha1 "github.com/projectsveltos/addon-controller/api/v1beta1" + configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1" libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1" "github.com/projectsveltos/sveltosctl/internal/utils" ) @@ -38,17 +38,17 @@ var _ = Describe("Profile", func() { initObjects := []client.Object{} for i := 0; i < 15; i++ { - profile := &configv1alpha1.Profile{ + profile := &configv1beta1.Profile{ ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: configv1alpha1.Spec{ + Spec: configv1beta1.Spec{ ClusterSelector: libsveltosv1beta1.Selector{ LabelSelector: metav1.LabelSelector{ MatchLabels: map[string]string{"zone": "west"}, }, }, - SyncMode: configv1alpha1.SyncModeContinuous, + SyncMode: configv1beta1.SyncModeContinuous, }, } initObjects = append(initObjects, profile) diff --git a/internal/utils/rolerequests_test.go b/internal/utils/rolerequests_test.go index 9dbb9f8d..ab946214 100644 --- a/internal/utils/rolerequests_test.go +++ b/internal/utils/rolerequests_test.go @@ -41,14 +41,10 @@ var _ = Describe("RoleRequest", func() { ObjectMeta: metav1.ObjectMeta{ Name: randomString(), }, - Spec: libsveltosv1beta1.RoleRequestSpec{ + Spec: libsveltosv1alpha1.RoleRequestSpec{ ServiceAccountNamespace: randomString(), ServiceAccountName: randomString(), - ClusterSelector: libsveltosv1beta1.Selector{ - LabelSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{"zone": "east"}, - }, - }, + ClusterSelector: libsveltosv1alpha1.Selector("zone:east"), }, } initObjects = append(initObjects, rr) diff --git a/k8s/sveltosctl.yaml b/k8s/sveltosctl.yaml index 1b0f43ed..b7faf435 100644 --- a/k8s/sveltosctl.yaml +++ b/k8s/sveltosctl.yaml @@ -134,7 +134,6 @@ rules: - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots - - techsupports verbs: - get - list @@ -143,14 +142,12 @@ rules: - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots/finalizers - - techsupports/finalizers verbs: - patch - update - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots/status - - techsupports/status verbs: - '*' - apiGroups: ["cluster.x-k8s.io"] diff --git a/manifest/manifest.yaml b/manifest/manifest.yaml index 66bd828b..1d84111b 100644 --- a/manifest/manifest.yaml +++ b/manifest/manifest.yaml @@ -134,7 +134,6 @@ rules: - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots - - techsupports verbs: - get - list @@ -143,14 +142,12 @@ rules: - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots/finalizers - - techsupports/finalizers verbs: - patch - update - apiGroups: ["utils.projectsveltos.io"] resources: - snapshots/status - - techsupports/status verbs: - '*' - apiGroups: ["cluster.x-k8s.io"] @@ -196,9 +193,20 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.5 + cert-manager.io/inject-ca-from: projectsveltos/projectsveltos-serving-cert + controller-gen.kubebuilder.io/version: v0.17.0 name: snapshots.utils.projectsveltos.io spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: webhook-service + namespace: projectsveltos + path: /convert + conversionReviewVersions: + - v1 group: utils.projectsveltos.io names: kind: Snapshot @@ -208,89 +216,6 @@ spec: scope: Cluster versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Snapshot is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: SnapshotSpec defines the desired state of Snapshot - properties: - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where snapshots will be stored. - It must be an existing directory. - Snapshots will be stored in this directory in a subdirectory named - with Snapshot instance name. - type: string - successfulSnapshotLimit: - description: |- - The number of successful finished snapshots to retains. - If specified, only SuccessfulSnapshotLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - required: - - schedule - - storage - type: object - status: - description: SnapshotStatus defines the observed state of Snapshot - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last snapshot collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: false - subresources: - status: {} - - name: v1beta1 schema: openAPIV3Schema: description: Snapshot is the Schema for the snapshot API @@ -374,532 +299,3 @@ spec: subresources: status: {} --- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: projectsveltos/projectsveltos-serving-cert - controller-gen.kubebuilder.io/version: v0.16.5 - name: techsupports.utils.projectsveltos.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: webhook-service - namespace: projectsveltos - path: /convert - conversionReviewVersions: - - v1 - group: utils.projectsveltos.io - names: - kind: Techsupport - listKind: TechsupportList - plural: techsupports - singular: techsupport - scope: Cluster - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Techsupport is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: TechsupportSpec defines the desired state of Techsupport - properties: - clusterSelector: - description: ClusterSelector identifies clusters to collect techsupport - from. - type: string - logs: - description: Logs indicates what pods' log to collect - items: - description: LogFilter allows to select which logs to collect - properties: - labelFilters: - description: LabelFilters allows to filter pods based on current - labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: Namespace of the pods deployed in the Cluster. - type: string - sinceSeconds: - description: |- - A relative time in seconds before the current time from which to collect logs. - If this value precedes the time a pod was started, only logs since the pod start will be returned. - If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - format: int64 - type: integer - type: object - type: array - resources: - description: Resources indicates what resorces to collect - items: - description: Resource indicates the type of resources to collect. - properties: - group: - description: Group of the resource deployed in the Cluster. - type: string - kind: - description: Kind of the resource deployed in the Cluster. - minLength: 1 - type: string - labelFilters: - description: LabelFilters allows to filter resources based on - current labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: |- - Namespace of the resource deployed in the Cluster. - Empty for resources scoped at cluster level. - type: string - version: - description: Version of the resource deployed in the Cluster. - type: string - required: - - group - - kind - - version - type: object - type: array - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where techsupports will be stored. - It must be an existing directory. - Techsupports will be stored in this directory in a subdirectory named - with Techsupport instance name. - type: string - successfulTechsupportLimit: - description: |- - The number of successful finished techsupport to retains. - If specified, only SuccessfulTechsupportLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - tar: - default: false - description: If set denerates a tar file with all collected logs/resources - type: boolean - required: - - clusterSelector - - schedule - - storage - type: object - status: - description: TechsupportStatus defines the observed state of Techsupport - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last techsupport collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - machingClusters: - description: |- - MatchingClusterRefs reference all the clusters currently matching - Techsupport - items: - description: ObjectReference contains enough information to let - you inspect or modify the referred object. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: |- - If referring to a piece of an object instead of an entire object, this string - should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to the name of the container that triggered - 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. - type: string - kind: - description: |- - Kind of the referent. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - namespace: - description: |- - Namespace of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ - type: string - resourceVersion: - description: |- - Specific resourceVersion to which this reference is made, if any. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency - type: string - uid: - description: |- - UID of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids - type: string - type: object - x-kubernetes-map-type: atomic - type: array - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: false - subresources: - status: {} - - name: v1beta1 - schema: - openAPIV3Schema: - description: Techsupport is the Schema for the snapshot API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: TechsupportSpec defines the desired state of Techsupport - properties: - clusterSelector: - description: ClusterSelector identifies clusters to collect techsupport - from. - properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. - The requirements are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that the selector applies - to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - x-kubernetes-list-type: atomic - required: - - key - - operator - type: object - type: array - x-kubernetes-list-type: atomic - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - logs: - description: Logs indicates what pods' log to collect - items: - description: LogFilter allows to select which logs to collect - properties: - labelFilters: - description: LabelFilters allows to filter pods based on current - labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: Namespace of the pods deployed in the Cluster. - type: string - sinceSeconds: - description: |- - A relative time in seconds before the current time from which to collect logs. - If this value precedes the time a pod was started, only logs since the pod start will be returned. - If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified. - format: int64 - type: integer - type: object - type: array - resources: - description: Resources indicates what resorces to collect - items: - description: Resource indicates the type of resources to collect. - properties: - group: - description: Group of the resource deployed in the Cluster. - type: string - kind: - description: Kind of the resource deployed in the Cluster. - minLength: 1 - type: string - labelFilters: - description: LabelFilters allows to filter resources based on - current labels. - items: - properties: - key: - description: Key is the label key - type: string - operation: - description: Operation is the comparison operation - enum: - - Equal - - Different - type: string - value: - description: Value is the label value - type: string - required: - - key - - operation - - value - type: object - type: array - namespace: - description: |- - Namespace of the resource deployed in the Cluster. - Empty for resources scoped at cluster level. - type: string - version: - description: Version of the resource deployed in the Cluster. - type: string - required: - - group - - kind - - version - type: object - type: array - schedule: - description: Schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: |- - Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - storage: - description: |- - Storage represents directory where techsupports will be stored. - It must be an existing directory. - Techsupports will be stored in this directory in a subdirectory named - with Techsupport instance name. - type: string - successfulTechsupportLimit: - description: |- - The number of successful finished techsupport to retains. - If specified, only SuccessfulTechsupportLimit will be retained. Once such - number is reached, for any new successful snapshots, the oldest one is - deleted. - format: int32 - type: integer - tar: - default: false - description: If set denerates a tar file with all collected logs/resources - type: boolean - required: - - clusterSelector - - schedule - - storage - type: object - status: - description: TechsupportStatus defines the observed state of Techsupport - properties: - failureMessage: - description: |- - FailureMessage provides more information about the error, if - any occurred - type: string - lastRunStatus: - description: Status indicates what happened to last techsupport collection. - enum: - - Collected - - InProgress - - Failed - type: string - lastRunTime: - description: Information when was the last time a snapshot was successfully - scheduled. - format: date-time - type: string - machingClusters: - description: |- - MatchingClusterRefs reference all the clusters currently matching - Techsupport - items: - description: ObjectReference contains enough information to let - you inspect or modify the referred object. - properties: - apiVersion: - description: API version of the referent. - type: string - fieldPath: - description: |- - If referring to a piece of an object instead of an entire object, this string - should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. - For example, if the object reference is to a container within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to the name of the container that triggered - 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. - type: string - kind: - description: |- - Kind of the referent. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - namespace: - description: |- - Namespace of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ - type: string - resourceVersion: - description: |- - Specific resourceVersion to which this reference is made, if any. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency - type: string - uid: - description: |- - UID of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids - type: string - type: object - x-kubernetes-map-type: atomic - type: array - nextScheduleTime: - description: Information when next snapshot is scheduled - format: date-time - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {}