This is an automated email from the ASF dual-hosted git repository. zhongxjian pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push: new d9db74c1 [operator] Add manifest command d9db74c1 is described below commit d9db74c1e4c7a0a9e86018ff7e942335a34c756f Author: mfordjody <11638...@qq.com> AuthorDate: Mon Dec 23 14:18:27 2024 +0800 [operator] Add manifest command --- dubboctl/cmd/root.go | 4 +++ operator/cmd/cluster/manifest.go | 62 +++++++++++++++++++++++++++++++++++++++ operator/cmd/cluster/uninstall.go | 4 +-- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/dubboctl/cmd/root.go b/dubboctl/cmd/root.go index 113bf07f..1a1ac5f8 100644 --- a/dubboctl/cmd/root.go +++ b/dubboctl/cmd/root.go @@ -48,6 +48,10 @@ func GetRootCmd(args []string) *cobra.Command { upgradeCmd := cluster.UpgradeCmd(ctx) rootCmd.AddCommand(upgradeCmd) + manifestCmd := cluster.ManifestCmd(ctx) + rootCmd.AddCommand(manifestCmd) + hideFlags(manifestCmd, cli.NamespaceFlag, cli.DubboNamespaceFlag, cli.ChartFlag) + return rootCmd } diff --git a/operator/cmd/cluster/manifest.go b/operator/cmd/cluster/manifest.go new file mode 100644 index 00000000..f0576004 --- /dev/null +++ b/operator/cmd/cluster/manifest.go @@ -0,0 +1,62 @@ +package cluster + +import ( + "fmt" + "github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli" + "github.com/spf13/cobra" + "strings" +) + +type ManifestGenerateArgs struct { + files []string + sets []string + manifestPath string +} + +func (a *ManifestGenerateArgs) String() string { + var b strings.Builder + b.WriteString("files: " + fmt.Sprint(a.files) + "\n") + b.WriteString("sets: " + fmt.Sprint(a.sets) + "\n") + b.WriteString("manifestPath: " + a.manifestPath + "\n") + return b.String() +} + +func addManifestGenerateFlags(cmd *cobra.Command, args *ManifestGenerateArgs) { + cmd.PersistentFlags().StringSliceVarP(&args.files, "filename", "f", nil, "") + cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, "") + cmd.PersistentFlags().StringVarP(&args.manifestPath, "manifests", "d", "", "") +} + +func ManifestCmd(ctx cli.Context) *cobra.Command { + rootArgs := &RootArgs{} + mgcArgs := &ManifestGenerateArgs{} + mgc := ManifestGenerateCmd(ctx, rootArgs, mgcArgs) + ic := InstallCmd(ctx) + mc := &cobra.Command{ + Use: "manifest", + Short: "dubbo manifest related commands", + Long: "The manifest command will generates and diffs dubbo manifests.", + } + addFlags(mc, rootArgs) + addFlags(mgc, rootArgs) + addManifestGenerateFlags(mgc, mgcArgs) + mc.AddCommand(mgc) + mc.AddCommand(ic) + return mc +} + +func ManifestGenerateCmd(ctx cli.Context, _ *RootArgs, mgArgs *ManifestGenerateArgs) *cobra.Command { + return &cobra.Command{ + Use: "generate", + Short: "Generates an Dubbo install manifest", + Long: "The generate subcommand generates an Dubbo install manifest and outputs to the console by default.", + Example: ` # Generate a default Istio installation + istioctl manifest generate + + # Generate the demo profile + istioctl manifest generate --set profile=demo +`, + Args: nil, + RunE: nil, + } +} diff --git a/operator/cmd/cluster/uninstall.go b/operator/cmd/cluster/uninstall.go index c8b60ede..c799d9ba 100644 --- a/operator/cmd/cluster/uninstall.go +++ b/operator/cmd/cluster/uninstall.go @@ -38,8 +38,8 @@ func UninstallCmd(ctx cli.Context) *cobra.Command { uiArgs := &uninstallArgs{} uicmd := &cobra.Command{ Use: "uninstall", - Short: "Uninstall Dubbo-related resources", - Long: "This uninstall command will uninstall the dubbo cluster", + Short: "Uninstall Dubbo related resources", + Long: "The uninstall command will uninstall the dubbo cluster", SilenceUsage: true, SilenceErrors: false, Example: ` # Uninstall a single control plane by dop file