Skip to content

Commit

Permalink
chore(pkger): drop deprecated influx pkg command tree
Browse files Browse the repository at this point in the history
  • Loading branch information
jsteenb2 committed Jul 10, 2020
1 parent 944b097 commit f51f4fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

1. [18888](https://github.com/influxdata/influxdb/pull/18888): Add event source to influx stack operations
1. [18910](https://github.com/influxdata/influxdb/pull/18910): Add uninstall functionality for stacks
1. [18912](https://github.com/influxdata/influxdb/pull/18912): Drop deprecated influx pkg command tree

### Bug Fixes

Expand Down
75 changes: 10 additions & 65 deletions cmd/influx/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,8 @@ func newCmdPkgerBuilder(svcFn templateSVCsFn, f *globalFlags, opts genericCLIOpt
}

func (b *cmdTemplateBuilder) cmdApply() *cobra.Command {
cmd := b.cmdTemplateApply()

deprecatedCmds := []*cobra.Command{
b.cmdExport(),
b.cmdTemplateSummary(),
b.cmdStackDeprecated(),
b.cmdTemplateValidate(),
}
for i := range deprecatedCmds {
deprecatedCmds[i].Hidden = true
}

cmd.AddCommand(deprecatedCmds...)

return cmd
}

func (b *cmdTemplateBuilder) cmdTemplateApply() *cobra.Command {
cmd := b.newCmd("apply", b.applyRunEFn)
enforceFlagValidation(cmd)
cmd.Aliases = []string{"pkg"}
cmd.Short = "Apply a template to manage resources"
cmd.Long = `
The apply command applies InfluxDB template(s). Use the command to create new
Expand Down Expand Up @@ -572,19 +553,6 @@ func (b *cmdTemplateBuilder) exportStackRunEFn(cmd *cobra.Command, args []string
}

func (b *cmdTemplateBuilder) cmdTemplate() *cobra.Command {
cmd := b.newTemplateCmd("template")
cmd.Short = "Summarize the provided template"
cmd.AddCommand(b.cmdTemplateValidate())
return cmd
}

func (b *cmdTemplateBuilder) cmdTemplateSummary() *cobra.Command {
cmd := b.newTemplateCmd("summary")
cmd.Short = "Summarize the provided template"
return cmd
}

func (b *cmdTemplateBuilder) newTemplateCmd(usage string) *cobra.Command {
runE := func(cmd *cobra.Command, args []string) error {
template, _, err := b.readTemplate()
if err != nil {
Expand All @@ -594,11 +562,13 @@ func (b *cmdTemplateBuilder) newTemplateCmd(usage string) *cobra.Command {
return b.printTemplateSummary(0, template.Summary())
}

cmd := b.genericCLIOpts.newCmd(usage, runE, false)
cmd := b.genericCLIOpts.newCmd("template", runE, false)

b.registerTemplateFileFlags(cmd)
b.registerTemplatePrintOpts(cmd)
cmd.Short = "Summarize the provided template"

cmd.AddCommand(b.cmdTemplateValidate())
return cmd
}

Expand All @@ -620,7 +590,13 @@ func (b *cmdTemplateBuilder) cmdTemplateValidate() *cobra.Command {
}

func (b *cmdTemplateBuilder) cmdStacks() *cobra.Command {
cmd := b.newCmdStackList("stacks")
cmd := b.newCmd("stacks [flags]", b.stackListRunEFn)
cmd.Flags().StringArrayVar(&b.stackIDs, "stack-id", nil, "Stack ID to filter by")
cmd.Flags().StringArrayVar(&b.names, "stack-name", nil, "Stack name to filter by")
registerPrintOptions(cmd, &b.hideHeaders, &b.json)

b.org.register(cmd, false)

cmd.Short = "List stack(s) and associated templates. Subcommands manage stacks."
cmd.Long = `
List stack(s) and associated templates. Subcommands manage stacks.
Expand Down Expand Up @@ -654,18 +630,6 @@ func (b *cmdTemplateBuilder) cmdStacks() *cobra.Command {
return cmd
}

// TODO(jsteenb2): nuke the deprecated command here after OSS beta13 release.
func (b *cmdTemplateBuilder) cmdStackDeprecated() *cobra.Command {
cmd := b.genericCLIOpts.newCmd("stack", nil, false)
cmd.Short = "Stack management commands"
cmd.AddCommand(
b.cmdStackInit(),
b.cmdStackList(),
b.cmdStackRemove(),
)
return cmd
}

func (b *cmdTemplateBuilder) cmdStackInit() *cobra.Command {
cmd := b.newCmd("init", b.stackInitRunEFn)
cmd.Short = "Initialize a stack"
Expand Down Expand Up @@ -724,25 +688,6 @@ func (b *cmdTemplateBuilder) stackInitRunEFn(cmd *cobra.Command, args []string)
return b.writeStack(stack)
}

func (b *cmdTemplateBuilder) cmdStackList() *cobra.Command {
cmd := b.newCmdStackList("list")
cmd.Short = "List stack(s) and associated resources"
cmd.Aliases = []string{"ls"}
return cmd
}

func (b *cmdTemplateBuilder) newCmdStackList(cmdName string) *cobra.Command {
usage := fmt.Sprintf("%s [flags]", cmdName)
cmd := b.newCmd(usage, b.stackListRunEFn)
cmd.Flags().StringArrayVar(&b.stackIDs, "stack-id", nil, "Stack ID to filter by")
cmd.Flags().StringArrayVar(&b.names, "stack-name", nil, "Stack name to filter by")
registerPrintOptions(cmd, &b.hideHeaders, &b.json)

b.org.register(cmd, false)

return cmd
}

func (b *cmdTemplateBuilder) stackListRunEFn(cmd *cobra.Command, args []string) error {
templateSVC, orgSVC, err := b.svcFn()
if err != nil {
Expand Down

0 comments on commit f51f4fd

Please sign in to comment.