Skip to content

Commit 6ad6c9a

Browse files
committed
address Bucket API review changes
Address API review recommended changes for Bucket resource. Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
1 parent f3bf0f5 commit 6ad6c9a

File tree

10 files changed

+214
-31
lines changed

10 files changed

+214
-31
lines changed

client/apis/objectstorage/v1alpha2/bucket_types.go

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ const (
4242
// +kubebuilder:validation:XValidation:message="existingBucketID cannot be added or removed after creation",rule="has(oldSelf.existingBucketID) == has(self.existingBucketID)"
4343
type BucketSpec struct {
4444
// driverName is the name of the driver that fulfills requests for this Bucket.
45+
// Must be 63 characters or less, beginning and ending with an alphanumeric character
46+
// ([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between.
4547
// +required
4648
// +kubebuilder:validation:MinLength=1
49+
// +kubebuilder:validation:MaxLength=63
50+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?$`
4751
// +kubebuilder:validation:XValidation:message="driverName is immutable",rule="self == oldSelf"
4852
DriverName string `json:"driverName,omitempty"`
4953

@@ -58,28 +62,34 @@ type BucketSpec struct {
5862
// parameters is an opaque map of driver-specific configuration items passed to the driver that
5963
// fulfills requests for this Bucket.
6064
// +optional
65+
// +kubebuilder:validation:MinProperties=1
6166
// +kubebuilder:validation:XValidation:message="parameters map is immutable",rule="self == oldSelf"
6267
Parameters map[string]string `json:"parameters,omitempty"`
6368

6469
// protocols lists object store protocols that the provisioned Bucket must support.
6570
// If specified, COSI will verify that each item is advertised as supported by the driver.
71+
// Possible values: 'S3', 'Azure', 'GCS'.
6672
// +optional
6773
// +listType=set
6874
// +kubebuilder:validation:XValidation:message="protocols list is immutable",rule="self == oldSelf"
6975
Protocols []ObjectProtocol `json:"protocols,omitempty"`
7076

71-
// bucketClaim references the BucketClaim that resulted in the creation of this Bucket.
77+
// bucketClaimRef references the BucketClaim that resulted in the creation of this Bucket.
7278
// For statically-provisioned buckets, set the namespace and name of the BucketClaim that is
7379
// allowed to bind to this Bucket.
7480
// +required
75-
BucketClaimRef BucketClaimReference `json:"bucketClaim,omitzero"`
81+
BucketClaimRef BucketClaimReference `json:"bucketClaimRef,omitzero"`
7682

7783
// existingBucketID is the unique identifier for an existing backend bucket known to the driver.
7884
// Use driver documentation to determine how to set this value.
79-
// This field is used only for Bucket static provisioning.
85+
// This field is used only for static Bucket provisioning.
8086
// This field will be empty when the Bucket is dynamically provisioned from a BucketClaim.
87+
// Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
88+
// dashes (-), dots (.), and underscores (_).
8189
// +optional
8290
// +kubebuilder:validation:MinLength=1
91+
// +kubebuilder:validation:MaxLength=2048
92+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9._-]+$`
8393
// +kubebuilder:validation:XValidation:message="existingBucketID is immutable",rule="self == oldSelf"
8494
ExistingBucketID string `json:"existingBucketID,omitempty"`
8595
}
@@ -89,21 +99,34 @@ type BucketSpec struct {
8999
// +kubebuilder:validation:XValidation:message="uid cannot be removed once set",rule="!has(oldSelf.uid) || has(self.uid)"
90100
type BucketClaimReference struct {
91101
// name is the name of the BucketClaim being referenced.
102+
// Must be a valid Kubernetes resource name: at most 253 characters, consisting only of
103+
// lower-case alphanumeric characters, hyphens, and periods, starting and ending with an
104+
// alphanumeric character.
92105
// +required
93106
// +kubebuilder:validation:MinLength=1
94107
// +kubebuilder:validation:MaxLength=253
108+
// +kubebuilder:validation:XValidation:message="name must be a valid resource name",rule="!format.dns1123Subdomain().validate(self).hasValue()"
95109
// +kubebuilder:validation:XValidation:message="name is immutable",rule="self == oldSelf"
96110
Name string `json:"name,omitempty"`
97111

98112
// namespace is the namespace of the BucketClaim being referenced.
113+
// Must be a valid Kubernetes Namespace name: at most 63 characters, consisting only of
114+
// lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics.
99115
// +required
100116
// +kubebuilder:validation:MinLength=1
101-
// +kubebuilder:validation:MaxLength=253
117+
// +kubebuilder:validation:MaxLength=63
118+
// +kubebuilder:validation:XValidation:message="namespace must be a valid namespace name",rule="!format.dns1123Label().validate(self).hasValue()"
102119
// +kubebuilder:validation:XValidation:message="namespace is immutable",rule="self == oldSelf"
103120
Namespace string `json:"namespace,omitempty"`
104121

105122
// uid is the UID of the BucketClaim being referenced.
123+
// Must be a valid Kubernetes UID: RFC 4122 form with lowercase hexadecimal characters
124+
// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
106125
// +optional
126+
// +kubebuilder:validation:MinLength=36
127+
// +kubebuilder:validation:MaxLength=36
128+
// +kubebuilder:validation:Type=string
129+
// +kubebuilder:validation:Pattern=`^[0-9a-f]{8}-([0-9a-f]{4}\-){3}[0-9a-f]{12}$`
107130
// +kubebuilder:validation:XValidation:message="uid is immutable once set",rule="oldSelf == '' || self == oldSelf"
108131
UID types.UID `json:"uid,omitempty"`
109132
}
@@ -117,13 +140,18 @@ type BucketStatus struct {
117140
ReadyToUse *bool `json:"readyToUse,omitempty"`
118141

119142
// bucketID is the unique identifier for the backend bucket known to the driver.
143+
// Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
144+
// dashes (-), dots (.), and underscores (_).
120145
// +optional
121146
// +kubebuilder:validation:MinLength=1
147+
// +kubebuilder:validation:MaxLength=2048
148+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9._-]+$`
122149
// +kubebuilder:validation:XValidation:message="boundBucketName is immutable once set",rule="self == oldSelf"
123150
BucketID string `json:"bucketID,omitempty"`
124151

125152
// protocols is the set of protocols the Bucket reports to support. BucketAccesses can request
126153
// access to this BucketClaim using any of the protocols reported here.
154+
// Possible values: 'S3', 'Azure', 'GCS'.
127155
// +optional
128156
// +listType=set
129157
Protocols []ObjectProtocol `json:"protocols,omitempty"`

client/config/crd/objectstorage.k8s.io_buckets.yaml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,47 @@ spec:
4040
spec:
4141
description: spec defines the desired state of Bucket
4242
properties:
43-
bucketClaim:
43+
bucketClaimRef:
4444
description: |-
45-
bucketClaim references the BucketClaim that resulted in the creation of this Bucket.
45+
bucketClaimRef references the BucketClaim that resulted in the creation of this Bucket.
4646
For statically-provisioned buckets, set the namespace and name of the BucketClaim that is
4747
allowed to bind to this Bucket.
4848
properties:
4949
name:
50-
description: name is the name of the BucketClaim being referenced.
50+
description: |-
51+
name is the name of the BucketClaim being referenced.
52+
Must be a valid Kubernetes resource name: at most 253 characters, consisting only of
53+
lower-case alphanumeric characters, hyphens, and periods, starting and ending with an
54+
alphanumeric character.
5155
maxLength: 253
5256
minLength: 1
5357
type: string
5458
x-kubernetes-validations:
59+
- message: name must be a valid resource name
60+
rule: '!format.dns1123Subdomain().validate(self).hasValue()'
5561
- message: name is immutable
5662
rule: self == oldSelf
5763
namespace:
58-
description: namespace is the namespace of the BucketClaim being
59-
referenced.
60-
maxLength: 253
64+
description: |-
65+
namespace is the namespace of the BucketClaim being referenced.
66+
Must be a valid Kubernetes Namespace name: at most 63 characters, consisting only of
67+
lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics.
68+
maxLength: 63
6169
minLength: 1
6270
type: string
6371
x-kubernetes-validations:
72+
- message: namespace must be a valid namespace name
73+
rule: '!format.dns1123Label().validate(self).hasValue()'
6474
- message: namespace is immutable
6575
rule: self == oldSelf
6676
uid:
67-
description: uid is the UID of the BucketClaim being referenced.
77+
description: |-
78+
uid is the UID of the BucketClaim being referenced.
79+
Must be a valid Kubernetes UID: RFC 4122 form with lowercase hexadecimal characters
80+
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
81+
maxLength: 36
82+
minLength: 36
83+
pattern: ^[0-9a-f]{8}-([0-9a-f]{4}\-){3}[0-9a-f]{12}$
6884
type: string
6985
x-kubernetes-validations:
7086
- message: uid is immutable once set
@@ -90,9 +106,13 @@ spec:
90106
- Delete
91107
type: string
92108
driverName:
93-
description: driverName is the name of the driver that fulfills requests
94-
for this Bucket.
109+
description: |-
110+
driverName is the name of the driver that fulfills requests for this Bucket.
111+
Must be 63 characters or less, beginning and ending with an alphanumeric character
112+
([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between.
113+
maxLength: 63
95114
minLength: 1
115+
pattern: ^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?$
96116
type: string
97117
x-kubernetes-validations:
98118
- message: driverName is immutable
@@ -101,9 +121,13 @@ spec:
101121
description: |-
102122
existingBucketID is the unique identifier for an existing backend bucket known to the driver.
103123
Use driver documentation to determine how to set this value.
104-
This field is used only for Bucket static provisioning.
124+
This field is used only for static Bucket provisioning.
105125
This field will be empty when the Bucket is dynamically provisioned from a BucketClaim.
126+
Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
127+
dashes (-), dots (.), and underscores (_).
128+
maxLength: 2048
106129
minLength: 1
130+
pattern: ^[a-zA-Z0-9._-]+$
107131
type: string
108132
x-kubernetes-validations:
109133
- message: existingBucketID is immutable
@@ -114,6 +138,7 @@ spec:
114138
description: |-
115139
parameters is an opaque map of driver-specific configuration items passed to the driver that
116140
fulfills requests for this Bucket.
141+
minProperties: 1
117142
type: object
118143
x-kubernetes-validations:
119144
- message: parameters map is immutable
@@ -122,6 +147,7 @@ spec:
122147
description: |-
123148
protocols lists object store protocols that the provisioned Bucket must support.
124149
If specified, COSI will verify that each item is advertised as supported by the driver.
150+
Possible values: 'S3', 'Azure', 'GCS'.
125151
items:
126152
description: ObjectProtocol represents an object protocol type.
127153
enum:
@@ -135,7 +161,7 @@ spec:
135161
- message: protocols list is immutable
136162
rule: self == oldSelf
137163
required:
138-
- bucketClaim
164+
- bucketClaimRef
139165
- deletionPolicy
140166
- driverName
141167
type: object
@@ -150,9 +176,13 @@ spec:
150176
description: status defines the observed state of Bucket
151177
properties:
152178
bucketID:
153-
description: bucketID is the unique identifier for the backend bucket
154-
known to the driver.
179+
description: |-
180+
bucketID is the unique identifier for the backend bucket known to the driver.
181+
Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
182+
dashes (-), dots (.), and underscores (_).
183+
maxLength: 2048
155184
minLength: 1
185+
pattern: ^[a-zA-Z0-9._-]+$
156186
type: string
157187
x-kubernetes-validations:
158188
- message: boundBucketName is immutable once set
@@ -185,6 +215,7 @@ spec:
185215
description: |-
186216
protocols is the set of protocols the Bucket reports to support. BucketAccesses can request
187217
access to this BucketClaim using any of the protocols reported here.
218+
Possible values: 'S3', 'Azure', 'GCS'.
188219
items:
189220
description: ObjectProtocol represents an object protocol type.
190221
enum:

docs/src/api/out.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ _Appears in:_
333333

334334
| Field | Description | Default | Validation |
335335
| --- | --- | --- | --- |
336-
| `name` _string_ | name is the name of the BucketClaim being referenced. | | MaxLength: 253 <br />MinLength: 1 <br /> |
337-
| `namespace` _string_ | namespace is the namespace of the BucketClaim being referenced. | | MaxLength: 253 <br />MinLength: 1 <br /> |
338-
| `uid` _[UID](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#uid-types-pkg)_ | uid is the UID of the BucketClaim being referenced. | | |
336+
| `name` _string_ | name is the name of the BucketClaim being referenced.<br />Must be a valid Kubernetes resource name: at most 253 characters, consisting only of<br />lower-case alphanumeric characters, hyphens, and periods, starting and ending with an<br />alphanumeric character. | | MaxLength: 253 <br />MinLength: 1 <br /> |
337+
| `namespace` _string_ | namespace is the namespace of the BucketClaim being referenced.<br />Must be a valid Kubernetes Namespace name: at most 63 characters, consisting only of<br />lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics. | | MaxLength: 63 <br />MinLength: 1 <br /> |
338+
| `uid` _[UID](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#uid-types-pkg)_ | uid is the UID of the BucketClaim being referenced.<br />Must be a valid Kubernetes UID: RFC 4122 form with lowercase hexadecimal characters<br />(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). | | MaxLength: 36 <br />MinLength: 36 <br />Pattern: `^[0-9a-f]\{8\}-([0-9a-f]\{4\}\-)\{3\}[0-9a-f]\{12\}$` <br />Type: string <br /> |
339339

340340

341341
#### BucketClaimSpec
@@ -492,12 +492,12 @@ _Appears in:_
492492

493493
| Field | Description | Default | Validation |
494494
| --- | --- | --- | --- |
495-
| `driverName` _string_ | driverName is the name of the driver that fulfills requests for this Bucket. | | MinLength: 1 <br /> |
495+
| `driverName` _string_ | driverName is the name of the driver that fulfills requests for this Bucket.<br />Must be 63 characters or less, beginning and ending with an alphanumeric character<br />([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between. | | MaxLength: 63 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z0-9]([a-zA-Z0-9\-\.]\{0,61\}[a-zA-Z0-9])?$` <br /> |
496496
| `deletionPolicy` _[BucketDeletionPolicy](#bucketdeletionpolicy)_ | deletionPolicy determines whether a Bucket should be deleted when its bound BucketClaim is<br />deleted. This is mutable to allow Admins to change the policy after creation.<br />Possible values:<br /> - Retain: keep both the Bucket object and the backend bucket<br /> - Delete: delete both the Bucket object and the backend bucket | | Enum: [Retain Delete] <br /> |
497-
| `parameters` _object (keys:string, values:string)_ | parameters is an opaque map of driver-specific configuration items passed to the driver that<br />fulfills requests for this Bucket. | | |
498-
| `protocols` _[ObjectProtocol](#objectprotocol) array_ | protocols lists object store protocols that the provisioned Bucket must support.<br />If specified, COSI will verify that each item is advertised as supported by the driver. | | Enum: [S3 Azure GCS] <br /> |
499-
| `bucketClaim` _[BucketClaimReference](#bucketclaimreference)_ | bucketClaim references the BucketClaim that resulted in the creation of this Bucket.<br />For statically-provisioned buckets, set the namespace and name of the BucketClaim that is<br />allowed to bind to this Bucket. | | |
500-
| `existingBucketID` _string_ | existingBucketID is the unique identifier for an existing backend bucket known to the driver.<br />Use driver documentation to determine how to set this value.<br />This field is used only for Bucket static provisioning.<br />This field will be empty when the Bucket is dynamically provisioned from a BucketClaim. | | MinLength: 1 <br /> |
497+
| `parameters` _object (keys:string, values:string)_ | parameters is an opaque map of driver-specific configuration items passed to the driver that<br />fulfills requests for this Bucket. | | MinProperties: 1 <br /> |
498+
| `protocols` _[ObjectProtocol](#objectprotocol) array_ | protocols lists object store protocols that the provisioned Bucket must support.<br />If specified, COSI will verify that each item is advertised as supported by the driver.<br />Possible values: 'S3', 'Azure', 'GCS'. | | Enum: [S3 Azure GCS] <br /> |
499+
| `bucketClaimRef` _[BucketClaimReference](#bucketclaimreference)_ | bucketClaimRef references the BucketClaim that resulted in the creation of this Bucket.<br />For statically-provisioned buckets, set the namespace and name of the BucketClaim that is<br />allowed to bind to this Bucket. | | |
500+
| `existingBucketID` _string_ | existingBucketID is the unique identifier for an existing backend bucket known to the driver.<br />Use driver documentation to determine how to set this value.<br />This field is used only for static Bucket provisioning.<br />This field will be empty when the Bucket is dynamically provisioned from a BucketClaim.<br />Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),<br />dashes (-), dots (.), and underscores (_). | | MaxLength: 2048 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z0-9._-]+$` <br /> |
501501

502502

503503
#### BucketStatus
@@ -514,8 +514,8 @@ _Appears in:_
514514
| Field | Description | Default | Validation |
515515
| --- | --- | --- | --- |
516516
| `readyToUse` _boolean_ | readyToUse indicates that the bucket is ready for consumption by workloads. | | |
517-
| `bucketID` _string_ | bucketID is the unique identifier for the backend bucket known to the driver. | | MinLength: 1 <br /> |
518-
| `protocols` _[ObjectProtocol](#objectprotocol) array_ | protocols is the set of protocols the Bucket reports to support. BucketAccesses can request<br />access to this BucketClaim using any of the protocols reported here. | | Enum: [S3 Azure GCS] <br /> |
517+
| `bucketID` _string_ | bucketID is the unique identifier for the backend bucket known to the driver.<br />Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),<br />dashes (-), dots (.), and underscores (_). | | MaxLength: 2048 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z0-9._-]+$` <br /> |
518+
| `protocols` _[ObjectProtocol](#objectprotocol) array_ | protocols is the set of protocols the Bucket reports to support. BucketAccesses can request<br />access to this BucketClaim using any of the protocols reported here.<br />Possible values: 'S3', 'Azure', 'GCS'. | | Enum: [S3 Azure GCS] <br /> |
519519
| `bucketInfo` _object (keys:string, values:string)_ | bucketInfo contains info about the bucket reported by the driver, rendered in the same<br />COSI_<PROTOCOL>_<KEY> format used for the BucketAccess Secret.<br />e.g., COSI_S3_ENDPOINT, COSI_AZURE_STORAGE_ACCOUNT.<br />This should not contain any sensitive information. | | |
520520
| `error` _[TimestampedError](#timestampederror)_ | error holds the most recent error message, with a timestamp.<br />This is cleared when provisioning is successful. | | |
521521

0 commit comments

Comments
 (0)