validateProviderCredentialList checks that a list of credentials belonging to a provider is well-formed: no empty values, no duplicates, and within the maximum count. Trims whitespace in place.
(providerIndex int, providerType string, keys []string)
| 3303 | // duplicates, and within the maximum count. Trims whitespace in |
| 3304 | // place. |
| 3305 | func validateProviderCredentialList(providerIndex int, providerType string, keys []string) error { |
| 3306 | if len(keys) > maxKeysPerProvider { |
| 3307 | return xerrors.Errorf("provider %d (%s): too many keys (%d), maximum is %d", |
| 3308 | providerIndex, providerType, len(keys), maxKeysPerProvider) |
| 3309 | } |
| 3310 | |
| 3311 | seen := make(map[string]struct{}, len(keys)) |
| 3312 | for i, key := range keys { |
| 3313 | trimmed := strings.TrimSpace(key) |
| 3314 | if trimmed == "" { |
| 3315 | return xerrors.Errorf("provider %d (%s): key at index %d is empty", |
| 3316 | providerIndex, providerType, i) |
| 3317 | } |
| 3318 | keys[i] = trimmed |
| 3319 | if _, exists := seen[trimmed]; exists { |
| 3320 | return xerrors.Errorf("provider %d (%s): duplicate key at index %d", |
| 3321 | providerIndex, providerType, i) |
| 3322 | } |
| 3323 | seen[trimmed] = struct{}{} |
| 3324 | } |
| 3325 | |
| 3326 | return nil |
| 3327 | } |
| 3328 | |
| 3329 | // validateBedrockCredentials checks that Bedrock access keys and |
| 3330 | // secrets are paired correctly (same count) and that each list is |
no test coverage detected