From 2ae59d4eb3fa36731d52c29ea4b3c558fd4fdb8a Mon Sep 17 00:00:00 2001 From: mgianluc Date: Thu, 2 Jan 2025 14:10:47 +0100 Subject: [PATCH] (feat) remove techsupport An enhanced techsupport is offered via different component --- .github/workflows/main.yaml | 4 +- Dockerfile | 2 +- Makefile | 5 +- README.md | 53 -- api/v1alpha1/techsupport_conversion.go | 92 --- api/v1alpha1/techsupport_types.go | 155 ----- api/v1alpha1/zz_generated.conversion.go | 241 -------- api/v1alpha1/zz_generated.deepcopy.go | 184 ------ api/v1beta1/techsupport_conversion.go | 20 - api/v1beta1/techsupport_types.go | 156 ----- api/v1beta1/zz_generated.deepcopy.go | 185 ------ cmd/sveltosctl/main.go | 3 - .../utils.projectsveltos.io_snapshots.yaml | 2 +- .../utils.projectsveltos.io_techsupports.yaml | 519 ----------------- config/crd/kustomization.yaml | 5 +- .../crd/patches/cainjection_in_snapshots.yaml | 2 +- .../patches/cainjection_in_techsupports.yaml | 7 - ...upports.yaml => webhook_in_snapshots.yaml} | 2 +- go.mod | 41 +- go.sum | 100 ++-- hack/tools/go.mod | 41 +- hack/tools/go.sum | 99 ++-- internal/collector/client.go | 2 +- internal/collector/client_test.go | 35 +- internal/collector/request_interface.go | 3 - internal/collector/worker.go | 3 +- internal/commands/command_suite_test.go | 7 - internal/commands/reconciler_utils.go | 187 ------ internal/commands/snapshot.go | 1 - internal/commands/techsupport.go | 80 --- internal/commands/techsupport/export_test.go | 21 - internal/commands/techsupport/list.go | 148 ----- internal/commands/techsupport/list_test.go | 105 ---- .../techsupport/techsupport_suite_test.go | 66 --- internal/commands/techsupport_reconciler.go | 460 --------------- .../commands/techsupport_reconciler_test.go | 268 --------- .../commands/techsupport_reconciler_utils.go | 425 -------------- k8s/sveltosctl.yaml | 3 - manifest/manifest.yaml | 545 +----------------- 39 files changed, 184 insertions(+), 4093 deletions(-) delete mode 100644 api/v1alpha1/techsupport_conversion.go delete mode 100644 api/v1alpha1/techsupport_types.go delete mode 100644 api/v1beta1/techsupport_conversion.go delete mode 100644 api/v1beta1/techsupport_types.go delete mode 100644 config/crd/bases/utils.projectsveltos.io_techsupports.yaml delete mode 100644 config/crd/patches/cainjection_in_techsupports.yaml rename config/crd/patches/{webhook_in_techsupports.yaml => webhook_in_snapshots.yaml} (89%) delete mode 100644 internal/commands/techsupport.go delete mode 100644 internal/commands/techsupport/export_test.go delete mode 100644 internal/commands/techsupport/list.go delete mode 100644 internal/commands/techsupport/list_test.go delete mode 100644 internal/commands/techsupport/techsupport_suite_test.go delete mode 100644 internal/commands/techsupport_reconciler.go delete mode 100644 internal/commands/techsupport_reconciler_test.go delete mode 100644 internal/commands/techsupport_reconciler_utils.go diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2398922c..f1540b31 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,7 +18,7 @@ jobs: - name: Set up Go 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 @@ -37,7 +37,7 @@ jobs: - name: Set up Go 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/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..563c970b 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ 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_BIN := kustomize @@ -44,7 +44,7 @@ KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5 $(KUSTOMIZE): # Build kustomize from tools folder. CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER) -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,7 +120,6 @@ 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 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..a6f05853 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 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 e8ce5032..c501bc5b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/projectsveltos/sveltosctl -go 1.22.7 +go 1.23.4 require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 @@ -9,21 +9,21 @@ require ( 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.44.0 github.com/projectsveltos/event-manager v0.44.0 github.com/projectsveltos/libsveltos v0.44.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 + k8s.io/kubectl v0.32.0 + sigs.k8s.io/cluster-api v1.9.3 sigs.k8s.io/controller-runtime v0.19.3 sigs.k8s.io/yaml v1.4.0 ) @@ -42,14 +42,12 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gobuffalo/flect v1.0.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/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 @@ -68,24 +66,21 @@ require ( 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/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.25.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.26.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/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // 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 + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect ) // Replace digest lib to master to gather access to BLAKE3. diff --git a/go.sum b/go.sum index 531c4bcb..da767a69 100644 --- a/go.sum +++ b/go.sum @@ -38,26 +38,24 @@ github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4 github.com/gobuffalo/flect v1.0.3/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/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.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -66,6 +64,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI 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/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/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/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -74,6 +74,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= +github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -91,10 +93,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 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= @@ -112,6 +114,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ= +github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s= 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= @@ -132,6 +136,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO 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/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= 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= @@ -147,16 +152,18 @@ 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/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/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/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= @@ -167,28 +174,30 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +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.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/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-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= @@ -196,39 +205,40 @@ 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.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/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/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-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= +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.3 h1:XO2GvC9OPftRst6xWCpTgBZO04S2cbp0Qqkj8bX1sPw= sigs.k8s.io/controller-runtime v0.19.3/go.mod h1:j4j87DqtsThvwTv5/Tc5NFRyyF/RF0ip4+62tbTSIUM= -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= +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/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.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +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..c2def3a9 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -1,13 +1,13 @@ 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 ( @@ -23,7 +23,7 @@ require ( github.com/gobuffalo/flect v1.0.3 // 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 +32,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/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..b58dd857 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -21,12 +21,12 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv 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= @@ -43,8 +43,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= @@ -80,10 +80,10 @@ 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= @@ -118,82 +118,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 e35acaae..a2b93a35 100644 --- a/internal/collector/client_test.go +++ b/internal/collector/client_test.go @@ -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)) }) @@ -246,7 +246,7 @@ var _ = Describe("Client", func() { }) 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)) @@ -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)) @@ -285,7 +285,7 @@ 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() @@ -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/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/reconciler_utils.go b/internal/commands/reconciler_utils.go index 567c68b8..41d8e052 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" @@ -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 @@ -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()) @@ -316,10 +214,6 @@ func handlerSnapshotMapFun(ctx context.Context, snapshot *utilsv1beta1.Snapshot) 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", @@ -428,34 +322,6 @@ func (p SnapshotPredicate) Generic(obj event.TypedGenericEvent[*utilsv1beta1.Sna 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 { - return false -} - func schedule(ctx context.Context, instance client.Object, collectionType collector.CollectionType, collectMethod collector.CollectMethod, collectionInstance collection, logger logr.Logger) (*time.Time, error) { @@ -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/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/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/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..99d55f2d 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 @@ -374,532 +382,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: {}