parseKeyID parses a key ID in format "region:key-uuid" and returns the region and UUID.
(keyID string)
| 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) { |
| 100 | keyID = strings.TrimSpace(keyID) |
| 101 | parts := strings.SplitN(keyID, ":", 2) |
| 102 | if len(parts) != 2 { |
| 103 | return "", "", fmt.Errorf("invalid key ID format: expected 'region:key-uuid', got %q", keyID) |
| 104 | } |
| 105 | region := strings.TrimSpace(parts[0]) |
| 106 | keyUUID := strings.TrimSpace(parts[1]) |
| 107 | if region == "" { |
| 108 | return "", "", fmt.Errorf("region cannot be empty in key ID: %q", keyID) |
| 109 | } |
| 110 | if keyUUID == "" { |
| 111 | return "", "", fmt.Errorf("key UUID cannot be empty in key ID: %q", keyID) |
| 112 | } |
| 113 | return region, keyUUID, nil |
| 114 | } |
| 115 | |
| 116 | // Credentials is a wrapper around auth.ICredential used for authentication |
| 117 | // towards HuaweiCloud KMS. |