mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
* fixed flaky loop(cautils): loadpolicy getter We should not inject pointers to the variable iterated over by the "range" operator. Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> * fixed more flaky pointers in loops (registryadaptors, opaprocessor) Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> * fixed more flaky pointers in loops (resultshandling) Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> * enabled golangci linter in CI Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> * fixed linting issues with minimal linters config Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> * bump go version to 1.19 * English and typos * Support AKS parser (#994) * support GKE parser * update go mod * support GKE parser * update go mod * update k8s-interface pkg * Added KS desgin.drawio * revert k8s.io to v0.25.3 * ran go mod tidy * update sign-up url * [wip] Adding CreateAccount support * revert to docs URL * update opa-utils pkg * Print attack tree (optional, with argument) (#997) * Print attack tree with the argument Signed-off-by: Frédéric BIDON <fredbi@yahoo.com> Co-authored-by: Frédéric BIDON <frederic@oneconcern.com> Co-authored-by: Frédéric BIDON <fredbi@yahoo.com> Co-authored-by: Oshrat Nir <45561829+Oshratn@users.noreply.github.com> Co-authored-by: Amir Malka <amirm@armosec.io> Co-authored-by: David Wertenteil <dwertent@armosec.io>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package completion
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var completionCmdExamples = `
|
|
|
|
# Enable BASH shell autocompletion
|
|
$ source <(kubescape completion bash)
|
|
$ echo 'source <(kubescape completion bash)' >> ~/.bashrc
|
|
|
|
# Enable ZSH shell autocompletion
|
|
$ source <(kubectl completion zsh)
|
|
$ echo 'source <(kubectl completion zsh)' >> "${fpath[1]}/_kubectl"
|
|
|
|
`
|
|
|
|
func GetCompletionCmd() *cobra.Command {
|
|
completionCmd := &cobra.Command{
|
|
Use: "completion [bash|zsh|fish|powershell]",
|
|
Short: "Generate autocompletion script",
|
|
Long: "To load completions",
|
|
Example: completionCmdExamples,
|
|
DisableFlagsInUseLine: true,
|
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
|
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
switch strings.ToLower(args[0]) {
|
|
case "bash":
|
|
cmd.Root().GenBashCompletion(os.Stdout)
|
|
case "zsh":
|
|
cmd.Root().GenZshCompletion(os.Stdout)
|
|
case "fish":
|
|
cmd.Root().GenFishCompletion(os.Stdout, true)
|
|
case "powershell":
|
|
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
|
}
|
|
},
|
|
}
|
|
return completionCmd
|
|
}
|