mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 14:50:24 +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
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -72,6 +73,9 @@ func newCredentialsFromSecret(idField, keyField string, secrets map[string]strin
|
|||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if len(secrets) == 0 {
|
||||||
|
return nil, errors.New("provided secret is empty")
|
||||||
|
}
|
||||||
if c.ID, ok = secrets[idField]; !ok {
|
if c.ID, ok = secrets[idField]; !ok {
|
||||||
return nil, fmt.Errorf("missing ID field '%s' in secrets", idField)
|
return nil, fmt.Errorf("missing ID field '%s' in secrets", idField)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user