Skip to content

Commit fec11eb

Browse files
committed
Simplify setting crawler auth settings
1 parent 7245216 commit fec11eb

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

pkg/config/config.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,13 @@ func (c *Config) SetCrawlerAuth(profile, crawlerUserID, crawlerAPIKey string) er
207207

208208
profiles := configuration.AllSettings()
209209

210-
found := false
211-
212-
for profileName := range profiles {
213-
runtimeViper := viper.GetViper()
214-
215-
if profileName == profile {
216-
found = true
217-
runtimeViper.Set(profileName+".crawler_user_id", crawlerUserID)
218-
runtimeViper.Set(profileName+".crawler_api_key", crawlerAPIKey)
219-
}
220-
}
221-
222-
if !found {
210+
if _, exists := profiles[profile]; !exists {
223211
return fmt.Errorf("profile '%s' not found", profile)
224212
}
225213

214+
configuration.Set(profile+".crawler_user_id", crawlerUserID)
215+
configuration.Set(profile+".crawler_api_key", crawlerAPIKey)
216+
226217
return c.write(configuration)
227218
}
228219

0 commit comments

Comments
 (0)