From 269199dbde48620422eeff6d0a8769c2948ab9f4 Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Fri, 26 Aug 2022 15:15:35 -0400 Subject: [PATCH] Create API for vsphere CSI topology configuration Update API to use latest guidelines, drop omitempty --- .../generated_openapi/zz_generated.openapi.go | 81 ++++++++++++++++++- openapi/openapi.json | 45 +++++++++++ ...0_90_cluster_csi_driver_01_config.crd.yaml | 32 ++++++++ operator/v1/types_csi_cluster_driver.go | 51 ++++++++++++ operator/v1/zz_generated.deepcopy.go | 43 ++++++++++ .../v1/zz_generated.swagger_doc_generated.go | 20 +++++ 6 files changed, 271 insertions(+), 1 deletion(-) diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index 1c47df76a6f..07fbe37da70 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -695,6 +695,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/openshift/api/operator/v1.AuthenticationList": schema_openshift_api_operator_v1_AuthenticationList(ref), "github.com/openshift/api/operator/v1.AuthenticationSpec": schema_openshift_api_operator_v1_AuthenticationSpec(ref), "github.com/openshift/api/operator/v1.AuthenticationStatus": schema_openshift_api_operator_v1_AuthenticationStatus(ref), + "github.com/openshift/api/operator/v1.CSIDriverConfigSpec": schema_openshift_api_operator_v1_CSIDriverConfigSpec(ref), "github.com/openshift/api/operator/v1.CSISnapshotController": schema_openshift_api_operator_v1_CSISnapshotController(ref), "github.com/openshift/api/operator/v1.CSISnapshotControllerList": schema_openshift_api_operator_v1_CSISnapshotControllerList(ref), "github.com/openshift/api/operator/v1.CSISnapshotControllerSpec": schema_openshift_api_operator_v1_CSISnapshotControllerSpec(ref), @@ -854,6 +855,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/openshift/api/operator/v1.SyslogLoggingDestinationParameters": schema_openshift_api_operator_v1_SyslogLoggingDestinationParameters(ref), "github.com/openshift/api/operator/v1.Upstream": schema_openshift_api_operator_v1_Upstream(ref), "github.com/openshift/api/operator/v1.UpstreamResolvers": schema_openshift_api_operator_v1_UpstreamResolvers(ref), + "github.com/openshift/api/operator/v1.VSphereCSIDriverConfigSpec": schema_openshift_api_operator_v1_VSphereCSIDriverConfigSpec(ref), "github.com/openshift/api/operator/v1alpha1.DelegatedAuthentication": schema_openshift_api_operator_v1alpha1_DelegatedAuthentication(ref), "github.com/openshift/api/operator/v1alpha1.DelegatedAuthorization": schema_openshift_api_operator_v1alpha1_DelegatedAuthorization(ref), "github.com/openshift/api/operator/v1alpha1.GenerationHistory": schema_openshift_api_operator_v1alpha1_GenerationHistory(ref), @@ -35705,6 +35707,48 @@ func schema_openshift_api_operator_v1_AuthenticationStatus(ref common.ReferenceC } } +func schema_openshift_api_operator_v1_CSIDriverConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "CSIDriverConfigSpec defines configuration spec that can be used to optionally configure a specific CSI Driver.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "driverType": { + SchemaProps: spec.SchemaProps{ + Description: "driverType indicates type of CSI driver for which the driverConfig is being applied to.\n\nValid values are:\n\n* vSphere\n\nAllows configuration of vsphere CSI driver topology.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "vSphere": { + SchemaProps: spec.SchemaProps{ + Description: "vsphere is used to configure the vsphere CSI driver.", + Ref: ref("github.com/openshift/api/operator/v1.VSphereCSIDriverConfigSpec"), + }, + }, + }, + Required: []string{"driverType"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-unions": []interface{}{ + map[string]interface{}{ + "discriminator": "driverType", + "fields-to-discriminateBy": map[string]interface{}{ + "vSphere": "VSphere", + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/openshift/api/operator/v1.VSphereCSIDriverConfigSpec"}, + } +} + func schema_openshift_api_operator_v1_CSISnapshotController(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -36344,12 +36388,19 @@ func schema_openshift_api_operator_v1_ClusterCSIDriverSpec(ref common.ReferenceC Format: "", }, }, + "driverConfig": { + SchemaProps: spec.SchemaProps{ + Description: "driverConfig can be used to specify platform specific driver configuration. When omitted, this means no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time.", + Default: map[string]interface{}{}, + Ref: ref("github.com/openshift/api/operator/v1.CSIDriverConfigSpec"), + }, + }, }, Required: []string{"managementState"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + "github.com/openshift/api/operator/v1.CSIDriverConfigSpec", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, } } @@ -43752,6 +43803,34 @@ func schema_openshift_api_operator_v1_UpstreamResolvers(ref common.ReferenceCall } } +func schema_openshift_api_operator_v1_VSphereCSIDriverConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "VSphereCSIDriverConfigSpec defines properties that can be configured for vsphere CSI driver.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "topologyCategories": { + SchemaProps: spec.SchemaProps{ + Description: "topologyCategories indicates tag categories with which vcenter resources such as hostcluster or datacenter were tagged with. If cluster Infrastructure object has a topology, values specified in Infrastructure object will be used and modifications to topologyCategories will be rejected.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + func schema_openshift_api_operator_v1alpha1_DelegatedAuthentication(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/openapi/openapi.json b/openapi/openapi.json index c597f739d97..fd43d5f5267 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -20832,6 +20832,32 @@ } } }, + "com.github.openshift.api.operator.v1.CSIDriverConfigSpec": { + "description": "CSIDriverConfigSpec defines configuration spec that can be used to optionally configure a specific CSI Driver.", + "type": "object", + "required": [ + "driverType" + ], + "properties": { + "driverType": { + "description": "driverType indicates type of CSI driver for which the driverConfig is being applied to.\n\nValid values are:\n\n* vSphere\n\nAllows configuration of vsphere CSI driver topology.", + "type": "string", + "default": "" + }, + "vSphere": { + "description": "vsphere is used to configure the vsphere CSI driver.", + "$ref": "#/definitions/com.github.openshift.api.operator.v1.VSphereCSIDriverConfigSpec" + } + }, + "x-kubernetes-unions": [ + { + "discriminator": "driverType", + "fields-to-discriminateBy": { + "vSphere": "VSphere" + } + } + ] + }, "com.github.openshift.api.operator.v1.CSISnapshotController": { "description": "CSISnapshotController provides a means to configure an operator to manage the CSI snapshots. `cluster` is the canonical name.\n\nCompatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).", "type": "object", @@ -21192,6 +21218,11 @@ "managementState" ], "properties": { + "driverConfig": { + "description": "driverConfig can be used to specify platform specific driver configuration. When omitted, this means no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time.", + "default": {}, + "$ref": "#/definitions/com.github.openshift.api.operator.v1.CSIDriverConfigSpec" + }, "logLevel": { "description": "logLevel is an intent based logging for an overall component. It does not give fine grained control, but it is a simple way to manage coarse grained logging choices that operators have to interpret for their operands.\n\nValid values are: \"Normal\", \"Debug\", \"Trace\", \"TraceAll\". Defaults to \"Normal\".", "type": "string" @@ -25657,6 +25688,20 @@ } } }, + "com.github.openshift.api.operator.v1.VSphereCSIDriverConfigSpec": { + "description": "VSphereCSIDriverConfigSpec defines properties that can be configured for vsphere CSI driver.", + "type": "object", + "properties": { + "topologyCategories": { + "description": "topologyCategories indicates tag categories with which vcenter resources such as hostcluster or datacenter were tagged with. If cluster Infrastructure object has a topology, values specified in Infrastructure object will be used and modifications to topologyCategories will be rejected.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + } + } + }, "com.github.openshift.api.operator.v1alpha1.DelegatedAuthentication": { "description": "DelegatedAuthentication allows authentication to be disabled.", "type": "object", diff --git a/operator/v1/0000_90_cluster_csi_driver_01_config.crd.yaml b/operator/v1/0000_90_cluster_csi_driver_01_config.crd.yaml index 02d7e1868ec..c045d86255e 100644 --- a/operator/v1/0000_90_cluster_csi_driver_01_config.crd.yaml +++ b/operator/v1/0000_90_cluster_csi_driver_01_config.crd.yaml @@ -58,6 +58,38 @@ spec: spec: description: spec holds user settable values for configuration properties: + driverConfig: + description: driverConfig can be used to specify platform specific + driver configuration. When omitted, this means no opinion and the + platform is left to choose reasonable defaults. These defaults are + subject to change over time. + properties: + driverType: + description: "driverType indicates type of CSI driver for which + the driverConfig is being applied to. \n Valid values are: \n + * vSphere \n Allows configuration of vsphere CSI driver topology. + \n --- Consumers should treat unknown values as a NO-OP." + enum: + - "" + - vSphere + type: string + vSphere: + description: vsphere is used to configure the vsphere CSI driver. + properties: + topologyCategories: + description: topologyCategories indicates tag categories with + which vcenter resources such as hostcluster or datacenter + were tagged with. If cluster Infrastructure object has a + topology, values specified in Infrastructure object will + be used and modifications to topologyCategories will be + rejected. + items: + type: string + type: array + type: object + required: + - driverType + type: object logLevel: default: Normal description: "logLevel is an intent based logging for an overall component. diff --git a/operator/v1/types_csi_cluster_driver.go b/operator/v1/types_csi_cluster_driver.go index f93e04659cb..b295340152c 100644 --- a/operator/v1/types_csi_cluster_driver.go +++ b/operator/v1/types_csi_cluster_driver.go @@ -96,6 +96,57 @@ type ClusterCSIDriverSpec struct { // The current default behaviour is Managed. // +optional StorageClassState StorageClassStateName `json:"storageClassState,omitempty"` + + // driverConfig can be used to specify platform specific driver configuration. + // When omitted, this means no opinion and the platform is left to choose reasonable + // defaults. These defaults are subject to change over time. + // +optional + DriverConfig CSIDriverConfigSpec `json:"driverConfig"` +} + +// CSIDriverType indicates type of CSI driver being configured. +// +kubebuilder:validation:Enum="";vSphere +type CSIDriverType string + +const ( + VSphereDriverType CSIDriverType = "vSphere" +) + +// CSIDriverConfigSpec defines configuration spec that can be +// used to optionally configure a specific CSI Driver. +// +union +type CSIDriverConfigSpec struct { + // driverType indicates type of CSI driver for which the + // driverConfig is being applied to. + // + // Valid values are: + // + // * vSphere + // + // Allows configuration of vsphere CSI driver topology. + // + // --- + // Consumers should treat unknown values as a NO-OP. + // + // +kubebuilder:validation:Required + // +unionDiscriminator + DriverType CSIDriverType `json:"driverType"` + + // vsphere is used to configure the vsphere CSI driver. + // +optional + VSphere *VSphereCSIDriverConfigSpec `json:"vSphere,omitempty"` +} + +// VSphereCSIDriverConfigSpec defines properties that +// can be configured for vsphere CSI driver. +type VSphereCSIDriverConfigSpec struct { + // topologyCategories indicates tag categories with which + // vcenter resources such as hostcluster or datacenter were tagged with. + // If cluster Infrastructure object has a topology, values specified in + // Infrastructure object will be used and modifications to topologyCategories + // will be rejected. + // +optional + TopologyCategories []string `json:"topologyCategories,omitempty"` } // ClusterCSIDriverStatus is the observed status of CSI driver operator diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index cf9c10dcb7a..0fb0e60e149 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -232,6 +232,27 @@ func (in *AuthenticationStatus) DeepCopy() *AuthenticationStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSIDriverConfigSpec) DeepCopyInto(out *CSIDriverConfigSpec) { + *out = *in + if in.VSphere != nil { + in, out := &in.VSphere, &out.VSphere + *out = new(VSphereCSIDriverConfigSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIDriverConfigSpec. +func (in *CSIDriverConfigSpec) DeepCopy() *CSIDriverConfigSpec { + if in == nil { + return nil + } + out := new(CSIDriverConfigSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CSISnapshotController) DeepCopyInto(out *CSISnapshotController) { *out = *in @@ -509,6 +530,7 @@ func (in *ClusterCSIDriverList) DeepCopyObject() runtime.Object { func (in *ClusterCSIDriverSpec) DeepCopyInto(out *ClusterCSIDriverSpec) { *out = *in in.OperatorSpec.DeepCopyInto(&out.OperatorSpec) + in.DriverConfig.DeepCopyInto(&out.DriverConfig) return } @@ -4057,3 +4079,24 @@ func (in *UpstreamResolvers) DeepCopy() *UpstreamResolvers { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSphereCSIDriverConfigSpec) DeepCopyInto(out *VSphereCSIDriverConfigSpec) { + *out = *in + if in.TopologyCategories != nil { + in, out := &in.TopologyCategories, &out.TopologyCategories + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSphereCSIDriverConfigSpec. +func (in *VSphereCSIDriverConfigSpec) DeepCopy() *VSphereCSIDriverConfigSpec { + if in == nil { + return nil + } + out := new(VSphereCSIDriverConfigSpec) + in.DeepCopyInto(out) + return out +} diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index 4569471dd85..fdc25e6a08d 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -325,6 +325,16 @@ func (StatuspageProvider) SwaggerDoc() map[string]string { return map_StatuspageProvider } +var map_CSIDriverConfigSpec = map[string]string{ + "": "CSIDriverConfigSpec defines configuration spec that can be used to optionally configure a specific CSI Driver.", + "driverType": "driverType indicates type of CSI driver for which the driverConfig is being applied to.\n\nValid values are:\n\n* vSphere\n\nAllows configuration of vsphere CSI driver topology.", + "vSphere": "vsphere is used to configure the vsphere CSI driver.", +} + +func (CSIDriverConfigSpec) SwaggerDoc() map[string]string { + return map_CSIDriverConfigSpec +} + var map_ClusterCSIDriver = map[string]string{ "": "ClusterCSIDriver object allows management and configuration of a CSI driver operator installed by default in OpenShift. Name of the object must be name of the CSI driver it operates. See CSIDriverName type for list of allowed values.\n\nCompatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).", "spec": "spec holds user settable values for configuration", @@ -346,6 +356,7 @@ func (ClusterCSIDriverList) SwaggerDoc() map[string]string { var map_ClusterCSIDriverSpec = map[string]string{ "": "ClusterCSIDriverSpec is the desired behavior of CSI driver operator", "storageClassState": "StorageClassState determines if CSI operator should create and manage storage classes. If this field value is empty or Managed - CSI operator will continuously reconcile storage class and create if necessary. If this field value is Unmanaged - CSI operator will not reconcile any previously created storage class. If this field value is Removed - CSI operator will delete the storage class it created previously. When omitted, this means the user has no opinion and the platform chooses a reasonable default, which is subject to change over time. The current default behaviour is Managed.", + "driverConfig": "driverConfig can be used to specify platform specific driver configuration. When omitted, this means no opinion and the platform is left to choose reasonable defaults. These defaults are subject to change over time.", } func (ClusterCSIDriverSpec) SwaggerDoc() map[string]string { @@ -360,6 +371,15 @@ func (ClusterCSIDriverStatus) SwaggerDoc() map[string]string { return map_ClusterCSIDriverStatus } +var map_VSphereCSIDriverConfigSpec = map[string]string{ + "": "VSphereCSIDriverConfigSpec defines properties that can be configured for vsphere CSI driver.", + "topologyCategories": "topologyCategories indicates tag categories with which vcenter resources such as hostcluster or datacenter were tagged with. If cluster Infrastructure object has a topology, values specified in Infrastructure object will be used and modifications to topologyCategories will be rejected.", +} + +func (VSphereCSIDriverConfigSpec) SwaggerDoc() map[string]string { + return map_VSphereCSIDriverConfigSpec +} + var map_CSISnapshotController = map[string]string{ "": "CSISnapshotController provides a means to configure an operator to manage the CSI snapshots. `cluster` is the canonical name.\n\nCompatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).", "spec": "spec holds user settable values for configuration",