| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
package configcobra |
| 7 |
|
| 8 |
import ( |
| 9 |
"github.com/spf13/cobra" |
| 10 |
"sigs.k8s.io/kustomize/cmd/config/internal/commands" |
| 11 |
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/api" |
| 12 |
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/tutorials" |
| 13 |
"sigs.k8s.io/kustomize/cmd/config/runner" |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
var ( |
| 20 |
Cat = commands.CatCommand |
| 21 |
Count = commands.CountCommand |
| 22 |
Grep = commands.GrepCommand |
| 23 |
RunFn = commands.RunCommand |
| 24 |
Tree = commands.TreeCommand |
| 25 |
|
| 26 |
StackOnError = &runner.StackOnError |
| 27 |
ExitOnError = &runner.ExitOnError |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
func AddCommands(root *cobra.Command, name string) *cobra.Command { |
| 32 |
runner.ExitOnError = true |
| 33 |
|
| 34 |
root.PersistentFlags().BoolVar(StackOnError, "stack-trace", false, |
| 35 |
"print a stack-trace on error") |
| 36 |
|
| 37 |
root.AddCommand(GetCfg(name)) |
| 38 |
root.AddCommand(GetFn(name)) |
| 39 |
|
| 40 |
root.AddCommand(&cobra.Command{ |
| 41 |
Use: "docs-merge", |
| 42 |
Short: "[Alpha] Documentation for merging Resources (2-way merge).", |
| 43 |
Long: api.Merge2Long, |
| 44 |
}) |
| 45 |
root.AddCommand(&cobra.Command{ |
| 46 |
Use: "docs-merge3", |
| 47 |
Short: "[Alpha] Documentation for merging Resources (3-way merge).", |
| 48 |
Long: api.Merge3Long, |
| 49 |
}) |
| 50 |
root.AddCommand(&cobra.Command{ |
| 51 |
Use: "docs-fn", |
| 52 |
Short: "[Alpha] Documentation for developing and invoking Configuration Functions.", |
| 53 |
Long: api.FunctionsImplLong, |
| 54 |
}) |
| 55 |
root.AddCommand(&cobra.Command{ |
| 56 |
Use: "docs-fn-spec", |
| 57 |
Short: "[Alpha] Documentation for Configuration Functions Specification.", |
| 58 |
Long: api.FunctionsSpecLong, |
| 59 |
}) |
| 60 |
root.AddCommand(&cobra.Command{ |
| 61 |
Use: "docs-io-annotations", |
| 62 |
Short: "[Alpha] Documentation for annotations used by io.", |
| 63 |
Long: api.ConfigIoLong, |
| 64 |
}) |
| 65 |
|
| 66 |
root.AddCommand(&cobra.Command{ |
| 67 |
Use: "tutorials-command-basics", |
| 68 |
Short: "[Alpha] Tutorials for using basic config commands.", |
| 69 |
Long: tutorials.ConfigurationBasicsLong, |
| 70 |
}) |
| 71 |
|
| 72 |
root.AddCommand(&cobra.Command{ |
| 73 |
Use: "tutorials-function-basics", |
| 74 |
Short: "[Alpha] Tutorials for using functions.", |
| 75 |
Long: tutorials.FunctionBasicsLong, |
| 76 |
}) |
| 77 |
|
| 78 |
return root |
| 79 |
} |