()
| 85 | } |
| 86 | |
| 87 | func (p *Profile) GetAdminAPIKey() (string, error) { |
| 88 | if os.Getenv("ALGOLIA_ADMIN_API_KEY") != "" { |
| 89 | return os.Getenv("ALGOLIA_ADMIN_API_KEY"), nil |
| 90 | } |
| 91 | |
| 92 | if p.AdminAPIKey != "" { |
| 93 | return p.AdminAPIKey, nil |
| 94 | } |
| 95 | |
| 96 | if p.Name == "" { |
| 97 | p.LoadDefault() |
| 98 | } |
| 99 | |
| 100 | if err := viper.ReadInConfig(); err == nil { |
| 101 | adminAPIKey := viper.GetString(p.GetFieldName("admin_api_key")) |
| 102 | if adminAPIKey != "" { |
| 103 | return adminAPIKey, nil |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | return "", ErrAPIKeyNotConfigured |
| 108 | } |
| 109 | |
| 110 | func (p *Profile) GetSearchHosts() []string { |
| 111 | envHosts := os.Getenv("ALGOLIA_SEARCH_HOSTS") |
no test coverage detected