mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
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>
(cherry picked from commit b8568a5bb9
)
This commit is contained in:
parent
756a650cd1
commit
454394322a
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user