From 175d275688c62a67a282a44487708afc5c2e8e27 Mon Sep 17 00:00:00 2001 From: SRIHARSHA ROUTHU <69401277+telnet-harsha@users.noreply.github.com> Date: Mon, 13 Mar 2023 17:29:03 +0530 Subject: [PATCH] =?UTF-8?q?[=20Razorpay=20imagepullsecret-patcher=20]=20Tr?= =?UTF-8?q?ivy,=20EOL=20Languages,=20Dependabot=E2=80=A6=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ Razorpay imagepullsecret-patcher ] Trivy, EOL Languages, Dependabot Fixes --- pkg/crd/crd.go | 57 ++++++++++++++++++++++++++++++++++++++------- pkg/crd/deepcopy.go | 2 +- pkg/crd/types.go | 6 ++--- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/pkg/crd/crd.go b/pkg/crd/crd.go index de5cda1..89d45f9 100644 --- a/pkg/crd/crd.go +++ b/pkg/crd/crd.go @@ -4,7 +4,7 @@ import ( "context" "reflect" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,22 +17,63 @@ import ( ) func EnsureResource(client apiextensionsclient.Interface) error { - crd := &apiextensionsv1beta1.CustomResourceDefinition{ + crd := &v1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "sqsautoscalers.aws.uswitch.com", }, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "aws.uswitch.com", - Version: "v1", - Scope: apiextensionsv1beta1.NamespaceScoped, - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ + Spec: v1.CustomResourceDefinitionSpec{ + Group: "aws.uswitch.com", + Scope: v1.NamespaceScoped, + Versions: []v1.CustomResourceDefinitionVersion{ + { + Name: "v1", + Served: true, + Storage: true, + Deprecated: false, + Schema: &v1.CustomResourceValidation{ + OpenAPIV3Schema: &v1.JSONSchemaProps{ + Description: "openapi3.0 schema for validation & pruning", + Type: "object", + Required: []string{ + "deployment", + "maxPods", + "minPods", + "queue", + "scaleDown", + "scaleUp", + }, + }, + }, + }, + { + Name: "v1beta1", + Served: true, + Storage: false, + Deprecated: true, + Schema: &v1.CustomResourceValidation{ + OpenAPIV3Schema: &v1.JSONSchemaProps{ + Description: "openapi3.0 schema for validation & pruning", + Type: "object", + Required: []string{ + "deployment", + "maxPods", + "minPods", + "queue", + "scaleDown", + "scaleUp", + }, + }, + }, + }, + }, + Names: v1.CustomResourceDefinitionNames{ Singular: "sqsautoscaler", Plural: "sqsautoscalers", Kind: reflect.TypeOf(SqsAutoScaler{}).Name(), }, }, } - _, err := client.ApiextensionsV1beta1().CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{}) + _, err := client.ApiextensionsV1().CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{}) if err != nil && apierrors.IsAlreadyExists(err) { return nil } diff --git a/pkg/crd/deepcopy.go b/pkg/crd/deepcopy.go index cd795e8..e22d534 100644 --- a/pkg/crd/deepcopy.go +++ b/pkg/crd/deepcopy.go @@ -44,7 +44,7 @@ func (in *SqsAutoScaler) DeepCopyObject() runtime.Object { func (in *SqsAutoScalerList) DeepCopyInto(out *SqsAutoScalerList) { *out = *in out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]SqsAutoScaler, len(*in)) diff --git a/pkg/crd/types.go b/pkg/crd/types.go index e56175e..2a127c3 100644 --- a/pkg/crd/types.go +++ b/pkg/crd/types.go @@ -11,9 +11,9 @@ type SqsAutoScaler struct { } type SqsAutoScalerList struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - Items []SqsAutoScaler `json:"items"` + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + Items []SqsAutoScaler `json:"items"` } type AutoScalerSpec struct {