From a33b0e9e8579ea6a081884908192580eded8eb8c Mon Sep 17 00:00:00 2001 From: mcncl Date: Tue, 26 Mar 2024 13:39:40 +1100 Subject: [PATCH] Initial framework for adding an OpenAI token to the base config (#217) Co-authored-by: Ben McNicholl --- internal/config/config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 5aa0b17e..0c799ef3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -10,6 +10,7 @@ import ( const ( APITokenConfigKey = "api_token" + OpenAIAPITokenConfigKey = "openai_api_token" OrganizationsSlugConfigKey = "organizations" SelectedOrgKey = "selected_org" ) @@ -32,9 +33,10 @@ const ( // buildkite-oss: // api_token: type Config struct { - APIToken string - Organization string - V ViperConfig + APIToken string + OpenAIAPIToken string + Organization string + V ViperConfig } type ProjectConfig struct { @@ -57,11 +59,13 @@ func (conf *Config) merge() { APITokenConfigKey: conf.APIToken, } conf.V.Set(OrganizationsSlugConfigKey, orgs) + conf.V.Set(OpenAIAPITokenConfigKey, conf.OpenAIAPIToken) } // Save sets the current config values into viper and writes the config file func (conf *Config) Save() error { conf.V.Set(SelectedOrgKey, conf.Organization) + conf.V.Set(OpenAIAPITokenConfigKey, conf.OpenAIAPIToken) conf.merge() return conf.V.WriteConfig()