From d1a6abc76ef0fa3d301892e10d261da8a6140229 Mon Sep 17 00:00:00 2001 From: Ram Lavi Date: Wed, 2 Sep 2020 19:22:01 +0300 Subject: [PATCH] bump CustomResourceDefinition to v1 in order to run "kubectl explain crd" we need to bump CustomResourceDefinition to v1. Part of this change is to move the deprecated spec.validation field to be per version in spec.versions[].schema Signed-off-by: Ram Lavi --- pkg/components/components.go | 66 +++++++++---------- .../manifest-templator/manifest-templator.go | 4 +- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/pkg/components/components.go b/pkg/components/components.go index 5497783ffc..8e192e65c5 100644 --- a/pkg/components/components.go +++ b/pkg/components/components.go @@ -7,7 +7,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" - extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" cnao "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/shared" @@ -368,63 +368,61 @@ func GetClusterRole() *rbacv1.ClusterRole { return role } -func GetCrd() *extv1beta1.CustomResourceDefinition { - crd := &extv1beta1.CustomResourceDefinition{ +func GetCrd() *extv1.CustomResourceDefinition { + validationSchema := &extv1.CustomResourceValidation{ + OpenAPIV3Schema: &extv1.JSONSchemaProps{ + Type: "object", + Properties: map[string]extv1.JSONSchemaProps{ + "apiVersion": extv1.JSONSchemaProps{ + Type: "string", + }, + "kind": extv1.JSONSchemaProps{ + Type: "string", + }, + "metadata": extv1.JSONSchemaProps{ + Type: "object", + }, + "spec": extv1.JSONSchemaProps{ + Type: "object", + }, + "status": extv1.JSONSchemaProps{ + Type: "object", + }, + }, + }, + } + + crd := &extv1.CustomResourceDefinition{ TypeMeta: metav1.TypeMeta{ - APIVersion: "apiextensions.k8s.io/v1beta1", + APIVersion: "apiextensions.k8s.io/v1", Kind: "CustomResourceDefinition", }, ObjectMeta: metav1.ObjectMeta{ Name: "networkaddonsconfigs.networkaddonsoperator.network.kubevirt.io", }, - Spec: extv1beta1.CustomResourceDefinitionSpec{ + Spec: extv1.CustomResourceDefinitionSpec{ Group: "networkaddonsoperator.network.kubevirt.io", Scope: "Cluster", - Subresources: &extv1beta1.CustomResourceSubresources{ - Status: &extv1beta1.CustomResourceSubresourceStatus{}, - }, - - Names: extv1beta1.CustomResourceDefinitionNames{ + Names: extv1.CustomResourceDefinitionNames{ Plural: "networkaddonsconfigs", Singular: "networkaddonsconfig", Kind: "NetworkAddonsConfig", ListKind: "NetworkAddonsConfigList", }, - Versions: []extv1beta1.CustomResourceDefinitionVersion{ + Versions: []extv1.CustomResourceDefinitionVersion{ { Name: "v1", Served: true, Storage: true, + Schema: validationSchema, }, { Name: "v1alpha1", Served: true, Storage: false, - }, - }, - - Validation: &extv1beta1.CustomResourceValidation{ - OpenAPIV3Schema: &extv1beta1.JSONSchemaProps{ - Type: "object", - Properties: map[string]extv1beta1.JSONSchemaProps{ - "apiVersion": extv1beta1.JSONSchemaProps{ - Type: "string", - }, - "kind": extv1beta1.JSONSchemaProps{ - Type: "string", - }, - "metadata": extv1beta1.JSONSchemaProps{ - Type: "object", - }, - "spec": extv1beta1.JSONSchemaProps{ - Type: "object", - }, - "status": extv1beta1.JSONSchemaProps{ - Type: "object", - }, - }, + Schema: validationSchema, }, }, }, diff --git a/tools/manifest-templator/manifest-templator.go b/tools/manifest-templator/manifest-templator.go index ed08df88f0..190840b720 100644 --- a/tools/manifest-templator/manifest-templator.go +++ b/tools/manifest-templator/manifest-templator.go @@ -34,7 +34,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" components "github.com/kubevirt/cluster-network-addons-operator/pkg/components" - extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) type operatorData struct { @@ -44,7 +44,7 @@ type operatorData struct { Rules string ClusterRoleString string ClusterRules string - CRD *extv1beta1.CustomResourceDefinition + CRD *extv1.CustomResourceDefinition CRDString string CRDVersion string CRString string