Browse Source

better failing (#12)

pull/14/head
Vladimir Smagin 1 year ago
committed by GitHub
parent
commit
4d1b5ba3e2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 9 deletions
  1. +13
    -1
      pkg/controller/rabbitmq/rabbitmq_configmaps.go
  2. +8
    -8
      pkg/controller/rabbitmq/rabbitmq_secrets.go

+ 13
- 1
pkg/controller/rabbitmq/rabbitmq_configmaps.go View File

@@ -85,11 +85,23 @@ func (r *ReconcileRabbitmq) reconcileConfigMap(reqLogger logr.Logger, cr *rabbit
}

defaultUsername := string(secretObj.Data["username"])
if defaultUsername == "" {
reqLogger.Info("Empty service username", "ConfigMap.Namespace", cr.Namespace, "ConfigMap.Name", cr.Name)
return reconcile.Result{}, err
}
templateData.DefaultUser = defaultUsername
defaultPassword := string(secretObj.Data["password"])
if defaultPassword == "" {
reqLogger.Info("Empty service password", "ConfigMap.Namespace", cr.Namespace, "ConfigMap.Name", cr.Name)
return reconcile.Result{}, err
}
templateData.DefaultPassword = defaultPassword
cookieData := string(secretObj.Data["cookie"])
reqLogger.Info("Configmap decoded secret", "ConfigMap.Namespace", cr.Namespace, "ConfigMap.Name", cr.Name, "Secret decoded", cookieData)
if cookieData == "" {
reqLogger.Info("Empty cookie data", "ConfigMap.Namespace", cr.Namespace, "ConfigMap.Name", cr.Name)
return reconcile.Result{}, err
}
reqLogger.Info("Configmap decoded secret", "ConfigMap.Namespace", cr.Namespace, "ConfigMap.Name", cr.Name, "Secret cookie", cookieData)

templateData.Spec = cr.Spec



+ 8
- 8
pkg/controller/rabbitmq/rabbitmq_secrets.go View File

@@ -65,7 +65,7 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
} else if err != nil {
// happend something else, do nothing
reqLogger.Info("Service Account linked: error happend", err)
return secretNames, err
return secretResouces{}, err
}
} else {
// link empty, search standart service account secret
@@ -80,7 +80,7 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
} else if err != nil {
// happend something else, do nothing
reqLogger.Info("Service Account standart: error happend", err)
return secretNames, err
return secretResouces{}, err
}
}

@@ -101,13 +101,13 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
}

if err := controllerutil.SetControllerReference(cr, secretSAResource, r.scheme); err != nil {
return secretNames, err
return secretResouces{}, err
}

err := r.client.Create(context.TODO(), secretSAResource)

if err != nil {
return secretNames, err
return secretResouces{}, err
}

}
@@ -130,7 +130,7 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
} else if err != nil {
// happend something else, do nothing
reqLogger.Info("User credentials: error happend", err)
return secretNames, err
return secretResouces{}, err
}
secretNames.Credentials = cr.Spec.RabbitmqSecretCredentials
} else {
@@ -145,7 +145,7 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
} else if err != nil {
// happend something else, do nothing
reqLogger.Info("User credentials standart: error happend", err)
return secretNames, err
return secretResouces{}, err
}
}

@@ -162,12 +162,12 @@ func (r *ReconcileRabbitmq) reconcileSecrets(reqLogger logr.Logger, cr *rabbitmq
}

if err := controllerutil.SetControllerReference(cr, secretCredResourceNew, r.scheme); err != nil {
return secretNames, err
return secretResouces{}, err
}

err := r.client.Create(context.TODO(), secretCredResourceNew)
if err != nil {
return secretNames, err
return secretResouces{}, err
}

}


Loading…
Cancel
Save