baremetal: refactor createMariadbPasswordSecret()
@@ -85,7 +85,10 @@ func generateRandomPassword() (string, error) {
func createMariadbPasswordSecret(client coreclientv1.SecretsGetter, config *OperatorConfig) error {
glog.V(3).Info("Checking if the MariaDB password secret already exists")
_, err := client.Secrets(config.TargetNamespace).Get(context.Background(), baremetalSecretName, metav1.GetOptions{})
- if apierrors.IsNotFound(err) {
+ if !apierrors.IsNotFound(err) {
+ return err
+ }
+
// Secret does not already exist. So, create one.
password, err := generateRandomPassword()
if err != nil {
@@ -106,8 +109,6 @@ func createMariadbPasswordSecret(client coreclientv1.SecretsGetter, config *Oper
)
return err
}
- return err
-}
func newMetal3Deployment(config *OperatorConfig, baremetalProvisioningConfig BaremetalProvisioningConfig) *appsv1.Deployment {
replicas := int32(1)
