Skip to content

Commit

Permalink
Changes as per suggestion and clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Parth Patel <p.patel81@yahoo.com>
  • Loading branch information
ppatel1604 committed Feb 5, 2024
1 parent 41cd1d3 commit 1467a9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
},
},
},
Expand Down
7 changes: 2 additions & 5 deletions pkg/controllers/clusterexternalsecret/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit 1467a9b

Please sign in to comment.