Просмотр исходного кода

feat: increase verbosity of error message during validation (#3742)

* feat: increase verbosity of error message during validation

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

* removing Equal as we do not have the specific error message there

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

---------

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Gergely Brautigam 1 год назад
Родитель
Сommit
2b51f8a8e1
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 1
      e2e/suites/provider/cases/vault/vault.go
  2. 2 2
      pkg/controllers/secretstore/common.go

+ 1 - 1
e2e/suites/provider/cases/vault/vault.go

@@ -292,7 +292,7 @@ func testInvalidMtlsStore(tc *framework.TestCase) {
 		Expect(string(ss.Status.Conditions[0].Type)).Should(Equal("Ready"))
 		Expect(string(ss.Status.Conditions[0].Status)).Should(Equal("False"))
 		Expect(ss.Status.Conditions[0].Reason).Should(Equal("ValidationFailed"))
-		Expect(ss.Status.Conditions[0].Message).Should(Equal("unable to validate store"))
+		Expect(ss.Status.Conditions[0].Message).Should(ContainSubstring("unable to validate store"))
 		return true, nil
 	})
 	Expect(err).ToNot(HaveOccurred())

+ 2 - 2
pkg/controllers/secretstore/common.go

@@ -35,7 +35,7 @@ const (
 	errValidationFailed    = "could not validate provider: %w"
 	errPatchStatus         = "unable to patch status: %w"
 	errUnableCreateClient  = "unable to create client"
-	errUnableValidateStore = "unable to validate store"
+	errUnableValidateStore = "unable to validate store: %s"
 	errUnableGetProvider   = "unable to get store provider"
 
 	msgStoreValidated = "store validated"
@@ -103,7 +103,7 @@ func validateStore(ctx context.Context, namespace, controllerClass string, store
 	}
 	validationResult, err := cl.Validate()
 	if err != nil && validationResult != esapi.ValidationResultUnknown {
-		cond := NewSecretStoreCondition(esapi.SecretStoreReady, v1.ConditionFalse, esapi.ReasonValidationFailed, errUnableValidateStore)
+		cond := NewSecretStoreCondition(esapi.SecretStoreReady, v1.ConditionFalse, esapi.ReasonValidationFailed, fmt.Sprintf(errUnableValidateStore, err))
 		SetExternalSecretCondition(store, *cond, gaugeVecGetter)
 		recorder.Event(store, v1.EventTypeWarning, esapi.ReasonValidationFailed, err.Error())
 		return fmt.Errorf(errValidationFailed, err)