mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
A couple follow-ups from #23948 --------- Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
+12
-9
@@ -2961,9 +2961,10 @@ func ReadAIBridgeProvidersFromEnv(logger slog.Logger, environ []string) ([]coder
|
||||
provider.Type = v.Value
|
||||
case "NAME":
|
||||
provider.Name = v.Value
|
||||
case "KEY": // Alias for a single key.
|
||||
provider.Key = v.Value
|
||||
case "KEYS":
|
||||
case "KEY", "KEYS":
|
||||
if provider.Key != "" {
|
||||
return nil, xerrors.Errorf("provider %d: KEY and KEYS are mutually exclusive, use one or the other", providerNum)
|
||||
}
|
||||
provider.Key = v.Value
|
||||
case "BASE_URL":
|
||||
provider.BaseURL = v.Value
|
||||
@@ -2971,13 +2972,15 @@ func ReadAIBridgeProvidersFromEnv(logger slog.Logger, environ []string) ([]coder
|
||||
provider.BedrockBaseURL = v.Value
|
||||
case "BEDROCK_REGION":
|
||||
provider.BedrockRegion = v.Value
|
||||
case "BEDROCK_ACCESS_KEY": // Alias for a single key.
|
||||
case "BEDROCK_ACCESS_KEY", "BEDROCK_ACCESS_KEYS":
|
||||
if provider.BedrockAccessKey != "" {
|
||||
return nil, xerrors.Errorf("provider %d: BEDROCK_ACCESS_KEY and BEDROCK_ACCESS_KEYS are mutually exclusive, use one or the other", providerNum)
|
||||
}
|
||||
provider.BedrockAccessKey = v.Value
|
||||
case "BEDROCK_ACCESS_KEYS":
|
||||
provider.BedrockAccessKey = v.Value
|
||||
case "BEDROCK_ACCESS_KEY_SECRET": // Alias for a single key secret.
|
||||
provider.BedrockAccessKeySecret = v.Value
|
||||
case "BEDROCK_ACCESS_KEY_SECRETS":
|
||||
case "BEDROCK_ACCESS_KEY_SECRET", "BEDROCK_ACCESS_KEY_SECRETS":
|
||||
if provider.BedrockAccessKeySecret != "" {
|
||||
return nil, xerrors.Errorf("provider %d: BEDROCK_ACCESS_KEY_SECRET and BEDROCK_ACCESS_KEY_SECRETS are mutually exclusive, use one or the other", providerNum)
|
||||
}
|
||||
provider.BedrockAccessKeySecret = v.Value
|
||||
case "BEDROCK_MODEL":
|
||||
provider.BedrockModel = v.Value
|
||||
|
||||
@@ -194,6 +194,33 @@ func TestReadAIBridgeProvidersFromEnv(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ConflictKeyAndKeys",
|
||||
env: []string{
|
||||
"CODER_AIBRIDGE_PROVIDER_0_TYPE=openai",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_KEY=sk-single",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_KEYS=sk-multi",
|
||||
},
|
||||
errContains: "KEY and KEYS are mutually exclusive",
|
||||
},
|
||||
{
|
||||
name: "ConflictBedrockAccessKeyAndKeys",
|
||||
env: []string{
|
||||
"CODER_AIBRIDGE_PROVIDER_0_TYPE=anthropic",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_BEDROCK_ACCESS_KEY=AKID1",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_BEDROCK_ACCESS_KEYS=AKID2",
|
||||
},
|
||||
errContains: "BEDROCK_ACCESS_KEY and BEDROCK_ACCESS_KEYS are mutually exclusive",
|
||||
},
|
||||
{
|
||||
name: "ConflictBedrockSecretAndSecrets",
|
||||
env: []string{
|
||||
"CODER_AIBRIDGE_PROVIDER_0_TYPE=anthropic",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_BEDROCK_ACCESS_KEY_SECRET=s1",
|
||||
"CODER_AIBRIDGE_PROVIDER_0_BEDROCK_ACCESS_KEY_SECRETS=s2",
|
||||
},
|
||||
errContains: "BEDROCK_ACCESS_KEY_SECRET and BEDROCK_ACCESS_KEY_SECRETS are mutually exclusive",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user