mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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>
This commit is contained in:
parent
ceef9ff3a5
commit
b8568a5bb9
@ -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