Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
rename activeEnvironment to active in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Feb 1, 2020
1 parent 970d1bc commit cfcc2ac
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/commands/environmentscmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ var initCmd = &cobra.Command{
viper.Set(fmt.Sprintf("environments.%s.home", env), workingDir)
viper.Set(fmt.Sprintf("environments.%s.services", env), services)

oldEnv := viper.GetString("activeEnvironment")
oldEnv := viper.GetString("active")

viper.Set("activeEnvironment", env)
viper.Set("active", env)

if err := viper.WriteConfig(); err != nil {
fmt.Printf("%sError on initializing environment: %s (old: %s)%s\n", chalk.Red, env, oldEnv, chalk.ResetColor)
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/environmentscmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var listCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
envs := utils.GetEnvironments()

activeEnv := viper.GetString("activeEnvironment")
activeEnv := viper.GetString("active")

if len(envs) > 0 {
for _, env := range envs {
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/environmentscmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ var removeCmd = &cobra.Command{
os.Exit(0)
}

activeEnv := viper.GetString("activeEnvironment")
activeEnv := viper.GetString("active")

if env == activeEnv {
fmt.Printf("%sRemoved active environment: %s%s\n\n", chalk.Yellow, env, chalk.ResetColor)

viper.Set("activeEnvironment", nil)
viper.Set("active", "-")

fmt.Printf("%sUnset active environment%s\n", chalk.Cyan, chalk.ResetColor)
} else {
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/environmentscmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var setCmd = &cobra.Command{
env = utils.GetEnvironment(args[0])
}

activeEnv := viper.GetString("activeEnvironment")
activeEnv := viper.GetString("active")

if env == activeEnv {
fmt.Printf("%sActive environment already set: %s%s\n", chalk.Yellow, activeEnv, chalk.ResetColor)
Expand All @@ -40,7 +40,7 @@ var setCmd = &cobra.Command{

fmt.Printf("%sNew active environment: %s%s (old: %s)\n", chalk.Green, env, chalk.ResetColor, activeEnv)

viper.Set("activeEnvironment", env)
viper.Set("active", env)

if err := viper.WriteConfig(); err != nil {
fmt.Printf("%sError setting active environment: %s%s\n", chalk.Red, env, chalk.ResetColor)
Expand Down
5 changes: 3 additions & 2 deletions internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ func init() {
viper.SetDefault("home", path.Join(userHome, ".dockma"))
}

viper.SetDefault("logfile", "log.txt")
viper.SetDefault("username", "User")
viper.SetDefault("activeEnvironment", "-")
viper.SetDefault("logSubcommandOutput", false)
viper.SetDefault("logfile", "log.txt")
viper.SetDefault("active", "-")
viper.SetDefault("environments", map[string]interface{}{})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/upcmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var UpCommand = &cobra.Command{
// logfileName := viper.GetString("logfile")
// filepath := utils.GetFullLogfilePath(logfileName)

activeEnv := viper.GetString("activeEnvironment")
activeEnv := viper.GetString("active")
envHomeDir := viper.GetString(fmt.Sprintf("environments.%s.home", activeEnv))
os.Chdir(envHomeDir)

Expand Down

0 comments on commit cfcc2ac

Please sign in to comment.