diff --git a/apis/database/v1alpha1/database_types.go b/apis/database/v1alpha1/database_types.go index 21ca094..1ea71c5 100644 --- a/apis/database/v1alpha1/database_types.go +++ b/apis/database/v1alpha1/database_types.go @@ -44,6 +44,14 @@ type DatabaseSpec struct { // This field will be empty when the Database is dynamically provisioned by operator. // +optional ExistingDatabaseID string `json:"existingBucketID,omitempty"` + + // DeletionPolicy is used to specify how to handle deletion. There are 2 possible values: + // - Retain: Indicates that the database should not be deleted (default) + // - Delete: Indicates that the database should be deleted + // + // +optional + // +kubebuilder:default:=Retain + DeletionPolicy DeletionPolicy `json:"deletionPolicy"` } type DatabaseStatus struct { diff --git a/apis/database/v1alpha1/databaseclass_types.go b/apis/database/v1alpha1/databaseclass_types.go index c0ae1d5..be1b627 100644 --- a/apis/database/v1alpha1/databaseclass_types.go +++ b/apis/database/v1alpha1/databaseclass_types.go @@ -22,6 +22,13 @@ func init() { SchemeBuilder.Register(&DatabaseClass{}, &DatabaseClassList{}) } +type DeletionPolicy string + +const ( + DeletionPolicyRetain DeletionPolicy = "Retain" + DeletionPolicyDelete DeletionPolicy = "Delete" +) + // +kubebuilder:object:root=true // +kubebuilder:resource:scope=Cluster type DatabaseClass struct { @@ -37,6 +44,14 @@ type DatabaseClass struct { // for creating the database // +optional Parameters map[string]string `json:"parameters,omitempty"` + + // DeletionPolicy is used to specify how to handle deletion. There are 2 possible values: + // - Retain: Indicates that the database should not be deleted (default) + // - Delete: Indicates that the database should be deleted + // + // +optional + // +kubebuilder:default:=Retain + DeletionPolicy DeletionPolicy `json:"deletionPolicy"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/config/crd/bases/database.plural.sh_databaseclasses.yaml b/config/crd/bases/database.plural.sh_databaseclasses.yaml index d086726..d6e99d2 100644 --- a/config/crd/bases/database.plural.sh_databaseclasses.yaml +++ b/config/crd/bases/database.plural.sh_databaseclasses.yaml @@ -24,6 +24,13 @@ spec: of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string + deletionPolicy: + default: Retain + description: 'DeletionPolicy is used to specify how to handle deletion. + There are 2 possible values: - Retain: Indicates that the database should + not be deleted (default) - Delete: Indicates that the database should + be deleted' + type: string driverName: description: DriverName is the name of driver associated with this database type: string diff --git a/config/crd/bases/database.plural.sh_databases.yaml b/config/crd/bases/database.plural.sh_databases.yaml index d260e2e..e752750 100644 --- a/config/crd/bases/database.plural.sh_databases.yaml +++ b/config/crd/bases/database.plural.sh_databases.yaml @@ -76,6 +76,13 @@ spec: type: string type: object x-kubernetes-map-type: atomic + deletionPolicy: + default: Retain + description: 'DeletionPolicy is used to specify how to handle deletion. + There are 2 possible values: - Retain: Indicates that the database + should not be deleted (default) - Delete: Indicates that the database + should be deleted' + type: string driverName: description: DriverName is the name of driver associated with this database