Skip to content

Commit

Permalink
Add user management to MariaDB
Browse files Browse the repository at this point in the history
It's now possible to do user management with MariaDB. The logic is
exactly the same as with PostgreSQL.
  • Loading branch information
Kidswiss committed Oct 15, 2024
1 parent 88cb04c commit c4e44ee
Show file tree
Hide file tree
Showing 17 changed files with 553 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apis/vshn/v1/dbaas_vshn_mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ type VSHNMariaDBServiceSpec struct {
// ServiceLevel defines the service level of this service. Either Best Effort or Guaranteed Availability is allowed.
ServiceLevel VSHNDBaaSServiceLevel `json:"serviceLevel,omitempty"`

// +kubebuilder:default="standalone"
// +kubebuilder:validation:Enum=replication;standalone
// Access defines additional users and databases for this instance.
Access []VSHNAccess `json:"access,omitempty"`
}

// VSHNMariaDBTLSSpec contains settings to control tls traffic of a service.
Expand Down
1 change: 1 addition & 0 deletions apis/vshn/v1/dbaas_vshn_postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ type VSHNPostgreSQLServiceSpec struct {
// +kubebuilder:default=false
VacuumEnabled bool `json:"vacuumEnabled,omitempty"`

// Access defines additional users and databases for this instance.
Access []VSHNAccess `json:"access,omitempty"`
}

Expand Down
9 changes: 8 additions & 1 deletion apis/vshn/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crds/vshn.appcat.vshn.io_vshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9776,6 +9776,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down
41 changes: 41 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnmariadbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4843,6 +4843,47 @@ spec:
service:
description: Service contains MariaDB DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
description: Database is the name of the database to create, defaults to user.
type: string
privileges:
description: |-
Privileges specifies the privileges to grant the user. Please check
the database's docs for available privileges.
items:
type: string
type: array
user:
description: |-
User specifies the username. If all other fields are left empty
then a new database with the same name and all permissions will be created.
type: string
writeConnectionSecretToRef:
description: |-
WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this user should
be written.
If not specified, a secret with the name $claimname-$username will be
created in the namespace where the claim is located.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
required:
- user
type: object
type: array
mariadbSettings:
description: MariadbSettings contains additional MariaDB settings.
type: string
Expand Down
1 change: 1 addition & 0 deletions crds/vshn.appcat.vshn.io_vshnnextclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9742,6 +9742,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down
1 change: 1 addition & 0 deletions crds/vshn.appcat.vshn.io_vshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4966,6 +4966,7 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases for this instance.
items:
properties:
database:
Expand Down
2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11556,6 +11556,8 @@ spec:
properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
Expand Down
43 changes: 43 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5567,6 +5567,49 @@ spec:
service:
description: Service contains MariaDB DBaaS specific properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
description: Database is the name of the database to
create, defaults to user.
type: string
privileges:
description: |-
Privileges specifies the privileges to grant the user. Please check
the database's docs for available privileges.
items:
type: string
type: array
user:
description: |-
User specifies the username. If all other fields are left empty
then a new database with the same name and all permissions will be created.
type: string
writeConnectionSecretToRef:
description: |-
WriteConnectionSecretToReference specifies the namespace and name of a
Secret to which any connection details for this user should
be written.
If not specified, a secret with the name $claimname-$username will be
created in the namespace where the claim is located.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
required:
- user
type: object
type: array
mariadbSettings:
description: MariadbSettings contains additional MariaDB settings.
type: string
Expand Down
2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11520,6 +11520,8 @@ spec:
properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
Expand Down
2 changes: 2 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5648,6 +5648,8 @@ spec:
description: Service contains PostgreSQL DBaaS specific properties
properties:
access:
description: Access defines additional users and databases
for this instance.
items:
properties:
database:
Expand Down
4 changes: 4 additions & 0 deletions pkg/comp-functions/functions/vshnmariadb/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func init() {
Name: "billing",
Execute: AddServiceBillingLabel,
},
{
Name: "user-management",
Execute: UserManagement,
},
},
})
}
Loading

0 comments on commit c4e44ee

Please sign in to comment.