Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added kustomize #858

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions completers/kustomize_completer/cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/docker"
"github.com/spf13/cobra"
)

var buildCmd = &cobra.Command{
Use: "build",
Short: "Build a kustomization target from a directory or URL.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildCmd).Standalone()
buildCmd.Flags().Bool("as-current-user", false, "use the uid and gid of the command executor to run the function in the container")
buildCmd.Flags().Bool("enable-alpha-plugins", false, "enable kustomize plugins")
buildCmd.Flags().Bool("enable-exec", false, "enable support for exec functions (raw executables); do not use for untrusted configs! (Alpha)")
buildCmd.Flags().Bool("enable-helm", false, "Enable use of the Helm chart inflator generator.")
buildCmd.Flags().Bool("enable-managedby-label", false, "enable adding app.kubernetes.io/managed-by")
buildCmd.Flags().Bool("enable-star", false, "enable support for starlark functions. (Alpha)")
buildCmd.Flags().StringArrayP("env", "e", []string{}, "a list of environment variables to be used by functions")
buildCmd.Flags().String("helm-command", "helm", "helm command (path to executable)")
buildCmd.Flags().String("load-restrictor", "LoadRestrictionsRootOnly", "if set to 'LoadRestrictionsNone', local kustomizations may load files from outside their root. This does, however, break the relocatability of the kustomization.")
buildCmd.Flags().StringArray("mount", []string{}, "a list of storage options read from the filesystem")
buildCmd.Flags().Bool("network", false, "enable network access for functions that declare it")
buildCmd.Flags().String("network-name", "bridge", "the docker network to run the container in")
buildCmd.Flags().StringP("output", "o", "", "If specified, write output to this path.")
buildCmd.Flags().String("reorder", "legacy", "Reorder the resources just before output. Use 'legacy' to apply a legacy reordering (Namespaces first, Webhooks last, etc). Use 'none' to suppress a final reordering.")
rootCmd.AddCommand(buildCmd)

carapace.Gen(buildCmd).FlagCompletion(carapace.ActionMap{
"helm-command": carapace.ActionFiles(),
"load-restrictor": carapace.ActionValues("LoadRestrictionsNone", "LoadRestrictionsRootOnly"),
"network-name": docker.ActionNetworks(),
"output": carapace.ActionFiles(),
"reorder": carapace.ActionValues(
"legacy", "Namespaces first, Webhooks last, etc",
"none", "suppress a final reordering",
),
})
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/cfg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cfgCmd = &cobra.Command{
Use: "cfg",
Short: "Commands for reading and writing configuration.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cfgCmd).Standalone()
rootCmd.AddCommand(cfgCmd)
}
40 changes: 40 additions & 0 deletions completers/kustomize_completer/cmd/cfg_cat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cfg_catCmd = &cobra.Command{
Use: "cat",
Short: "[Alpha] Print Resource Config from a local directory.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cfg_catCmd).Standalone()
cfg_catCmd.Flags().Bool("annotate", false, "annotate resources with their file origins.")
cfg_catCmd.Flags().String("dest", "", "if specified, write output to a file rather than stdout")
cfg_catCmd.Flags().Bool("exclude-non-local", false, "if true, exclude non-local-config in the output.")
cfg_catCmd.Flags().Bool("format", true, "format resource config yaml before printing.")
cfg_catCmd.Flags().String("function-config", "", "path to function config to put in ResourceList -- only if wrapped in a ResourceList.")
cfg_catCmd.Flags().Bool("include-local", false, "if true, include local-config in the output.")
cfg_catCmd.Flags().BoolP("recurse-subpackages", "R", true, "print resources recursively in all the nested subpackages")
cfg_catCmd.Flags().Bool("strip-comments", false, "remove comments from yaml.")
cfg_catCmd.Flags().StringSlice("style", []string{}, "yaml styles to apply. may be 'TaggedStyle', 'DoubleQuotedStyle', 'LiteralStyle', 'FoldedStyle', 'FlowStyle'.")
cfg_catCmd.Flags().String("wrap-kind", "", "if set, wrap the output in this list type kind.")
cfg_catCmd.Flags().String("wrap-version", "", "if set, wrap the output in this list type apiVersion.")
cfgCmd.AddCommand(cfg_catCmd)

carapace.Gen(cfg_catCmd).FlagCompletion(carapace.ActionMap{
"dest": carapace.ActionFiles(),
"function-config": carapace.ActionFiles(),
"style": carapace.ActionMultiParts(",", func(c carapace.Context) carapace.Action {
return carapace.ActionValues("TaggedStyle", "DoubleQuotedStyle", "LiteralStyle", "FoldedStyle", "FlowStyle").Invoke(c).Filter(c.Parts).ToA()
}),
})

carapace.Gen(cfg_catCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
23 changes: 23 additions & 0 deletions completers/kustomize_completer/cmd/cfg_count.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cfg_countCmd = &cobra.Command{
Use: "count",
Short: "[Alpha] Count Resources Config from a local directory.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cfg_countCmd).Standalone()
cfg_countCmd.Flags().Bool("kind", true, "count resources by kind.")
cfg_countCmd.Flags().BoolP("recurse-subpackages", "R", true, "prints count of resources recursively in all the nested subpackages")
cfgCmd.AddCommand(cfg_countCmd)

carapace.Gen(cfg_countCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
25 changes: 25 additions & 0 deletions completers/kustomize_completer/cmd/cfg_grep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cfg_grepCmd = &cobra.Command{
Use: "grep",
Short: "[Alpha] Search for matching Resources in a directory or from stdin",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cfg_grepCmd).Standalone()
cfg_grepCmd.Flags().Bool("annotate", true, "annotate resources with their file origins.")
cfg_grepCmd.Flags().Bool("invert-match", false, "Selected Resources are those not matching any of the specified patterns..")
cfg_grepCmd.Flags().BoolP("recurse-subpackages", "R", true, "also print resources recursively in all the nested subpackages")
cfgCmd.AddCommand(cfg_grepCmd)

carapace.Gen(cfg_grepCmd).PositionalCompletion(
carapace.ActionValues(),
carapace.ActionDirectories(),
)
}
38 changes: 38 additions & 0 deletions completers/kustomize_completer/cmd/cfg_tree.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cfg_treeCmd = &cobra.Command{
Use: "tree",
Short: "[Alpha] Display Resource structure from a directory or stdin.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cfg_treeCmd).Standalone()
cfg_treeCmd.Flags().Bool("all", false, "print all field infos")
cfg_treeCmd.Flags().Bool("args", false, "print args field")
cfg_treeCmd.Flags().Bool("command", false, "print command field")
cfg_treeCmd.Flags().Bool("env", false, "print env field")
cfg_treeCmd.Flags().Bool("exclude-non-local", false, "if true, exclude non-local-config in the output.")
cfg_treeCmd.Flags().StringSlice("field", []string{}, "print field")
cfg_treeCmd.Flags().String("graph-structure", "", "Graph structure to use for printing the tree. may be any of: owners,directory")
cfg_treeCmd.Flags().Bool("image", false, "print image field")
cfg_treeCmd.Flags().Bool("include-local", false, "if true, include local-config in the output.")
cfg_treeCmd.Flags().Bool("name", false, "print name field")
cfg_treeCmd.Flags().Bool("ports", false, "print ports field")
cfg_treeCmd.Flags().Bool("replicas", false, "print replicas field")
cfg_treeCmd.Flags().Bool("resources", false, "print resources field")
cfgCmd.AddCommand(cfg_treeCmd)

carapace.Gen(cfg_treeCmd).FlagCompletion(carapace.ActionMap{
"graph-structure": carapace.ActionValues("owners", "directory"),
})

carapace.Gen(cfg_treeCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
21 changes: 21 additions & 0 deletions completers/kustomize_completer/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate shell completion script",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completionCmd).Standalone()
rootCmd.AddCommand(completionCmd)

carapace.Gen(completionCmd).PositionalCompletion(
carapace.ActionValues("bash", "zsh", "fish", "powershell"),
)
}
25 changes: 25 additions & 0 deletions completers/kustomize_completer/cmd/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var createCmd = &cobra.Command{
Use: "create",
Short: "Create a new kustomization in the current directory",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(createCmd).Standalone()
createCmd.Flags().String("annotations", "", "Add one or more common annotations.")
createCmd.Flags().Bool("autodetect", false, "Search for kubernetes resources in the current directory to be added to the kustomization file.")
createCmd.Flags().String("labels", "", "Add one or more common labels.")
createCmd.Flags().String("nameprefix", "", "Sets the value of the namePrefix field in the kustomization file.")
createCmd.Flags().String("namespace", "", "Set the value of the namespace field in the customization file.")
createCmd.Flags().String("namesuffix", "", "Sets the value of the nameSuffix field in the kustomization file.")
createCmd.Flags().Bool("recursive", false, "Enable recursive directory searching for resource auto-detection.")
createCmd.Flags().String("resources", "", "Name of a file containing a file to add to the kustomization file.")
rootCmd.AddCommand(createCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/docsFn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var docsFnCmd = &cobra.Command{
Use: "docs-fn",
Short: "[Alpha] Documentation for developing and invoking Configuration Functions.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(docsFnCmd).Standalone()
rootCmd.AddCommand(docsFnCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/docsFnSpec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var docsFnSpecCmd = &cobra.Command{
Use: "docs-fn-spec",
Short: "[Alpha] Documentation for Configuration Functions Specification.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(docsFnSpecCmd).Standalone()
rootCmd.AddCommand(docsFnSpecCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/docsIoAnnotations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var docsIoAnnotationsCmd = &cobra.Command{
Use: "docs-io-annotations",
Short: "[Alpha] Documentation for annotations used by io.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(docsIoAnnotationsCmd).Standalone()
rootCmd.AddCommand(docsIoAnnotationsCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/docsMerge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var docsMergeCmd = &cobra.Command{
Use: "docs-merge",
Short: "[Alpha] Documentation for merging Resources (2-way merge).",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(docsMergeCmd).Standalone()
rootCmd.AddCommand(docsMergeCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/docsMerge3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var docsMerge3Cmd = &cobra.Command{
Use: "docs-merge3",
Short: "[Alpha] Documentation for merging Resources (3-way merge).",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(docsMerge3Cmd).Standalone()
rootCmd.AddCommand(docsMerge3Cmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/edit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var editCmd = &cobra.Command{
Use: "edit",
Short: "Edits a kustomization file",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(editCmd).Standalone()
rootCmd.AddCommand(editCmd)
}
17 changes: 17 additions & 0 deletions completers/kustomize_completer/cmd/edit_add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var edit_addCmd = &cobra.Command{
Use: "add",
Short: "Adds an item to the kustomization file.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(edit_addCmd).Standalone()
editCmd.AddCommand(edit_addCmd)
}
18 changes: 18 additions & 0 deletions completers/kustomize_completer/cmd/edit_add_annotation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var edit_add_annotationCmd = &cobra.Command{
Use: "annotation",
Short: "Adds one or more commonAnnotations to kustomization.yaml",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(edit_add_annotationCmd).Standalone()
edit_add_annotationCmd.Flags().BoolP("force", "f", false, "overwrite commonAnnotation if it already exists")
edit_addCmd.AddCommand(edit_add_annotationCmd)
}
Loading