You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zh...@apache.org on 2024/12/25 10:09:39 UTC

(dubbo-kubernetes) branch master updated: [operator] add version and validate command

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 89754906 [operator] add version and validate command
89754906 is described below

commit 89754906845b0788b00abb93ab0e59adcd468ded
Author: mfordjody <11...@qq.com>
AuthorDate: Wed Dec 25 18:09:29 2024 +0800

    [operator] add version and validate command
---
 dubboctl/cmd/root.go              |  5 +++++
 operator/pkg/validate/validate.go | 26 ++++++++++++++++++++++++++
 operator/pkg/version/version.go   |  1 +
 3 files changed, 32 insertions(+)

diff --git a/dubboctl/cmd/root.go b/dubboctl/cmd/root.go
index 1a1ac5f8..d4892165 100644
--- a/dubboctl/cmd/root.go
+++ b/dubboctl/cmd/root.go
@@ -19,6 +19,7 @@ import (
 	"flag"
 	"github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli"
 	"github.com/apache/dubbo-kubernetes/operator/cmd/cluster"
+	"github.com/apache/dubbo-kubernetes/operator/pkg/validate"
 	"github.com/spf13/cobra"
 )
 
@@ -52,6 +53,10 @@ func GetRootCmd(args []string) *cobra.Command {
 	rootCmd.AddCommand(manifestCmd)
 	hideFlags(manifestCmd, cli.NamespaceFlag, cli.DubboNamespaceFlag, cli.ChartFlag)
 
+	validateCmd := validate.NewValidateCommand(ctx)
+	rootCmd.AddCommand(validateCmd)
+	hideFlags(validateCmd, cli.NamespaceFlag, cli.DubboNamespaceFlag, cli.ChartFlag)
+
 	return rootCmd
 }
 
diff --git a/operator/pkg/validate/validate.go b/operator/pkg/validate/validate.go
new file mode 100644
index 00000000..7c7079b9
--- /dev/null
+++ b/operator/pkg/validate/validate.go
@@ -0,0 +1,26 @@
+package validate
+
+import (
+	"github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli"
+	"github.com/spf13/cobra"
+)
+
+func NewValidateCommand(ctx cli.Context) *cobra.Command {
+	vc := &cobra.Command{
+		Use:   "validate -f FILENAME [options]",
+		Short: "Validate Dubbo rules files",
+		Long:  "The validate command is used to validate the dubbo related rule file",
+		Example: `  # Validate current deployments under 'default' namespace with in the cluster
+  kubectl get deployments -o yaml | dubboctl validate -f -
+
+  # Validate current services under 'default' namespace with in the cluster
+  kubectl get services -o yaml | dubboctl validate -f -
+`,
+		Args:    cobra.NoArgs,
+		Aliases: []string{"v"},
+		RunE: func(cmd *cobra.Command, _ []string) error {
+			return nil
+		},
+	}
+	return vc
+}
diff --git a/operator/pkg/version/version.go b/operator/pkg/version/version.go
new file mode 100644
index 00000000..f37d99d0
--- /dev/null
+++ b/operator/pkg/version/version.go
@@ -0,0 +1 @@
+package version