mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
util: log available configs when KMS not found
When the KMS configuration can not be found, it is useful to know what configurations are available. This aids troubleshooting when typos in the KMS ID are made. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
a7c261a394
commit
bd1388fb96
@ -67,7 +67,7 @@ func GetKMS(tenant, kmsID string, secrets map[string]string) (EncryptionKMS, err
|
||||
section, ok := config[kmsID]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("could not get KMS configuration "+
|
||||
"for %q", kmsID)
|
||||
"for %q (have %v)", kmsID, getKeys(config))
|
||||
}
|
||||
|
||||
// kmsConfig can have additional sub-sections
|
||||
|
@ -319,3 +319,17 @@ func contains(s []string, key string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// getKeys takes a map that uses strings for keys and returns a slice with the
|
||||
// keys.
|
||||
func getKeys(m map[string]interface{}) []string {
|
||||
keys := make([]string, len(m))
|
||||
|
||||
i := 0
|
||||
for k := range m {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user