GetCrawlerAPIKey returns the Crawler API key.
()
| 157 | |
| 158 | // GetCrawlerAPIKey returns the Crawler API key. |
| 159 | func (p *Profile) GetCrawlerAPIKey() (string, error) { |
| 160 | if os.Getenv("ALGOLIA_CRAWLER_API_KEY") != "" { |
| 161 | return os.Getenv("ALGOLIA_CRAWLER_API_KEY"), nil |
| 162 | } |
| 163 | |
| 164 | if p.Name == "" { |
| 165 | p.LoadDefault() |
| 166 | } |
| 167 | |
| 168 | if err := viper.ReadInConfig(); err == nil { |
| 169 | apiKey := viper.GetString(p.GetFieldName("crawler_api_key")) |
| 170 | if apiKey != "" { |
| 171 | return apiKey, nil |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | return "", ErrCrawlerAPIKeyNotConfigured |
| 176 | } |
| 177 | |
| 178 | // Add adds a profile to the configuration, preserving any existing profiles. |
| 179 | func (p *Profile) Add() error { |
no test coverage detected