@@ -30,26 +30,27 @@ import (
3030
3131// PerconaXtraDBClusterSpec defines the desired state of PerconaXtraDBCluster
3232type PerconaXtraDBClusterSpec struct {
33- Platform version.Platform `json:"platform,omitempty"`
34- CRVersion string `json:"crVersion,omitempty"`
35- Pause bool `json:"pause,omitempty"`
36- SecretsName string `json:"secretsName,omitempty"`
37- VaultSecretName string `json:"vaultSecretName,omitempty"`
38- SSLSecretName string `json:"sslSecretName,omitempty"`
39- SSLInternalSecretName string `json:"sslInternalSecretName,omitempty"`
40- LogCollectorSecretName string `json:"logCollectorSecretName,omitempty"`
41- TLS * TLSSpec `json:"tls,omitempty"`
42- PXC * PXCSpec `json:"pxc,omitempty"`
43- ProxySQL * ProxySQLSpec `json:"proxysql,omitempty"`
44- HAProxy * HAProxySpec `json:"haproxy,omitempty"`
45- PMM * PMMSpec `json:"pmm,omitempty"`
46- LogCollector * LogCollectorSpec `json:"logcollector,omitempty"`
47- Backup * BackupSpec `json:"backup,omitempty"`
48- UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"`
49- UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
50- AllowUnsafeConfig bool `json:"allowUnsafeConfigurations,omitempty"`
51- Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
52- VolumeExpansionEnabled bool `json:"enableVolumeExpansion,omitempty"`
33+ Platform version.Platform `json:"platform,omitempty"`
34+ CRVersion string `json:"crVersion,omitempty"`
35+ Pause bool `json:"pause,omitempty"`
36+ SecretsName string `json:"secretsName,omitempty"`
37+ PasswordGenerationOptions * PasswordGenerationOptions `json:"passwordGenerationOptions,omitempty"`
38+ VaultSecretName string `json:"vaultSecretName,omitempty"`
39+ SSLSecretName string `json:"sslSecretName,omitempty"`
40+ SSLInternalSecretName string `json:"sslInternalSecretName,omitempty"`
41+ LogCollectorSecretName string `json:"logCollectorSecretName,omitempty"`
42+ TLS * TLSSpec `json:"tls,omitempty"`
43+ PXC * PXCSpec `json:"pxc,omitempty"`
44+ ProxySQL * ProxySQLSpec `json:"proxysql,omitempty"`
45+ HAProxy * HAProxySpec `json:"haproxy,omitempty"`
46+ PMM * PMMSpec `json:"pmm,omitempty"`
47+ LogCollector * LogCollectorSpec `json:"logcollector,omitempty"`
48+ Backup * BackupSpec `json:"backup,omitempty"`
49+ UpdateStrategy appsv1.StatefulSetUpdateStrategyType `json:"updateStrategy,omitempty"`
50+ UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
51+ AllowUnsafeConfig bool `json:"allowUnsafeConfigurations,omitempty"`
52+ Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
53+ VolumeExpansionEnabled bool `json:"enableVolumeExpansion,omitempty"`
5354
5455 // Deprecated, should be removed in the future. Use InitContainer.Image instead
5556 InitImage string `json:"initImage,omitempty"`
@@ -62,6 +63,37 @@ type PerconaXtraDBClusterSpec struct {
6263 Users []User `json:"users,omitempty"`
6364}
6465
66+ // +kubebuilder:validation:XValidation:rule="self.maxLength > self.minLength"
67+ type PasswordGenerationOptions struct {
68+ // Special symbols to include in password generation
69+ // +kubebuilder:validation:Required
70+ // +kubebuilder:validation:MaxLength=32
71+ // +kubebuilder:default="!#$%&()*+,-.<=>?@[]^_{}~"
72+ Symbols string `json:"symbols"`
73+ // Max password length
74+ // +kubebuilder:validation:Required
75+ // +kubebuilder:validation:Maximum=32
76+ // +kubebuilder:validation:Minimum=8
77+ // +kubebuilder:default=20
78+ MaxLength int `json:"maxLength"`
79+ // Min password length
80+ // +kubebuilder:validation:Required
81+ // +kubebuilder:validation:Maximum=32
82+ // +kubebuilder:validation:Minimum=8
83+ // +kubebuilder:default=16
84+ MinLength int `json:"minLength"`
85+ }
86+
87+ func (cr * PerconaXtraDBCluster ) setPasswordGenerationOptionsDefaults () {
88+ if cr .Spec .PasswordGenerationOptions == nil {
89+ cr .Spec .PasswordGenerationOptions = & PasswordGenerationOptions {
90+ Symbols : "!#$%&()*+,-.<=>?@[]^_{}~" ,
91+ MaxLength : 20 ,
92+ MinLength : 16 ,
93+ }
94+ }
95+ }
96+
6597type SecretKeySelector struct {
6698 Name string `json:"name"`
6799 Key string `json:"key,omitempty"`
@@ -1194,6 +1226,7 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV
11941226
11951227 cr .setProbesDefaults ()
11961228 cr .setPodSecurityContext ()
1229+ cr .setPasswordGenerationOptionsDefaults ()
11971230
11981231 if cr .Spec .EnableCRValidationWebhook == nil {
11991232 falseVal := false
0 commit comments