Skip to content

Commit

Permalink
add DeletionPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
test committed Oct 26, 2022
1 parent 65733b4 commit c61f1a6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apis/database/v1alpha1/database_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions apis/database/v1alpha1/databaseclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/database.plural.sh_databaseclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/database.plural.sh_databases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c61f1a6

Please sign in to comment.