NewMasterKeyFromKeyIDString takes a comma separated list of HuaweiCloud KMS key IDs in format "region:key-uuid", and returns a slice of new MasterKeys.
(keyID string)
| 77 | // NewMasterKeyFromKeyIDString takes a comma separated list of HuaweiCloud KMS |
| 78 | // key IDs in format "region:key-uuid", and returns a slice of new MasterKeys. |
| 79 | func NewMasterKeyFromKeyIDString(keyID string) ([]*MasterKey, error) { |
| 80 | var keys []*MasterKey |
| 81 | if keyID == "" { |
| 82 | return keys, nil |
| 83 | } |
| 84 | for _, s := range strings.Split(keyID, ",") { |
| 85 | s = strings.TrimSpace(s) |
| 86 | if s == "" { |
| 87 | continue |
| 88 | } |
| 89 | k, err := NewMasterKey(s) |
| 90 | if err != nil { |
| 91 | return nil, err |
| 92 | } |
| 93 | keys = append(keys, k) |
| 94 | } |
| 95 | return keys, nil |
| 96 | } |
| 97 | |
| 98 | // parseKeyID parses a key ID in format "region:key-uuid" and returns the region and UUID. |
| 99 | func parseKeyID(keyID string) (string, string, error) { |