MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / ResolveAPIKey

Function ResolveAPIKey

internal/providers/providers.go:93–101  ·  view source on GitHub ↗

ResolveAPIKey resolves the endpoint's API key. A literal key stored on the endpoint (APIKey) wins; otherwise the value is read from the environment variable named by APIKeyEnv via the supplied env lookup function. Returns an empty string when neither is set. Callers should inject os.Getenv (or a tes

(e Endpoint, env func(string) string)

Source from the content-addressed store, hash-verified

91// empty string when neither is set. Callers should inject os.Getenv (or a test
92// stub) so this stays pure and easy to fake.
93func ResolveAPIKey(e Endpoint, env func(string) string) string {
94 if strings.TrimSpace(e.APIKey) != "" {
95 return e.APIKey
96 }
97 if e.APIKeyEnv == "" || env == nil {
98 return ""
99 }
100 return env(e.APIKeyEnv)
101}
102
103// ResolveAPIKeyEnv returns the environment-variable name that holds this
104// endpoint's API key. When the endpoint sets APIKeyEnv explicitly that name is

Callers 9

ResolveLaunchEnvFunction · 0.92
providerDTOFunction · 0.92
ApplyConfigMethod · 0.92
TestResolveAPIKeyFunction · 0.92
applyCommandMethod · 0.92
launchCommandMethod · 0.92
providerFromEndpointFunction · 0.92
fetchModelsURLFunction · 0.85
buildDiscoveryEnvFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestResolveAPIKeyFunction · 0.74