From 9fde3655756a423fe65babb6ccbeff662a5c4a02 Mon Sep 17 00:00:00 2001 From: Srini Brahmaroutu Date: Mon, 18 Jan 2021 14:38:24 -0800 Subject: [PATCH] Adding Protocol to BucketClass to allow admin to provide backend information --- .../v1alpha1/openapi_generated.go | 60 ++++--------------- .../v1alpha1/protocol_types.go | 7 +-- .../objectstorage.k8s.io/v1alpha1/s3_types.go | 1 - apis/objectstorage.k8s.io/v1alpha1/types.go | 7 +-- .../v1alpha1/zz_generated.deepcopy.go | 19 +----- controller/controller.go | 2 +- crds/objectstorage.k8s.io_bucketclasses.yaml | 45 +++++++++++++- crds/objectstorage.k8s.io_bucketrequests.yaml | 15 ----- crds/objectstorage.k8s.io_buckets.yaml | 25 +++----- 9 files changed, 72 insertions(+), 109 deletions(-) diff --git a/apis/objectstorage.k8s.io/v1alpha1/openapi_generated.go b/apis/objectstorage.k8s.io/v1alpha1/openapi_generated.go index efb69844..67089a2e 100644 --- a/apis/objectstorage.k8s.io/v1alpha1/openapi_generated.go +++ b/apis/objectstorage.k8s.io/v1alpha1/openapi_generated.go @@ -53,7 +53,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.BucketStatus": schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_BucketStatus(ref), "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.GCSProtocol": schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_GCSProtocol(ref), "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.Protocol": schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_Protocol(ref), - "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.RequestedProtocol": schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_RequestedProtocol(ref), "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.S3Protocol": schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_S3Protocol(ref), } } @@ -647,8 +646,7 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp }, "protocol": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Ref: ref("github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.Protocol"), }, }, "anonymousAccessMode": { @@ -687,7 +685,7 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp }, }, Dependencies: []string{ - "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.AnonymousAccessMode", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.AnonymousAccessMode", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.Protocol", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -896,17 +894,9 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp Format: "", }, }, - "protocol": { - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.RequestedProtocol"), - }, - }, }, - Required: []string{"protocol"}, }, }, - Dependencies: []string{ - "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.RequestedProtocol"}, } } @@ -1080,9 +1070,16 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "requestedProtocol": { + "name": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.RequestedProtocol"), + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", }, }, "s3": { @@ -1101,36 +1098,11 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp }, }, }, - Required: []string{"requestedProtocol"}, - }, - }, - Dependencies: []string{ - "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.AzureProtocol", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.GCSProtocol", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.RequestedProtocol", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.S3Protocol"}, - } -} - -func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alpha1_RequestedProtocol(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "name": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "version": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, Required: []string{"name"}, }, }, + Dependencies: []string{ + "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.AzureProtocol", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.GCSProtocol", "github.com/kubernetes-sigs/container-object-storage-interface-api/apis/objectstorage.k8s.io/v1alpha1.S3Protocol"}, } } @@ -1140,12 +1112,6 @@ func schema_container_object_storage_interface_api_apis_objectstoragek8sio_v1alp SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "version": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, "endpoint": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, diff --git a/apis/objectstorage.k8s.io/v1alpha1/protocol_types.go b/apis/objectstorage.k8s.io/v1alpha1/protocol_types.go index 102b60af..b9e2522c 100644 --- a/apis/objectstorage.k8s.io/v1alpha1/protocol_types.go +++ b/apis/objectstorage.k8s.io/v1alpha1/protocol_types.go @@ -24,16 +24,11 @@ const ( ProtocolNameGCS ProtocolName = "gcs" ) -type RequestedProtocol struct { +type Protocol struct { // +kubebuilder:validation:Enum:={s3,azureBlob,gcs} Name ProtocolName `json:"name"` // +optional Version string `json:"version,omitempty"` -} - -type Protocol struct { - // +required - RequestedProtocol `json:"requestedProtocol"` // +optional S3 *S3Protocol `json:"s3,omitempty"` // +optional diff --git a/apis/objectstorage.k8s.io/v1alpha1/s3_types.go b/apis/objectstorage.k8s.io/v1alpha1/s3_types.go index 7163bde1..6ef23aae 100644 --- a/apis/objectstorage.k8s.io/v1alpha1/s3_types.go +++ b/apis/objectstorage.k8s.io/v1alpha1/s3_types.go @@ -26,7 +26,6 @@ const ( ) type S3Protocol struct { - Version string `json:"version,omitempty"` Endpoint string `json:"endpoint,omitempty"` BucketName string `json:"bucketName,omitempty"` Region string `json:"region,omitempty"` diff --git a/apis/objectstorage.k8s.io/v1alpha1/types.go b/apis/objectstorage.k8s.io/v1alpha1/types.go index dc426553..e9ae280f 100644 --- a/apis/objectstorage.k8s.io/v1alpha1/types.go +++ b/apis/objectstorage.k8s.io/v1alpha1/types.go @@ -27,8 +27,7 @@ type BucketRequestSpec struct { // +optional BucketPrefix string `json:"bucketPrefix,omitempty"` // +optional - BucketClassName string `json:"bucketClassName,omitempty"` - Protocol RequestedProtocol `json:"protocol"` + BucketClassName string `json:"bucketClassName,omitempty"` } type BucketRequestStatus struct { @@ -145,7 +144,7 @@ type BucketClass struct { // +listType=atomic // +optional AllowedNamespaces []string `json:"allowedNamespaces,omitempty"` - Protocol string `json:"protocol"` + Protocol Protocol `json:"protocol"` // +optional AnonymousAccessMode AnonymousAccessMode `json:"anonymousAccessMode,omitempty"` // +kubebuilder:default:=retain @@ -196,7 +195,7 @@ type BucketAccessSpec struct { // +optional BucketAccessRequest *corev1.ObjectReference `json:"bucketAccessRequest,omitempty"` // +optional - ServiceAccount *corev1.ObjectReference `json:"serviceAccount,omitempty"` + ServiceAccount *corev1.ObjectReference `json:"serviceAccount,omitempty"` // +optional MintedSecretName string `json:"mintedSecretName,omitempty"` PolicyActionsConfigMapData string `json:"policyActionsConfigMapData,omitempty"` diff --git a/apis/objectstorage.k8s.io/v1alpha1/zz_generated.deepcopy.go b/apis/objectstorage.k8s.io/v1alpha1/zz_generated.deepcopy.go index 0904685e..8d9e27ed 100644 --- a/apis/objectstorage.k8s.io/v1alpha1/zz_generated.deepcopy.go +++ b/apis/objectstorage.k8s.io/v1alpha1/zz_generated.deepcopy.go @@ -369,6 +369,7 @@ func (in *BucketClass) DeepCopyInto(out *BucketClass) { *out = make([]string, len(*in)) copy(*out, *in) } + in.Protocol.DeepCopyInto(&out.Protocol) out.AnonymousAccessMode = in.AnonymousAccessMode if in.Parameters != nil { in, out := &in.Parameters, &out.Parameters @@ -528,7 +529,6 @@ func (in *BucketRequestList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BucketRequestSpec) DeepCopyInto(out *BucketRequestSpec) { *out = *in - out.Protocol = in.Protocol return } @@ -628,7 +628,6 @@ func (in *GCSProtocol) DeepCopy() *GCSProtocol { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Protocol) DeepCopyInto(out *Protocol) { *out = *in - out.RequestedProtocol = in.RequestedProtocol if in.S3 != nil { in, out := &in.S3, &out.S3 *out = new(S3Protocol) @@ -657,22 +656,6 @@ func (in *Protocol) DeepCopy() *Protocol { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RequestedProtocol) DeepCopyInto(out *RequestedProtocol) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequestedProtocol. -func (in *RequestedProtocol) DeepCopy() *RequestedProtocol { - if in == nil { - return nil - } - out := new(RequestedProtocol) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *S3Protocol) DeepCopyInto(out *S3Protocol) { *out = *in diff --git a/controller/controller.go b/controller/controller.go index 39d2fb46..1c989264 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -172,7 +172,7 @@ func NewObjectStorageControllerWithClientset(identity string, leaderLockName str // Run - runs the controller. Note that ctx must be cancellable i.e. ctx.Done() should not return nil func (c *ObjectStorageController) Run(ctx context.Context) error { if !c.initialized { - fmt.Errorf("Uninitialized controller. Atleast 1 listener should be added") + return fmt.Errorf("Uninitialized controller. Atleast 1 listener should be added") } ns := func() string { diff --git a/crds/objectstorage.k8s.io_bucketclasses.yaml b/crds/objectstorage.k8s.io_bucketclasses.yaml index 27fc59e8..363d8d30 100644 --- a/crds/objectstorage.k8s.io_bucketclasses.yaml +++ b/crds/objectstorage.k8s.io_bucketclasses.yaml @@ -56,7 +56,50 @@ spec: type: string type: object protocol: - type: string + properties: + azureBlob: + properties: + containerName: + type: string + storageAccount: + type: string + type: object + gcs: + properties: + bucketName: + type: string + privateKeyName: + type: string + projectID: + type: string + serviceAccount: + type: string + type: object + name: + enum: + - s3 + - azureBlob + - gcs + type: string + s3: + properties: + bucketName: + type: string + endpoint: + type: string + region: + type: string + signatureVersion: + enum: + - s3v2 + - s3v4 + type: string + type: object + version: + type: string + required: + - name + type: object provisioner: type: string retentionPolicy: diff --git a/crds/objectstorage.k8s.io_bucketrequests.yaml b/crds/objectstorage.k8s.io_bucketrequests.yaml index 6e26e722..3cd5d037 100644 --- a/crds/objectstorage.k8s.io_bucketrequests.yaml +++ b/crds/objectstorage.k8s.io_bucketrequests.yaml @@ -40,21 +40,6 @@ spec: type: string bucketPrefix: type: string - protocol: - properties: - name: - enum: - - s3 - - azureBlob - - gcs - type: string - version: - type: string - required: - - name - type: object - required: - - protocol type: object status: properties: diff --git a/crds/objectstorage.k8s.io_buckets.yaml b/crds/objectstorage.k8s.io_buckets.yaml index c59241d4..2c558e83 100644 --- a/crds/objectstorage.k8s.io_buckets.yaml +++ b/crds/objectstorage.k8s.io_buckets.yaml @@ -135,19 +135,12 @@ spec: serviceAccount: type: string type: object - requestedProtocol: - properties: - name: - enum: - - s3 - - azureBlob - - gcs - type: string - version: - type: string - required: - - name - type: object + name: + enum: + - s3 + - azureBlob + - gcs + type: string s3: properties: bucketName: @@ -161,11 +154,11 @@ spec: - s3v2 - s3v4 type: string - version: - type: string type: object + version: + type: string required: - - requestedProtocol + - name type: object provisioner: type: string