Skip to content

Commit

Permalink
feat(influx): provide active config when running bare influx config cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
jsteenb2 committed Jun 18, 2020
1 parent d5bf002 commit 8d9e3bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
1. [18573](https://github.com/influxdata/influxdb/pull/18573): Extend influx stacks cmd with new influx stacks update cmd
1. [18595](https://github.com/influxdata/influxdb/pull/18595): Add ability to skip resources in a template by kind or by metadata.name
1. [18600](https://github.com/influxdata/influxdb/pull/18600): Extend influx apply with resource filter capabilities
1. [18601](https://github.com/influxdata/influxdb/pull/18601): Provide active config running influx config without args

## v2.0.0-beta.12 [2020-06-12]

Expand Down
28 changes: 25 additions & 3 deletions cmd/influx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type cmdConfigBuilder struct {
func (b *cmdConfigBuilder) cmd() *cobra.Command {
cmd := b.newCmd("config [config name]", b.cmdSwitchActiveRunEFn, false)
cmd.Short = "Config management commands"
cmd.Args = cobra.ExactArgs(1)
cmd.Args = cobra.ArbitraryArgs

cmd.AddCommand(
b.cmdCreate(),
Expand All @@ -50,13 +50,35 @@ func (b *cmdConfigBuilder) cmd() *cobra.Command {
}

func (b *cmdConfigBuilder) cmdSwitchActiveRunEFn(cmd *cobra.Command, args []string) error {
cfg, err := b.svc.SwitchActive(args[0])
if len(args) > 0 {
cfg, err := b.svc.SwitchActive(args[0])
if err != nil {
return err
}

return b.printConfigs(configPrintOpts{
config: cfg,
})
}

configs, err := b.svc.ListConfigs()
if err != nil {
return err
}

var active config.Config
for _, cfg := range configs {
if cfg.Active {
active = cfg
break
}
}
if !active.Active {
return nil
}

return b.printConfigs(configPrintOpts{
config: cfg,
config: active,
})
}

Expand Down
1 change: 0 additions & 1 deletion cmd/influx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func TestCmdConfig(t *testing.T) {

t.Run("create", func(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 8d9e3bb

Please sign in to comment.