Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/bases/mariadb.openstack.org_mariadbaccounts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ spec:
spec:
description: MariaDBAccountSpec defines the desired state of MariaDBAccount
properties:
accountType:
default: User
enum:
- User
- System
type: string
requireTLS:
default: false
description: Account must use TLS to connect to the database
Expand Down Expand Up @@ -108,6 +114,14 @@ spec:
- type
type: object
type: array
currentSecret:
description: |-
the Secret that's currently in use for the account.
keeping a handle to this secret allows us to remove its finalizer
when it's replaced with a new one. It also is useful for storing
the current "root" secret separate from a newly proposed one which is
needed when changing the database root password.
type: string
hash:
additionalProperties:
type: string
Expand Down
26 changes: 26 additions & 0 deletions api/v1beta1/mariadbaccount_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,28 @@ type MariaDBAccountSpec struct {
// Account must use TLS to connect to the database
// +kubebuilder:default=false
RequireTLS bool `json:"requireTLS"`

// +kubebuilder:validation:Enum=User;System
// +kubebuilder:default=User
AccountType AccountType `json:"accountType,omitempty"`
}

type AccountType string

const (
User AccountType = "User"
System AccountType = "System"
)

// MariaDBAccountStatus defines the observed state of MariaDBAccount
type MariaDBAccountStatus struct {
// the Secret that's currently in use for the account.
// keeping a handle to this secret allows us to remove its finalizer
// when it's replaced with a new one. It also is useful for storing
// the current "root" secret separate from a newly proposed one which is
// needed when changing the database root password.
CurrentSecret string `json:"currentSecret,omitempty"`

// Deployment Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`

Expand Down Expand Up @@ -85,3 +103,11 @@ type MariaDBAccountList struct {
func init() {
SchemeBuilder.Register(&MariaDBAccount{}, &MariaDBAccountList{})
}

func (mariadbAccount MariaDBAccount) IsSystemAccount() bool {
return mariadbAccount.Spec.AccountType == System
}

func (mariadbAccount MariaDBAccount) IsUserAccount() bool {
return mariadbAccount.Spec.AccountType == "" || mariadbAccount.Spec.AccountType == User
}
14 changes: 14 additions & 0 deletions config/crd/bases/mariadb.openstack.org_mariadbaccounts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ spec:
spec:
description: MariaDBAccountSpec defines the desired state of MariaDBAccount
properties:
accountType:
default: User
enum:
- User
- System
type: string
requireTLS:
default: false
description: Account must use TLS to connect to the database
Expand Down Expand Up @@ -108,6 +114,14 @@ spec:
- type
type: object
type: array
currentSecret:
description: |-
the Secret that's currently in use for the account.
keeping a handle to this secret allows us to remove its finalizer
when it's replaced with a new one. It also is useful for storing
the current "root" secret separate from a newly proposed one which is
needed when changing the database root password.
type: string
hash:
additionalProperties:
type: string
Expand Down
3 changes: 1 addition & 2 deletions controllers/galera_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,8 @@ func (r *GaleraReconciler) SetupWithManager(mgr ctrl.Manager) error {
Complete(r)
}

// GetDatabaseObject - returns either a Galera or MariaDB object (and an associated client.Object interface).
// GetDatabaseObject - returns a Galera object.
// used by both MariaDBDatabaseReconciler and MariaDBAccountReconciler
// this will later return only Galera objects, so as a lookup it's part of the galera controller
func GetDatabaseObject(ctx context.Context, clientObj client.Client, name string, namespace string) (*mariadbv1.Galera, error) {
dbGalera := &mariadbv1.Galera{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading