MCPcopy Create free account
hub / github.com/algolia/cli / GetCrawlerAPIKey

Method GetCrawlerAPIKey

pkg/config/profile.go:159–176  ·  view source on GitHub ↗

GetCrawlerAPIKey returns the Crawler API key.

()

Source from the content-addressed store, hash-verified

157
158// GetCrawlerAPIKey returns the Crawler API key.
159func (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.
179func (p *Profile) Add() error {

Callers 1

crawlerClientFunction · 0.80

Calls 2

LoadDefaultMethod · 0.95
GetFieldNameMethod · 0.95

Tested by

no test coverage detected