(auth *coreauth.Auth)
| 2221 | } |
| 2222 | |
| 2223 | func (s *Service) resolveConfigGeminiKey(auth *coreauth.Auth) *config.GeminiKey { |
| 2224 | if auth == nil || s.cfg == nil { |
| 2225 | return nil |
| 2226 | } |
| 2227 | var attrKey, attrBase string |
| 2228 | if auth.Attributes != nil { |
| 2229 | attrKey = strings.TrimSpace(auth.Attributes["api_key"]) |
| 2230 | attrBase = strings.TrimSpace(auth.Attributes["base_url"]) |
| 2231 | } |
| 2232 | for i := range s.cfg.GeminiKey { |
| 2233 | entry := &s.cfg.GeminiKey[i] |
| 2234 | cfgKey := strings.TrimSpace(entry.APIKey) |
| 2235 | cfgBase := strings.TrimSpace(entry.BaseURL) |
| 2236 | if attrKey != "" && strings.EqualFold(cfgKey, attrKey) { |
| 2237 | if cfgBase == "" || strings.EqualFold(cfgBase, attrBase) { |
| 2238 | return entry |
| 2239 | } |
| 2240 | continue |
| 2241 | } |
| 2242 | if attrKey == "" && attrBase != "" && strings.EqualFold(cfgBase, attrBase) { |
| 2243 | return entry |
| 2244 | } |
| 2245 | } |
| 2246 | return nil |
| 2247 | } |
| 2248 | |
| 2249 | func (s *Service) resolveConfigVertexCompatKey(auth *coreauth.Auth) *config.VertexCompatKey { |
| 2250 | if auth == nil || s.cfg == nil { |
no outgoing calls
no test coverage detected