MCPcopy Index your code
hub / github.com/getsops/sops / parseKeyID

Function parseKeyID

hckms/keysource.go:99–114  ·  view source on GitHub ↗

parseKeyID parses a key ID in format "region:key-uuid" and returns the region and UUID.

(keyID string)

Source from the content-addressed store, hash-verified

97
98// parseKeyID parses a key ID in format "region:key-uuid" and returns the region and UUID.
99func 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.

Callers 1

NewMasterKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected