Browse Source

Changes as per suggestion and clean up (#3077)

Signed-off-by: Parth Patel <p.patel81@yahoo.com>
Parth Patel 2 years ago
parent
commit
8db12430e7

+ 1 - 2
pkg/controllers/clusterexternalsecret/clusterexternalsecret_controller.go

@@ -59,7 +59,6 @@ const (
 	errNamespaces           = "could not get namespaces from selector"
 	errGetExistingES        = "could not get existing ExternalSecret"
 	errNamespacesFailed     = "one or more namespaces failed"
-	errNamespaceNotFound    = "no namespace matches"
 )
 
 func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
@@ -179,7 +178,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		provisionedNamespaces = append(provisionedNamespaces, namespace.Name)
 	}
 
-	condition := NewClusterExternalSecretCondition(failedNamespaces, &namespaceList)
+	condition := NewClusterExternalSecretCondition(failedNamespaces)
 	SetClusterExternalSecretCondition(&clusterExternalSecret, *condition)
 
 	clusterExternalSecret.Status.FailedNamespaces = toNamespaceFailures(failedNamespaces)

+ 3 - 4
pkg/controllers/clusterexternalsecret/clusterexternalsecret_controller_test.go

@@ -634,7 +634,7 @@ var _ = Describe("ClusterExternalSecret controller", func() {
 				}
 			},
 		}),
-		Entry("Should not be ready if no namespace matches", testCase{
+		Entry("Should be ready if no namespace matches", testCase{
 			namespaces: []v1.Namespace{
 				{
 					ObjectMeta: metav1.ObjectMeta{
@@ -659,9 +659,8 @@ var _ = Describe("ClusterExternalSecret controller", func() {
 						ExternalSecretName: created.Name,
 						Conditions: []esv1beta1.ClusterExternalSecretStatusCondition{
 							{
-								Type:    esv1beta1.ClusterExternalSecretReady,
-								Status:  v1.ConditionFalse,
-								Message: errNamespaceNotFound,
+								Type:   esv1beta1.ClusterExternalSecretReady,
+								Status: v1.ConditionTrue,
 							},
 						},
 					},

+ 2 - 5
pkg/controllers/clusterexternalsecret/util.go

@@ -21,8 +21,8 @@ import (
 	"github.com/external-secrets/external-secrets/pkg/controllers/clusterexternalsecret/cesmetrics"
 )
 
-func NewClusterExternalSecretCondition(failedNamespaces map[string]error, namespaceList *v1.NamespaceList) *esv1beta1.ClusterExternalSecretStatusCondition {
-	if len(namespaceList.Items) > 0 && len(failedNamespaces) == 0 {
+func NewClusterExternalSecretCondition(failedNamespaces map[string]error) *esv1beta1.ClusterExternalSecretStatusCondition {
+	if len(failedNamespaces) == 0 {
 		return &esv1beta1.ClusterExternalSecretStatusCondition{
 			Type:   esv1beta1.ClusterExternalSecretReady,
 			Status: v1.ConditionTrue,
@@ -34,9 +34,6 @@ func NewClusterExternalSecretCondition(failedNamespaces map[string]error, namesp
 		Status:  v1.ConditionFalse,
 		Message: errNamespacesFailed,
 	}
-	if len(failedNamespaces) == 0 {
-		condition.Message = errNamespaceNotFound
-	}
 
 	return condition
 }