@@ -22,10 +22,12 @@ import (
2222
2323// BucketAccessAuthenticationType specifies what authentication mechanism is used for provisioning 
2424// bucket access. 
25+ // +enum 
26+ // +kubebuilder:validation:Enum:="";Key;ServiceAccount 
2527type  BucketAccessAuthenticationType  string 
2628
2729const  (
28- 	// The driver will  generate a protocol-appropriate access key that clients can use to 
30+ 	// The driver should  generate a protocol-appropriate access key that clients can use to 
2931	// authenticate to the backend object store. 
3032	BucketAccessAuthenticationTypeKey  =  "Key" 
3133
@@ -34,39 +36,148 @@ const (
3436	BucketAccessAuthenticationTypeServiceAccount  =  "ServiceAccount" 
3537)
3638
39+ // BucketAccessMode describes the Read/Write mode an access should have for a bucket. 
40+ // +enum 
41+ // +kubebuilder:validation:Enum:=ReadWrite;ReadOnly;WriteOnly 
42+ type  BucketAccessMode  string 
43+ 
44+ const  (
45+ 	// BucketAccessModeReadWrite represents read-write access mode. 
46+ 	BucketAccessModeReadWrite  BucketAccessMode  =  "ReadWrite" 
47+ 
48+ 	// BucketAccessModeReadOnly represents read-only access mode. 
49+ 	BucketAccessModeReadOnly  BucketAccessMode  =  "ReadOnly" 
50+ 
51+ 	// BucketAccessModeWriteOnly represents write-only access mode. 
52+ 	BucketAccessModeWriteOnly  BucketAccessMode  =  "WriteOnly" 
53+ )
54+ 
3755// BucketAccessSpec defines the desired state of BucketAccess 
56+ // +kubebuilder:validation:XValidation:message="serviceAccountName is immutable",rule="has(oldSelf.serviceAccountName) == has(self.serviceAccountName)" 
3857type  BucketAccessSpec  struct  {
39- 	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster 
40- 	// Important: Run "make" to regenerate code after modifying this file 
41- 	// The following markers will use OpenAPI v3 schema to validate the value 
42- 	// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html 
58+ 	// bucketClaims is a list of BucketClaims the provisioned access must have permissions for, 
59+ 	// along with per-BucketClaim access parameters and system output definitions. 
60+ 	// At least one BucketClaim must be referenced. 
61+ 	// Multiple references to the same BucketClaim are not permitted. 
62+ 	// +required 
63+ 	// +listType=map 
64+ 	// +listMapKey=bucketClaimName 
65+ 	// +kubebuilder:validation:MinItems=1 
66+ 	// +kubebuilder:validation:XValidation:message="bucketClaims list is immutable",rule="self == oldSelf" 
67+ 	BucketClaims  []BucketClaimAccess  `json:"bucketClaims"` 
4368
44- 	// foo is an example field of BucketAccess. Edit bucketaccess_types.go to remove/update 
69+ 	// bucketAccessClassName selects the BucketAccessClass for provisioning the access. 
70+ 	// +required 
71+ 	// +kubebuilder:validation:MinLength=1 
72+ 	// +kubebuilder:validation:MaxLength=253 
73+ 	// +kubebuilder:validation:XValidation:message="bucketAccessClassName is immutable",rule="self == oldSelf" 
74+ 	BucketAccessClassName  string  `json:"bucketAccessClassName"` 
75+ 
76+ 	// protocol is the object storage protocol that the provisioned access must use. 
77+ 	// +required 
78+ 	// +kubebuilder:validation:XValidation:message="protocol is immutable",rule="self == oldSelf" 
79+ 	Protocol  ObjectProtocol  `json:"protocol"` 
80+ 
81+ 	// serviceAccountName is the name of the Kubernetes ServiceAccount that user application Pods 
82+ 	// intend to use for access to referenced BucketClaims. 
83+ 	// This has different behavior based on the BucketAccessClass's defined AuthenticationType: 
84+ 	// - Key: This field is ignored. 
85+ 	// - ServiceAccount: This field is required. The driver should configure the system so that Pods 
86+ 	//   using the ServiceAccount authenticate to the object storage backend automatically. 
4587	// +optional 
46- 	Foo  * string  `json:"foo,omitempty"` 
88+ 	// +kubebuilder:validation:MaxLength=253 
89+ 	// +kubebuilder:validation:XValidation:message="serviceAccountName is immutable",rule="self == oldSelf" 
90+ 	ServiceAccountName  string  `json:"serviceAccountName,omitempty"` 
4791}
4892
4993// BucketAccessStatus defines the observed state of BucketAccess. 
94+ // +kubebuilder:validation:XValidation:message="accountID is immutable once set",rule="!has(oldSelf.accountID) || has(self.accountID)" 
95+ // +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="!has(oldSelf.accessedBuckets) || has(self.accessedBuckets)" 
96+ // +kubebuilder:validation:XValidation:message="driverName is immutable once set",rule="!has(oldSelf.driverName) || has(self.driverName)" 
97+ // +kubebuilder:validation:XValidation:message="authenticationType is immutable once set",rule="!has(oldSelf.authenticationType) || has(self.authenticationType)" 
98+ // +kubebuilder:validation:XValidation:message="parameters is immutable once set",rule="!has(oldSelf.parameters) || has(self.parameters)" 
5099type  BucketAccessStatus  struct  {
51- 	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster 
52- 	// Important: Run "make" to regenerate code after modifying this file 
53- 
54- 	// For Kubernetes API conventions, see: 
55- 	// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties 
56- 
57- 	// conditions represent the current state of the BucketAccess resource. 
58- 	// Each condition has a unique type and reflects the status of a specific aspect of the resource. 
59- 	// 
60- 	// Standard condition types include: 
61- 	// - "Available": the resource is fully functional 
62- 	// - "Progressing": the resource is being created or updated 
63- 	// - "Degraded": the resource failed to reach or maintain its desired state 
64- 	// 
65- 	// The status of each condition is one of True, False, or Unknown. 
100+ 	// readyToUse indicates that the BucketAccess is ready for consumption by workloads. 
101+ 	ReadyToUse  bool  `json:"readyToUse"` 
102+ 
103+ 	// accountID is the unique identifier for the backend access known to the driver. 
104+ 	// This field is populated by the COSI Sidecar once access has been successfully granted. 
105+ 	// +optional 
106+ 	// +kubebuilder:validation:XValidation:message="accountId is immutable once set",rule="oldSelf == '' || self == oldSelf" 
107+ 	AccountID  string  `json:"accountID"` 
108+ 
109+ 	// accessedBuckets is a list of Buckets the provisioned access must have permissions for, along 
110+ 	// with per-Bucket access options. This field is populated by the COSI Controller based on the 
111+ 	// referenced BucketClaims in the spec. 
112+ 	// +optional 
66113	// +listType=map 
67- 	// +listMapKey=type 
114+ 	// +listMapKey=bucketName 
115+ 	// +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="oldSelf.size() == 0 || self == oldSelf" 
116+ 	AccessedBuckets  []AccessedBucket  `json:"accessedBuckets"` 
117+ 
118+ 	// driverName holds a copy of the BucketAccessClass driver name from the time of BucketAccess 
119+ 	// provisioning. This field is populated by the COSI Controller. 
68120	// +optional 
69- 	Conditions  []metav1.Condition  `json:"conditions,omitempty"` 
121+ 	// +kubebuilder:validation:XValidation:message="driverName is immutable once set",rule="oldSelf == '' || self == oldSelf" 
122+ 	DriverName  string  `json:"driverName"` 
123+ 
124+ 	// authenticationType holds a copy of the BucketAccessClass authentication type from the time of 
125+ 	// BucketAccess provisioning. This field is populated by the COSI Controller. 
126+ 	// +optional 
127+ 	// +kubebuilder:validation:XValidation:message="authenticationType is immutable once set",rule="oldSelf == '' || self == oldSelf" 
128+ 	AuthenticationType  BucketAccessAuthenticationType  `json:"authenticationType"` 
129+ 
130+ 	// parameters holds a copy of the BucketAccessClass parameters from the time of BucketAccess 
131+ 	// provisioning. This field is populated by the COSI Controller. 
132+ 	// +optional 
133+ 	// +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="oldSelf.size() == 0 || self == oldSelf" 
134+ 	Parameters  map [string ]string  `json:"parameters,omitempty"` 
135+ 
136+ 	// error holds the most recent error message, with a timestamp. 
137+ 	// This is cleared when provisioning is successful. 
138+ 	// +optional 
139+ 	Error  * TimestampedError  `json:"error,omitempty"` 
140+ }
141+ 
142+ // BucketClaimAccess selects a BucketClaim for access, defines access parameters for the 
143+ // corresponding bucket, and specifies where user-consumable bucket information and access 
144+ // credentials for the accessed bucket will be stored. 
145+ type  BucketClaimAccess  struct  {
146+ 	// bucketClaimName is the name of a BucketClaim the access should have permissions for. 
147+ 	// The BucketClaim must be in the same Namespace as the BucketAccess. 
148+ 	// +required 
149+ 	// +kubebuilder:validation:MinLength=1 
150+ 	// +kubebuilder:validation:MaxLength=253 
151+ 	BucketClaimName  string  `json:"bucketClaimName"` 
152+ 
153+ 	// accessMode is the Read/Write access mode that the access should have for the bucket. 
154+ 	// Possible values: ReadWrite, ReadOnly, WriteOnly. 
155+ 	// +required 
156+ 	AccessMode  BucketAccessMode  `json:"accessMode"` 
157+ 
158+ 	// accessSecretName is the name of a Kubernetes Secret that COSI should create and populate with 
159+ 	// bucket info and access credentials for the bucket. 
160+ 	// The Secret is created in the same Namespace as the BucketAccess and is deleted when the 
161+ 	// BucketAccess is deleted and deprovisioned. 
162+ 	// The Secret name must be unique across all bucketClaimRefs for all BucketAccesses in the same 
163+ 	// Namespace. 
164+ 	// +required 
165+ 	// +kubebuilder:validation:MinLength=1 
166+ 	// +kubebuilder:validation:MaxLength=253 
167+ 	AccessSecretName  string  `json:"accessSecretName"` 
168+ }
169+ 
170+ // AccessedBucket identifies a Bucket and corresponding access parameters. 
171+ type  AccessedBucket  struct  {
172+ 	// bucketName is the name of a Bucket the access should have permissions for. 
173+ 	// +required 
174+ 	// +kubebuilder:validation:MinLength=1 
175+ 	// +kubebuilder:validation:MaxLength=253 
176+ 	BucketName  string  `json:"bucketName"` 
177+ 
178+ 	// accessMode is the Read/Write access mode that the access should have for the bucket. 
179+ 	// +required 
180+ 	AccessMode  BucketAccessMode  `json:"accessMode"` 
70181}
71182
72183// +kubebuilder:object:root=true 
0 commit comments