diff --git a/api/v1alpha1/mysqlcluster_types.go b/api/v1alpha1/mysqlcluster_types.go index 19d4d0ed..8ee0482f 100644 --- a/api/v1alpha1/mysqlcluster_types.go +++ b/api/v1alpha1/mysqlcluster_types.go @@ -165,6 +165,12 @@ type MysqlOpts struct { // +optional MysqlConf MysqlConf `json:"mysqlConf,omitempty"` + // A []string that will be passed to my.cnf file + // The string array is persisted in the configmap. + // Delete key is not valid, it is recommended to edit the configmap directly. + // +optional + MysqlBoolConf MysqlBoolConfig `json:"mysqlBoolConf,omitempty"` + // A map[string]string that will be passed to plugin.cnf file. // The key/value pairs is persisted in the configmap. // Delete key is not valid, it is recommended to edit the configmap directly. @@ -234,6 +240,9 @@ type MetricsOpts struct { // string and string. type MysqlConf map[string]string +// MysqlBoolConfig defines type for extra cluster bool configs. It's a string array. +type MysqlBoolConfig []string + // PodPolicy defines the general configuration and extra resources of pod. type PodPolicy struct { // +kubebuilder:validation:Enum=Always;IfNotPresent;Never diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index db850e7c..66570e03 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -207,6 +207,25 @@ func (in *MySQLUserCondition) DeepCopy() *MySQLUserCondition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in MysqlBoolConfig) DeepCopyInto(out *MysqlBoolConfig) { + { + in := &in + *out = make(MysqlBoolConfig, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MysqlBoolConfig. +func (in MysqlBoolConfig) DeepCopy() MysqlBoolConfig { + if in == nil { + return nil + } + out := new(MysqlBoolConfig) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MysqlCluster) DeepCopyInto(out *MysqlCluster) { *out = *in @@ -361,6 +380,11 @@ func (in *MysqlOpts) DeepCopyInto(out *MysqlOpts) { (*out)[key] = val } } + if in.MysqlBoolConf != nil { + in, out := &in.MysqlBoolConf, &out.MysqlBoolConf + *out = make(MysqlBoolConfig, len(*in)) + copy(*out, *in) + } if in.PluginConf != nil { in, out := &in.PluginConf, &out.PluginConf *out = make(MysqlConf, len(*in)) diff --git a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml index 0f76cc53..f7c6b726 100644 --- a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml +++ b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml @@ -176,6 +176,13 @@ spec: the mysqld container will not be not healthy. minimum: 0 type: integer + mysqlBoolConf: + description: A []string that will be passed to my.cnf file The + string array is persisted in the configmap. Delete key is not + valid, it is recommended to edit the configmap directly. + items: + type: string + type: array mysqlConf: additionalProperties: type: string diff --git a/mysqlcluster/syncer/mysql_cm.go b/mysqlcluster/syncer/mysql_cm.go index 151d2675..20c215ce 100644 --- a/mysqlcluster/syncer/mysql_cm.go +++ b/mysqlcluster/syncer/mysql_cm.go @@ -270,6 +270,13 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) { log.Error(err, "failed to add boolean key to config section", "key", key) } } + if len(c.Spec.MysqlOpts.MysqlBoolConf) != 0 { + for _, key := range c.Spec.MysqlOpts.MysqlBoolConf { + if _, err := sec.NewBooleanKey(key); err != nil { + log.Error(err, "failed to add boolean key to config section", "key", key) + } + } + } if len(c.Spec.TlsSecretName) != 0 { addKVConfigsToSection(sec, mysqlSSLConfigs) }