@@ -112,7 +112,7 @@ func (c *Config) InitConfig() {
112
112
}
113
113
LocalConfigFile := ""
114
114
if c .LocalConfigFile == "" {
115
- LocalConfigFile = filepath .Join (workspaceFolder , "hookdeck.toml" )
115
+ LocalConfigFile = filepath .Join (workspaceFolder , ". hookdeck/config .toml" )
116
116
} else {
117
117
if filepath .IsAbs (c .LocalConfigFile ) {
118
118
LocalConfigFile = c .LocalConfigFile
@@ -203,10 +203,10 @@ func (c *Config) EditConfig() error {
203
203
}
204
204
205
205
// UseWorkspace selects the active workspace to be used
206
- func (c * Config ) UseWorkspace (teamId string , teamMode string ) error {
206
+ func (c * Config ) UseWorkspace (local bool , teamId string , teamMode string ) error {
207
207
c .Profile .TeamID = teamId
208
208
c .Profile .TeamMode = teamMode
209
- return c .Profile .SaveProfile ()
209
+ return c .Profile .SaveProfile (local )
210
210
}
211
211
212
212
func (c * Config ) ListProfiles () []string {
@@ -248,29 +248,26 @@ func (c *Config) RemoveAllProfiles() error {
248
248
249
249
// Construct the config struct from flags > local config > global config
250
250
func (c * Config ) constructConfig () {
251
- c .Color = getStringConfig (c .Color , c .LocalConfig .GetString ("color" ) , c .GlobalConfig .GetString (("color" )) , "auto" )
252
- c .LogLevel = getStringConfig (c .LogLevel , c .LocalConfig .GetString ("log" ) , c .GlobalConfig .GetString (("log" )) , "info" )
253
- c .APIBaseURL = getStringConfig (c .APIBaseURL , c .LocalConfig .GetString ("api_base" ) , c .GlobalConfig .GetString (("api_base" )) , hookdeck .DefaultAPIBaseURL )
254
- c .DashboardBaseURL = getStringConfig (c .DashboardBaseURL , c .LocalConfig .GetString ("dashboard_base" ) , c .GlobalConfig .GetString (("dashboard_base" )) , hookdeck .DefaultDashboardBaseURL )
255
- c .ConsoleBaseURL = getStringConfig (c .ConsoleBaseURL , c .LocalConfig .GetString ("console_base" ) , c .GlobalConfig .GetString (("console_base" )) , hookdeck .DefaultConsoleBaseURL )
256
- c .WSBaseURL = getStringConfig (c .WSBaseURL , c .LocalConfig .GetString ("ws_base" ) , c .GlobalConfig .GetString (("ws_base" )) , hookdeck .DefaultWebsocektURL )
257
- c .Profile .Name = getStringConfig (c .Profile .Name , c .LocalConfig .GetString ("profile" ) , c .GlobalConfig .GetString (("profile" )) , hookdeck .DefaultProfileName )
258
- c .Profile .APIKey = getStringConfig (c .Profile .APIKey , c .LocalConfig .GetString ("api_key" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("api_key" ))) , "" )
259
- c .Profile .TeamID = getStringConfig (c .Profile .TeamID , c .LocalConfig .GetString ("team_id" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("team_id" ))) , "" )
260
- c .Profile .TeamMode = getStringConfig (c .Profile .TeamMode , c .LocalConfig .GetString ("team_mode" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("team_mode" ))), "" )
251
+ c .Color = getStringConfig ([] string { c .Color , c .LocalConfig .GetString ("color" ) , c .GlobalConfig .GetString (("color" )) , "auto" } )
252
+ c .LogLevel = getStringConfig ([] string { c .LogLevel , c .LocalConfig .GetString ("log" ) , c .GlobalConfig .GetString (("log" )) , "info" } )
253
+ c .APIBaseURL = getStringConfig ([] string { c .APIBaseURL , c .LocalConfig .GetString ("api_base" ) , c .GlobalConfig .GetString (("api_base" )) , hookdeck .DefaultAPIBaseURL } )
254
+ c .DashboardBaseURL = getStringConfig ([] string { c .DashboardBaseURL , c .LocalConfig .GetString ("dashboard_base" ) , c .GlobalConfig .GetString (("dashboard_base" )) , hookdeck .DefaultDashboardBaseURL } )
255
+ c .ConsoleBaseURL = getStringConfig ([] string { c .ConsoleBaseURL , c .LocalConfig .GetString ("console_base" ) , c .GlobalConfig .GetString (("console_base" )) , hookdeck .DefaultConsoleBaseURL } )
256
+ c .WSBaseURL = getStringConfig ([] string { c .WSBaseURL , c .LocalConfig .GetString ("ws_base" ) , c .GlobalConfig .GetString (("ws_base" )) , hookdeck .DefaultWebsocektURL } )
257
+ c .Profile .Name = getStringConfig ([] string { c .Profile .Name , c .LocalConfig .GetString ("profile" ) , c .GlobalConfig .GetString (("profile" )) , hookdeck .DefaultProfileName } )
258
+ c .Profile .APIKey = getStringConfig ([] string { c .Profile .APIKey , c .LocalConfig .GetString ("api_key" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("api_key" ))) , "" } )
259
+ c .Profile .TeamID = getStringConfig ([] string { c .Profile .TeamID , c .LocalConfig .GetString ("workspace_id" ) , c . LocalConfig . GetString ( " team_id" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("workspace_id" ))) , c . GlobalConfig . GetString (( c . Profile . GetConfigField ( " team_id" ))) , "" } )
260
+ c .Profile .TeamMode = getStringConfig ([] string { c .Profile .TeamMode , c .LocalConfig .GetString ("workspace_mode" ) , c . LocalConfig . GetString ( " team_mode" ) , c .GlobalConfig .GetString ((c .Profile .GetConfigField ("workspace_mode" ))) , c . GlobalConfig . GetString (( c . Profile . GetConfigField ( " team_mode" ))) , "" } )
261
261
}
262
262
263
- func getStringConfig (v1 string , v2 string , v3 string , v4 string ) string {
264
- if v1 != "" {
265
- return v1
266
- }
267
- if v2 != "" {
268
- return v2
269
- }
270
- if v3 != "" {
271
- return v3
263
+ func getStringConfig (values []string ) string {
264
+ for _ , str := range values {
265
+ if str != "" {
266
+ return str
267
+ }
272
268
}
273
- return v4
269
+
270
+ return values [len (values )- 1 ]
274
271
}
275
272
276
273
// isProfile identifies whether a value in the config pertains to a profile.
0 commit comments