Skip to content

Commit 6fb96fd

Browse files
Merge pull request #173 from zzzeek/remove_standalone_mariadb
Remove MariaDB CRD
2 parents d5c0d27 + 8af0ab9 commit 6fb96fd

37 files changed

+97
-1580
lines changed

PROJECT

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ plugins:
1111
projectName: mariadb-operator
1212
repo: github.com/openstack-k8s-operators/mariadb-operator
1313
resources:
14-
- api:
15-
crdVersion: v1
16-
namespaced: true
17-
controller: true
18-
domain: openstack.org
19-
group: mariadb
20-
kind: MariaDB
21-
path: github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1
22-
version: v1beta1
23-
webhooks:
24-
defaulting: true
25-
validation: true
26-
webhookVersion: v1
2714
- api:
2815
crdVersion: v1
2916
namespaced: true

api/bases/mariadb.openstack.org_mariadbs.yaml

Lines changed: 0 additions & 129 deletions
This file was deleted.

api/v1beta1/galera_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ package v1beta1
1818

1919
import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
21+
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223
)
2324

2425
const (
2526
// CustomServiceConfigFile name of the additional mariadb config file
2627
CustomServiceConfigFile = "galera_custom.cnf.in"
28+
29+
// GaleraContainerImage is the fall-back container image for Galera
30+
GaleraContainerImage = "quay.io/podified-antelope-centos9/openstack-mariadb:current-podified"
2731
)
2832

33+
// AdoptionRedirectSpec defines redirection to a different DB instance during Adoption
34+
type AdoptionRedirectSpec struct {
35+
// MariaDB host to redirect to (IP or name)
36+
Host string `json:"host,omitempty"`
37+
}
38+
2939
// GaleraSpec defines the desired state of Galera
3040
type GaleraSpec struct {
3141
// Name of the secret to look for password keys
@@ -130,3 +140,13 @@ func (instance Galera) RbacNamespace() string {
130140
func (instance Galera) RbacResourceName() string {
131141
return "galera-" + instance.Name
132142
}
143+
144+
// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
145+
func SetupDefaults() {
146+
// Acquire environmental defaults and initialize Keystone defaults with them
147+
galeraDefaults := GaleraDefaults{
148+
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT", GaleraContainerImage),
149+
}
150+
151+
SetupGaleraDefaults(galeraDefaults)
152+
}

api/v1beta1/galera_webhook.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ import (
2626
// log is for logging in this package.
2727
var galeralog = logf.Log.WithName("galera-resource")
2828

29+
// GaleraDefaults -
30+
type GaleraDefaults struct {
31+
ContainerImageURL string
32+
}
33+
34+
var galeraDefaults GaleraDefaults
35+
2936
// SetupWebhookWithManager sets up the webhook with the Manager
3037
func (r *Galera) SetupWebhookWithManager(mgr ctrl.Manager) error {
3138
return ctrl.NewWebhookManagedBy(mgr).
@@ -47,7 +54,7 @@ func (r *Galera) Default() {
4754
// Default - set defaults for this MariaDB spec
4855
func (spec *GaleraSpec) Default() {
4956
if spec.ContainerImage == "" {
50-
spec.ContainerImage = mariaDBDefaults.ContainerImageURL
57+
spec.ContainerImage = galeraDefaults.ContainerImageURL
5158
}
5259
}
5360

@@ -79,3 +86,9 @@ func (r *Galera) ValidateDelete() error {
7986
// TODO(user): fill in your validation logic upon object deletion.
8087
return nil
8188
}
89+
90+
// SetupGaleraDefaults - initialize MariaDB spec defaults for use with either internal or external webhooks
91+
func SetupGaleraDefaults(defaults GaleraDefaults) {
92+
galeraDefaults = defaults
93+
galeralog.Info("Galera defaults initialized", "defaults", defaults)
94+
}

api/v1beta1/mariadb_types.go

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)