mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Refactor kustomize config command structure
- Create cfg, fn, live parent commands
This commit is contained in:
committed by
Phillip Wittrock
parent
73157c7141
commit
701c217791
@@ -6,43 +6,12 @@
|
||||
package configcobra
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sigs.k8s.io/kustomize/cmd/config/internal/commands"
|
||||
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/api"
|
||||
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/tutorials"
|
||||
"sigs.k8s.io/kustomize/kyaml/commandutil"
|
||||
)
|
||||
|
||||
var root = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "[Alpha] Utilities for working with Resource Configuration.",
|
||||
Long: `[Alpha] Utilities for working with Resource Configuration.
|
||||
|
||||
Tutorials:
|
||||
|
||||
Run 'kustomize help config tutorial-TUTORIAL'
|
||||
|
||||
$ kustomize help config tutorials-command-basics
|
||||
|
||||
Command Documentation:
|
||||
|
||||
Run 'kustomize help config CMD'
|
||||
|
||||
$ kustomize help config tree
|
||||
|
||||
Advanced Documentation Topics:
|
||||
|
||||
Run 'kustomize help config docs-TOPIC'
|
||||
|
||||
$ kustomize help config docs-merge
|
||||
$ kustomize help config docs-merge3
|
||||
$ kustomize help config docs-fn
|
||||
$ kustomize help config docs-io-annotations
|
||||
`,
|
||||
}
|
||||
|
||||
// Export commands publicly for composition
|
||||
var (
|
||||
Annotate = commands.AnnotateCommand
|
||||
@@ -52,10 +21,11 @@ var (
|
||||
CreateSubstitution = commands.CreateSubstitutionCommand
|
||||
Fmt = commands.FmtCommand
|
||||
Grep = commands.GrepCommand
|
||||
Init = commands.InitCommand
|
||||
ListSetters = commands.ListSettersCommand
|
||||
Merge = commands.MergeCommand
|
||||
Merge3 = commands.Merge3Command
|
||||
RunFn = commands.RunFnCommand
|
||||
RunFn = commands.RunCommand
|
||||
Set = commands.SetCommand
|
||||
Sink = commands.SinkCommand
|
||||
Source = commands.SourceCommand
|
||||
@@ -67,51 +37,16 @@ var (
|
||||
ExitOnError = &commands.ExitOnError
|
||||
)
|
||||
|
||||
// NewConfigCommand returns a new *cobra.Command for the config command group. This may
|
||||
// be embedded into other go binaries as a way of packaging the "config" command as part
|
||||
// of another binary.
|
||||
//
|
||||
// name is substituted into the built-in documentation for each sub-command as the command
|
||||
// invocation prefix -- e.g. if the result is embedded in kustomize, then name should be
|
||||
// "kustomize" and the built-in docs will display "kustomize config" in the examples.
|
||||
//
|
||||
func NewConfigCommand(name string) *cobra.Command {
|
||||
// config command is alpha
|
||||
root.Version = "v0.0.0"
|
||||
|
||||
// Only populate the command if Alpha commands are enabled.
|
||||
if !commandutil.GetAlphaEnabled() {
|
||||
// return the command because other subcommands are added to it
|
||||
root.Short = "[Alpha] To enable set KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true"
|
||||
root.Long = "[Alpha] To enable set KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true"
|
||||
root.Example = ""
|
||||
return root
|
||||
}
|
||||
|
||||
root.PersistentFlags().BoolVar(&commands.StackOnError, "stack-trace", false,
|
||||
"print a stack-trace on failure")
|
||||
|
||||
name = strings.TrimSpace(name + " config")
|
||||
// AddCommands adds the cfg, fn and live commands to kustomize.
|
||||
func AddCommands(root *cobra.Command, name string) *cobra.Command {
|
||||
commands.ExitOnError = true
|
||||
root.AddCommand(commands.AnnotateCommand(name))
|
||||
root.AddCommand(commands.GrepCommand(name))
|
||||
root.AddCommand(commands.TreeCommand(name))
|
||||
root.AddCommand(commands.CatCommand(name))
|
||||
root.AddCommand(commands.FmtCommand(name))
|
||||
root.AddCommand(commands.MergeCommand(name))
|
||||
root.AddCommand(commands.Merge3Command(name))
|
||||
root.AddCommand(commands.CountCommand(name))
|
||||
root.AddCommand(commands.RunFnCommand(name))
|
||||
root.AddCommand(commands.XArgsCommand())
|
||||
root.AddCommand(commands.WrapCommand())
|
||||
|
||||
root.AddCommand(commands.InitCommand(name))
|
||||
root.AddCommand(commands.SetCommand(name))
|
||||
root.AddCommand(commands.ListSettersCommand(name))
|
||||
root.AddCommand(commands.CreateSetterCommand(name))
|
||||
root.AddCommand(commands.CreateSubstitutionCommand(name))
|
||||
root.AddCommand(commands.SinkCommand(name))
|
||||
root.AddCommand(commands.SourceCommand(name))
|
||||
root.PersistentFlags().BoolVar(StackOnError, "stack-trace", false,
|
||||
"print a stack-trace on error")
|
||||
|
||||
root.AddCommand(GetCfg(name))
|
||||
root.AddCommand(GetFn(name))
|
||||
root.AddCommand(GetLive(name))
|
||||
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "docs-merge",
|
||||
|
||||
Reference in New Issue
Block a user