MCPcopy Index your code
hub / github.com/chainreactors/EvilProxy / authDataWithDefaults

Function authDataWithDefaults

internal/pluginhost/adapters.go:402–453  ·  view source on GitHub ↗
(data pluginapi.AuthData, auth *coreauth.Auth)

Source from the content-addressed store, hash-verified

400}
401
402func authDataWithDefaults(data pluginapi.AuthData, auth *coreauth.Auth) pluginapi.AuthData {
403 if auth == nil {
404 return data
405 }
406 if strings.TrimSpace(data.Provider) == "" {
407 data.Provider = auth.Provider
408 }
409 if strings.TrimSpace(data.ID) == "" {
410 data.ID = auth.ID
411 }
412 if strings.TrimSpace(data.FileName) == "" {
413 data.FileName = auth.FileName
414 }
415 if strings.TrimSpace(data.Label) == "" {
416 data.Label = auth.Label
417 }
418 if strings.TrimSpace(data.Prefix) == "" {
419 data.Prefix = auth.Prefix
420 }
421 if strings.TrimSpace(data.ProxyURL) == "" {
422 data.ProxyURL = auth.ProxyURL
423 }
424 if len(data.Metadata) == 0 {
425 data.Metadata = cloneAnyMap(auth.Metadata)
426 } else {
427 metadata := cloneAnyMap(data.Metadata)
428 for key, value := range auth.Metadata {
429 if _, exists := metadata[key]; !exists {
430 metadata[key] = value
431 }
432 }
433 data.Metadata = metadata
434 }
435 if len(data.Attributes) == 0 {
436 data.Attributes = cloneStringMap(auth.Attributes)
437 } else {
438 attributes := cloneStringMap(data.Attributes)
439 for key, value := range auth.Attributes {
440 if _, exists := attributes[key]; !exists {
441 attributes[key] = value
442 }
443 }
444 data.Attributes = attributes
445 }
446 if len(data.StorageJSON) == 0 {
447 data.StorageJSON = storageJSONFromAuth(auth)
448 }
449 if data.NextRefreshAfter.IsZero() {
450 data.NextRefreshAfter = auth.NextRefreshAfter
451 }
452 return data
453}
454
455type modelClientRegistration struct {
456 clientID string

Callers 1

ModelsForAuthMethod · 0.85

Calls 3

cloneAnyMapFunction · 0.85
cloneStringMapFunction · 0.85
storageJSONFromAuthFunction · 0.85

Tested by

no test coverage detected