kuma

Форк
0
53 строки · 1.4 Кб
1
package cmd
2

3
import (
4
	"os"
5

6
	"github.com/spf13/cobra"
7
)
8

9
type args struct {
10
	pluginDir string
11
	version   string
12
	goModule  string
13
}
14

15
func newRootCmd() *cobra.Command {
16
	rootArgs := &args{}
17

18
	cmd := &cobra.Command{
19
		Use:   "policy-gen",
20
		Short: "Tool to generate plugin-based policies for Kuma",
21
		Long:  "Tool to generate plugin-based policies for Kuma.",
22
		PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
23
			// once command line flags have been parsed,
24
			// avoid printing usage instructions
25
			cmd.SilenceUsage = true
26
			return nil
27
		},
28
	}
29

30
	cmd.AddCommand(newCoreResource(rootArgs))
31
	cmd.AddCommand(newK8sResource(rootArgs))
32
	cmd.AddCommand(newOpenAPI(rootArgs))
33
	cmd.AddCommand(newPluginFile(rootArgs))
34
	cmd.AddCommand(newHelpers(rootArgs))
35

36
	cmd.PersistentFlags().StringVar(&rootArgs.pluginDir, "plugin-dir", "", "path to the policy plugin director")
37
	cmd.PersistentFlags().StringVar(&rootArgs.version, "version", "v1alpha1", "policy version")
38
	cmd.PersistentFlags().StringVar(&rootArgs.goModule, "gomodule", "github.com/kumahq/kuma", "Where to put the generated code")
39

40
	return cmd
41
}
42

43
func DefaultRootCmd() *cobra.Command {
44
	return newRootCmd()
45
}
46

47
// Execute adds all child commands to the root command and sets flags appropriately.
48
// This is called by main.main(). It only needs to happen once to the rootCmd.
49
func Execute() {
50
	if err := DefaultRootCmd().Execute(); err != nil {
51
		os.Exit(1)
52
	}
53
}
54

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.