@@ -18,21 +18,81 @@ package v1alpha2
1818
1919import (
2020 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+ "k8s.io/apimachinery/pkg/types"
2122)
2223
23- // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24- // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
24+ // BucketDeletionPolicy configures COSI's behavior when a Bucket resource is deleted.
25+ // +enum
26+ // +kubebuilder:validation:Enum:=Retain;Delete
27+ type BucketDeletionPolicy string
28+
29+ const (
30+ // BucketDeletionPolicyRetain configures COSI to keep the Bucket object as well as the backend
31+ // bucket when a Bucket resource is deleted.
32+ BucketDeletionPolicyRetain BucketDeletionPolicy = "Retain"
33+
34+ // BucketDeletionPolicyDelete configures COSI to delete the Bucket object as well as the backend
35+ // bucket when a Bucket resource is deleted.
36+ BucketDeletionPolicyDelete BucketDeletionPolicy = "Delete"
37+ )
2538
2639// BucketSpec defines the desired state of Bucket
2740type BucketSpec struct {
28- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29- // Important: Run "make" to regenerate code after modifying this file
30- // The following markers will use OpenAPI v3 schema to validate the value
31- // More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
41+ // driverName is the name of the driver that fulfills requests for this Bucket.
42+ // +required
43+ // +kubebuilder:validation:MinLength=1
44+ // +kubebuilder:validation:XValidation:message="driverName is immutable",rule="self == oldSelf"
45+ DriverName string `json:"driverName"`
46+
47+ // deletionPolicy determines whether a Bucket should be deleted when its bound BucketClaim is
48+ // deleted. This is mutable to allow Admins to change the policy after creation.
49+ // Possible values:
50+ // - Retain: keep both the Bucket object and the backend bucket
51+ // - Delete: delete both the Bucket object and the backend bucket
52+ // +required
53+ DeletionPolicy BucketDeletionPolicy `json:"deletionPolicy"`
54+
55+ // parameters is an opaque map of driver-specific configuration items passed to the driver that
56+ // fulfills requests for this Bucket.
57+ // +optional
58+ // +kubebuilder:validation:XValidation:message="parameters map is immutable",rule="self == oldSelf"
59+ Parameters map [string ]string `json:"parameters,omitempty"`
60+
61+ // protocols lists object store protocols that the provisioned Bucket must support.
62+ // If specified, COSI will verify that each item is advertised as supported by the driver.
63+ // +optional
64+ // +listType=set
65+ // +kubebuilder:validation:XValidation:message="protocols list is immutable",rule="self == oldSelf"
66+ Protocols []ObjectProtocol `json:"protocols,omitempty"`
67+
68+ // bucketClaim references the BucketClaim that resulted in the creation of this Bucket.
69+ // For statically-provisioned buckets, set the namespace and name of the BucketClaim that is
70+ // allowed to bind to this Bucket.
71+ // +required
72+ BucketClaimRef BucketClaimReference `json:"bucketClaim"`
73+ }
74+
75+ // BucketClaimReference is a reference to a BucketClaim object.
76+ type BucketClaimReference struct {
77+ // name is the name of the BucketClaim being referenced.
78+ // +required
79+ // +kubebuilder:validation:MinLength=1
80+ // +kubebuilder:validation:XValidation:message="driverName is immutable",rule="self == oldSelf"
81+ Name string `json:"name"`
82+
83+ // namespace is the namespace of the BucketClaim being referenced.
84+ // If empty, the Kubernetes 'default' namespace is assumed.
85+ // namespace is immutable except to update '' to 'default'.
86+ // +optional
87+ // +kubebuilder:validation:MinLength=0
88+ // +kubebuilder:validation:XValidation:message="driverName is immutable",rule="(oldSelf == '' && self == 'default') || self == oldSelf"
89+ Namespace string `json:"namespace"`
3290
33- // foo is an example field of Bucket. Edit bucket_types.go to remove/update
91+ // uid is the UID of the BucketClaim being referenced.
92+ // Once set, the UID is immutable.
3493 // +optional
35- Foo * string `json:"foo,omitempty"`
94+ // +kubebuilder:validation:XValidation:message="driverName is immutable",rule="oldSelf == '' || self == oldSelf"
95+ UID types.UID `json:"uid"`
3696}
3797
3898// BucketStatus defines the observed state of Bucket.
@@ -46,6 +106,8 @@ type BucketStatus struct {
46106
47107// +kubebuilder:object:root=true
48108// +kubebuilder:subresource:status
109+ // +kubebuilder:resource:scope=Cluster
110+ // +kubebuilder:metadata:annotations="api-approved.kubernetes.io=unapproved, experimental v1alpha2 changes"
49111
50112// Bucket is the Schema for the buckets API
51113type Bucket struct {
0 commit comments