Add a check for nil secrets

Improve the error message if
secrets are not provided in request

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2019-09-25 20:15:19 +05:30 committed by mergify[bot]
parent ceef9ff3a5
commit b8568a5bb9

View File

@ -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)
}