mantl / consul-cli

Command line interface to Consul HTTP API
Apache License 2.0
251 stars 67 forks source link

Add support for multiple environments #47

Closed Theaxiom closed 6 years ago

Theaxiom commented 7 years ago

I was just pulling this in from a fork because it looked useful, do what you will with it. 😀

On Apr 20, 2017 10:10 PM, "Chris Aubuchon" notifications@github.com wrote:

@ChrisAubuchon commented on this pull request.

In commands/commands.go https://github.com/mantl/consul-cli/pull/47#discussion_r112609937:

@@ -19,6 +23,106 @@ type Cmd struct { Template string }

+type TomlConfig struct {

  • Env string
  • Dev ConsulFromFile
  • Prod ConsulFromFile
  • Stage ConsulFromFile
  • QA ConsulFromFile
  • West ConsulFromFile
  • East ConsulFromFile +}

What about a map[string]ConsulFromFile instead of hardcoding environment names?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mantl/consul-cli/pull/47#pullrequestreview-33938311, or mute the thread https://github.com/notifications/unsubscribe-auth/AADetTb0TMFNTX0WBf8aNXrZy80HhhAVks5ryDorgaJpZM4ND1f0 .

Theaxiom commented 7 years ago

Would you mind tweaking this code?

On Apr 20, 2017 10:11 PM, "Chris Aubuchon" notifications@github.com wrote:

@ChrisAubuchon commented on this pull request.

In commands/commands.go https://github.com/mantl/consul-cli/pull/47#discussion_r112610039:

+} + +func CheckConsulFile(inputFile string) string {

  • tempConsulFile := inputFile
  • if inputFile[:2] == "~/" {
  • user, _ := user.Current()
  • homeDir := fmt.Sprint(user.HomeDir + "/")
  • tempConsulFile = strings.Replace(inputFile, "~/", homeDir, 1)
  • }
  • _, err := os.Stat(tempConsulFile)
  • if err == nil {
  • return tempConsulFile
  • }
  • return "" +}

Might want to look at https://github.com/mitchellh/go-homedir for homedir detection. Biggest benefit is that it works in windows as well.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mantl/consul-cli/pull/47#pullrequestreview-33938408, or mute the thread https://github.com/notifications/unsubscribe-auth/AADetVZNKbuDG2BjVt_ITDZ5IJbTee1_ks5ryDqSgaJpZM4ND1f0 .

ChrisAubuchon commented 7 years ago

Yeah. I'll run with it. It's a cool idea.

Theaxiom commented 7 years ago

Awesome, thanks.

On Apr 20, 2017 10:13 PM, "Chris Aubuchon" notifications@github.com wrote:

Yeah. I'll run with it. It's a cool idea.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mantl/consul-cli/pull/47#issuecomment-296069168, or mute the thread https://github.com/notifications/unsubscribe-auth/AADetQfVBcjFGpheoemYx_SGwS44VfsUks5ryDr3gaJpZM4ND1f0 .