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

Method GetAdminAPIKey

pkg/config/profile.go:87–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87func (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
110func (p *Profile) GetSearchHosts() []string {
111 envHosts := os.Getenv("ALGOLIA_SEARCH_HOSTS")

Callers 1

GetAPIKeyMethod · 0.95

Calls 2

LoadDefaultMethod · 0.95
GetFieldNameMethod · 0.95

Tested by

no test coverage detected