Skip to content

Commit 9dde7a8

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 9dde7a8

File tree

12 files changed

+269
-37
lines changed

12 files changed

+269
-37
lines changed

client/apis/objectstorage/v1alpha2/bucket_types.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ 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
46-
// +kubebuilder:validation:MinLength=1
4748
// +kubebuilder:validation:XValidation:message="driverName is immutable",rule="self == oldSelf"
48-
DriverName string `json:"driverName,omitempty"`
49+
DriverName DriverName `json:"driverName,omitempty"`
4950

5051
// deletionPolicy determines whether a Bucket should be deleted when its bound BucketClaim is
5152
// deleted. This is mutable to allow Admins to change the policy after creation.
@@ -58,52 +59,68 @@ type BucketSpec struct {
5859
// parameters is an opaque map of driver-specific configuration items passed to the driver that
5960
// fulfills requests for this Bucket.
6061
// +optional
62+
// +kubebuilder:validation:MinProperties=1
6163
// +kubebuilder:validation:XValidation:message="parameters map is immutable",rule="self == oldSelf"
6264
Parameters map[string]string `json:"parameters,omitempty"`
6365

6466
// protocols lists object store protocols that the provisioned Bucket must support.
6567
// If specified, COSI will verify that each item is advertised as supported by the driver.
68+
// Possible values: 'S3', 'Azure', 'GCS'.
6669
// +optional
6770
// +listType=set
6871
// +kubebuilder:validation:XValidation:message="protocols list is immutable",rule="self == oldSelf"
6972
Protocols []ObjectProtocol `json:"protocols,omitempty"`
7073

71-
// bucketClaim references the BucketClaim that resulted in the creation of this Bucket.
74+
// bucketClaimRef references the BucketClaim that resulted in the creation of this Bucket.
7275
// For statically-provisioned buckets, set the namespace and name of the BucketClaim that is
7376
// allowed to bind to this Bucket.
7477
// +required
75-
BucketClaimRef BucketClaimReference `json:"bucketClaim,omitzero"`
78+
BucketClaimRef BucketClaimReference `json:"bucketClaimRef,omitzero"`
7679

7780
// existingBucketID is the unique identifier for an existing backend bucket known to the driver.
7881
// Use driver documentation to determine how to set this value.
79-
// This field is used only for Bucket static provisioning.
82+
// This field is used only for static Bucket provisioning.
8083
// This field will be empty when the Bucket is dynamically provisioned from a BucketClaim.
84+
// Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
85+
// dashes (-), dots (.), and underscores (_).
8186
// +optional
82-
// +kubebuilder:validation:MinLength=1
8387
// +kubebuilder:validation:XValidation:message="existingBucketID is immutable",rule="self == oldSelf"
84-
ExistingBucketID string `json:"existingBucketID,omitempty"`
88+
ExistingBucketID DriverResourceID `json:"existingBucketID,omitempty"`
8589
}
8690

8791
// BucketClaimReference is a reference to a BucketClaim object.
8892
// +kubebuilder:validation:XValidation:message="namespace cannot be removed once set",rule="!has(oldSelf.namespace) || has(self.namespace)"
8993
// +kubebuilder:validation:XValidation:message="uid cannot be removed once set",rule="!has(oldSelf.uid) || has(self.uid)"
9094
type BucketClaimReference struct {
9195
// name is the name of the BucketClaim being referenced.
96+
// Must be a valid Kubernetes resource name: at most 253 characters, consisting only of
97+
// lower-case alphanumeric characters, hyphens, and periods, starting and ending with an
98+
// alphanumeric character.
9299
// +required
93100
// +kubebuilder:validation:MinLength=1
94101
// +kubebuilder:validation:MaxLength=253
102+
// +kubebuilder:validation:XValidation:message="name must be a valid resource name",rule="!format.dns1123Subdomain().validate(self).hasValue()"
95103
// +kubebuilder:validation:XValidation:message="name is immutable",rule="self == oldSelf"
96104
Name string `json:"name,omitempty"`
97105

98106
// namespace is the namespace of the BucketClaim being referenced.
107+
// Must be a valid Kubernetes Namespace name: at most 63 characters, consisting only of
108+
// lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics.
99109
// +required
100110
// +kubebuilder:validation:MinLength=1
101-
// +kubebuilder:validation:MaxLength=253
111+
// +kubebuilder:validation:MaxLength=63
112+
// +kubebuilder:validation:XValidation:message="namespace must be a valid namespace name",rule="!format.dns1123Label().validate(self).hasValue()"
102113
// +kubebuilder:validation:XValidation:message="namespace is immutable",rule="self == oldSelf"
103114
Namespace string `json:"namespace,omitempty"`
104115

105116
// uid is the UID of the BucketClaim being referenced.
117+
// Must be a valid Kubernetes UID: RFC 4122 form with lowercase hexadecimal characters
118+
// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
106119
// +optional
120+
// +kubebuilder:validation:MinLength=36
121+
// +kubebuilder:validation:MaxLength=36
122+
// +kubebuilder:validation:Type=string
123+
// +kubebuilder:validation:Pattern=`^[0-9a-f]{8}-([0-9a-f]{4}\-){3}[0-9a-f]{12}$`
107124
// +kubebuilder:validation:XValidation:message="uid is immutable once set",rule="oldSelf == '' || self == oldSelf"
108125
UID types.UID `json:"uid,omitempty"`
109126
}
@@ -117,13 +134,15 @@ type BucketStatus struct {
117134
ReadyToUse *bool `json:"readyToUse,omitempty"`
118135

119136
// bucketID is the unique identifier for the backend bucket known to the driver.
137+
// Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
138+
// dashes (-), dots (.), and underscores (_).
120139
// +optional
121-
// +kubebuilder:validation:MinLength=1
122140
// +kubebuilder:validation:XValidation:message="boundBucketName is immutable once set",rule="self == oldSelf"
123-
BucketID string `json:"bucketID,omitempty"`
141+
BucketID DriverResourceID `json:"bucketID,omitempty"`
124142

125143
// protocols is the set of protocols the Bucket reports to support. BucketAccesses can request
126144
// access to this BucketClaim using any of the protocols reported here.
145+
// Possible values: 'S3', 'Azure', 'GCS'.
127146
// +optional
128147
// +listType=set
129148
Protocols []ObjectProtocol `json:"protocols,omitempty"`

client/apis/objectstorage/v1alpha2/shared_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ import (
2727
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
)
2929

30+
// DriverName represents the name of a driver.
31+
// Must be 63 characters or less, beginning and ending with an alphanumeric character
32+
// ([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between.
33+
// +kubebuilder:validation:MinLength=1
34+
// +kubebuilder:validation:MaxLength=63
35+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?$`
36+
type DriverName string
37+
38+
// DriverResourceID represents a unique identifier for a driver bucket or access resource.
39+
// To prevent misuse, a driver resource ID must be at most 2048 characters and consist only of
40+
// alphanumeric characters ([a-z0-9A-Z]), dashes (-), dots (.), and underscores (_).
41+
// +kubebuilder:validation:MinLength=1
42+
// +kubebuilder:validation:MaxLength=2048
43+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9._-]+$`
44+
type DriverResourceID string
45+
3046
// TimestampedError contains an error message with timestamp.
3147
type TimestampedError struct {
3248
// time is the timestamp when the error was encountered.

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

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,49 @@ 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 and 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 and consisting only of
67+
lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics.
68+
It must be at most 63 characters in length and consist only of lower-case alphanumeric
69+
characters and hyphens, and must start and end with an alphanumeric character.
70+
maxLength: 63
6171
minLength: 1
6272
type: string
6373
x-kubernetes-validations:
74+
- message: namespace must be a valid namespace name
75+
rule: '!format.dns1123Label().validate(self).hasValue()'
6476
- message: namespace is immutable
6577
rule: self == oldSelf
6678
uid:
67-
description: uid is the UID of the BucketClaim being referenced.
79+
description: |-
80+
uid is the UID of the BucketClaim being referenced.
81+
Must be a valid Kubernetes UID: RFC 4122 form with lowercase hexadecimal characters
82+
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
83+
maxLength: 36
84+
minLength: 36
85+
pattern: ^[0-9a-f]{8}-([0-9a-f]{4}\-){3}[0-9a-f]{12}$
6886
type: string
6987
x-kubernetes-validations:
7088
- message: uid is immutable once set
@@ -90,9 +108,13 @@ spec:
90108
- Delete
91109
type: string
92110
driverName:
93-
description: driverName is the name of the driver that fulfills requests
94-
for this Bucket.
111+
description: |-
112+
driverName is the name of the driver that fulfills requests for this Bucket.
113+
Must be 63 characters or less, beginning and ending with an alphanumeric character
114+
([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between.
115+
maxLength: 63
95116
minLength: 1
117+
pattern: ^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?$
96118
type: string
97119
x-kubernetes-validations:
98120
- message: driverName is immutable
@@ -101,9 +123,13 @@ spec:
101123
description: |-
102124
existingBucketID is the unique identifier for an existing backend bucket known to the driver.
103125
Use driver documentation to determine how to set this value.
104-
This field is used only for Bucket static provisioning.
126+
This field is used only for static Bucket provisioning.
105127
This field will be empty when the Bucket is dynamically provisioned from a BucketClaim.
128+
Must be at most 2048 characters and consist only of alphanumeric characters ([a-z0-9A-Z]),
129+
dashes (-), and dots (.).
130+
maxLength: 2048
106131
minLength: 1
132+
pattern: ^[a-zA-Z0-9._-]+$
107133
type: string
108134
x-kubernetes-validations:
109135
- message: existingBucketID is immutable
@@ -114,6 +140,7 @@ spec:
114140
description: |-
115141
parameters is an opaque map of driver-specific configuration items passed to the driver that
116142
fulfills requests for this Bucket.
143+
minProperties: 1
117144
type: object
118145
x-kubernetes-validations:
119146
- message: parameters map is immutable
@@ -122,6 +149,7 @@ spec:
122149
description: |-
123150
protocols lists object store protocols that the provisioned Bucket must support.
124151
If specified, COSI will verify that each item is advertised as supported by the driver.
152+
Possible values: 'S3', 'Azure', 'GCS'.
125153
items:
126154
description: ObjectProtocol represents an object protocol type.
127155
enum:
@@ -135,7 +163,7 @@ spec:
135163
- message: protocols list is immutable
136164
rule: self == oldSelf
137165
required:
138-
- bucketClaim
166+
- bucketClaimRef
139167
- deletionPolicy
140168
- driverName
141169
type: object

docs/src/api/out.md

Lines changed: 45 additions & 8 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 and 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 and consisting only of<br />lower-case alphanumeric characters and hyphens, starting and ending with alphanumerics.<br />It must be at most 63 characters in length and consist only of lower-case alphanumeric<br />characters and hyphens, and must start and end with an alphanumeric character. | | 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` _[DriverName](#drivername)_ | 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` _[DriverResourceID](#driverresourceid)_ | 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 (-), and dots (.). | | MaxLength: 2048 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z0-9._-]+$` <br />Type: string <br /> |
501501

502502

503503
#### BucketStatus
@@ -543,6 +543,43 @@ _Appears in:_
543543

544544

545545

546+
#### DriverName
547+
548+
_Underlying type:_ _string_
549+
550+
DriverName represents the name of a driver.
551+
Must be 63 characters or less, beginning and ending with an alphanumeric character
552+
([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between.
553+
554+
_Validation:_
555+
- MaxLength: 63
556+
- MinLength: 1
557+
- Pattern: `^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,61}[a-zA-Z0-9])?$`
558+
559+
_Appears in:_
560+
- [BucketSpec](#bucketspec)
561+
562+
563+
564+
#### DriverResourceID
565+
566+
_Underlying type:_ _string_
567+
568+
DriverResourceID represents a unique identifier for a driver bucket or access resource.
569+
To prevent misuse, a driver resource ID must be at most 2048 characters and consist only of
570+
alphanumeric characters ([a-z0-9A-Z]), dashes (-), dots (.), and underscores (_).
571+
572+
_Validation:_
573+
- MaxLength: 2048
574+
- MinLength: 1
575+
- Pattern: `^[a-zA-Z0-9._-]+$`
576+
- Type: string
577+
578+
_Appears in:_
579+
- [BucketSpec](#bucketspec)
580+
581+
582+
546583
#### ObjectProtocol
547584

548585
_Underlying type:_ _string_

0 commit comments

Comments
 (0)