From b8568a5bb992287259e832fd7b099a0e85614929 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 25 Sep 2019 20:15:19 +0530 Subject: [PATCH] Add a check for nil secrets Improve the error message if secrets are not provided in request Signed-off-by: Madhu Rajanna --- pkg/util/credentials.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/util/credentials.go b/pkg/util/credentials.go index 63f0891bb..7892fb521 100644 --- a/pkg/util/credentials.go +++ b/pkg/util/credentials.go @@ -17,6 +17,7 @@ limitations under the License. package util import ( + "errors" "fmt" "io/ioutil" "os" @@ -72,6 +73,9 @@ func newCredentialsFromSecret(idField, keyField string, secrets map[string]strin ok bool ) + if len(secrets) == 0 { + return nil, errors.New("provided secret is empty") + } if c.ID, ok = secrets[idField]; !ok { return nil, fmt.Errorf("missing ID field '%s' in secrets", idField) }