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 ebc28ef9 [operator] Supplementary code comments v4 (#648)
ebc28ef9 is described below

commit ebc28ef9a55b93ddf59306544edad8b175ca7523
Author: Jian Zhong <[email protected]>
AuthorDate: Thu Mar 20 12:50:40 2025 +0800

    [operator] Supplementary code comments v4 (#648)
---
 dubboctl/cmd/create.go          | 26 +++++++++++++-------------
 dubboctl/cmd/image.go           | 32 ++++++++++++++++++++------------
 dubboctl/pkg/util/err.go        |  4 +++-
 dubboctl/pkg/util/fs.go         |  2 +-
 operator/pkg/render/manifest.go |  2 +-
 pkg/version/version.go          |  6 +++---
 6 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/dubboctl/cmd/create.go b/dubboctl/cmd/create.go
index 4085b350..15661106 100644
--- a/dubboctl/cmd/create.go
+++ b/dubboctl/cmd/create.go
@@ -99,12 +99,12 @@ func sdkGenerateCmd(cmd *cobra.Command, clientFactory 
ClientFactory) *cobra.Comm
 }
 
 type createConfig struct {
-       Path       string
-       Runtime    string
-       Template   string
-       Repo       string
-       DirName    string
-       Initialzed bool
+       Path        string
+       Runtime     string
+       Template    string
+       Repo        string
+       DirName     string
+       Initialized bool
 }
 
 func newCreateConfig(_ *cobra.Command, _ []string, _ ClientFactory) (dcfg 
createConfig, err error) {
@@ -112,11 +112,11 @@ func newCreateConfig(_ *cobra.Command, _ []string, _ 
ClientFactory) (dcfg create
        absolutePath = cwd()
 
        dcfg = createConfig{
-               DirName:    viper.GetString("dirname"),
-               Path:       absolutePath + "/" + viper.GetString("dirname"),
-               Runtime:    viper.GetString("language"),
-               Template:   viper.GetString("template"),
-               Initialzed: viper.GetBool("initialzed"),
+               DirName:     viper.GetString("dirname"),
+               Path:        absolutePath + "/" + viper.GetString("dirname"),
+               Runtime:     viper.GetString("language"),
+               Template:    viper.GetString("template"),
+               Initialized: viper.GetBool("initialized"),
        }
        fmt.Printf("Name:     %v\n", dcfg.DirName)
        fmt.Printf("Path:     %v\n", dcfg.Path)
@@ -142,11 +142,11 @@ func runCreate(cmd *cobra.Command, args []string, 
clientFactory ClientFactory) e
                Name:     dcfg.DirName,
                Runtime:  dcfg.Runtime,
                Template: dcfg.Template,
-       }, dcfg.Initialzed, cmd)
+       }, dcfg.Initialized, cmd)
        if err != nil {
                return err
        }
-       fmt.Printf("Custom Dubbo %v sdk was successfully created.\n", 
dcfg.Runtime)
+       fmt.Printf("Custom dubbo %v sdk was successfully created.\n", 
dcfg.Runtime)
        return nil
 }
 
diff --git a/dubboctl/cmd/image.go b/dubboctl/cmd/image.go
index 3f431c24..da4a586f 100644
--- a/dubboctl/cmd/image.go
+++ b/dubboctl/cmd/image.go
@@ -119,10 +119,15 @@ func (dc deployConfig) deployClientOptions() 
([]sdk.Option, error) {
 func imageHubCmd(cmd *cobra.Command, clientFactory ClientFactory) 
*cobra.Command {
        iArgs := &imageArgs{}
        hc := &cobra.Command{
-               Use:     "hub",
-               Short:   "Build and Push to images",
-               Long:    "The hub subcommand used to build and push images",
-               Example: "",
+               Use:   "hub",
+               Short: "Build and Push to images",
+               Long:  "The hub subcommand used to build and push images",
+               Example: `  # Build an image using a Dockerfile.
+  dubboctl image hub -f Dockerfile
+
+  # Build an image using a builder.
+  dubboctl image hub -b
+`,
                Args: func(cmd *cobra.Command, args []string) error {
                        if cmd.Flags().Changed("file") {
                                if len(args) != 1 {
@@ -214,10 +219,15 @@ func runHub(cmd *cobra.Command, args []string, 
clientFactory ClientFactory) erro
 func imageDeployCmd(cmd *cobra.Command, clientFactory ClientFactory) 
*cobra.Command {
        iArgs := &imageArgs{}
        hc := &cobra.Command{
-               Use:     "deploy",
-               Short:   "Deploy to cluster",
-               Long:    "The deploy subcommand used to deploy to cluster",
-               Example: "",
+               Use:   "deploy",
+               Short: "Deploy to cluster",
+               Long:  "The deploy subcommand used to deploy to cluster",
+               Example: `  # Deploy the application to the cluster.
+  dubboctl image deploy
+
+  # Delete the deployed application.
+  dubboctl image deploy -d
+`,
                PreRunE: bindEnv("output", "delete"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runDeploy(cmd, args, clientFactory)
@@ -291,8 +301,7 @@ func runDeploy(cmd *cobra.Command, args []string, 
clientFactory ClientFactory) e
 func apply(cmd *cobra.Command, dc *dubbo.DubboConfig) error {
        file := filepath.Join(dc.Root, dc.Deploy.Output)
        ec := exec.CommandContext(cmd.Context(), "kubectl", "apply", "-f", file)
-       ec.Stdout = os.Stdout
-       ec.Stderr = os.Stderr
+       ec.Stdout, ec.Stderr = os.Stdout, os.Stderr
        if err := ec.Run(); err != nil {
                return err
        }
@@ -302,8 +311,7 @@ func apply(cmd *cobra.Command, dc *dubbo.DubboConfig) error 
{
 func remove(cmd *cobra.Command, dc *dubbo.DubboConfig) error {
        file := filepath.Join(dc.Root, dc.Deploy.Output)
        ec := exec.CommandContext(cmd.Context(), "kubectl", "delete", "-f", 
file)
-       ec.Stdout = os.Stdout
-       ec.Stderr = os.Stderr
+       ec.Stdout, ec.Stderr = os.Stdout, os.Stderr
        if err := ec.Run(); err != nil {
                return err
        }
diff --git a/dubboctl/pkg/util/err.go b/dubboctl/pkg/util/err.go
index 56ff6756..3b0aad10 100644
--- a/dubboctl/pkg/util/err.go
+++ b/dubboctl/pkg/util/err.go
@@ -24,7 +24,9 @@ type ErrNotInitialized struct {
 }
 
 func NewErrNotInitialized(path string) error {
-       return &ErrNotInitialized{Path: path}
+       return &ErrNotInitialized{
+               Path: path,
+       }
 }
 
 func (e ErrNotInitialized) Error() string {
diff --git a/dubboctl/pkg/util/fs.go b/dubboctl/pkg/util/fs.go
index 6b027c59..0516ac28 100644
--- a/dubboctl/pkg/util/fs.go
+++ b/dubboctl/pkg/util/fs.go
@@ -35,7 +35,7 @@ import (
        billy "github.com/go-git/go-billy/v5"
 )
 
-// Filesystems
+// Filesystem
 // Wrap the implementations of FS with their subtle differences into the
 // common interface for accessing template files defined herein.
 // os:    standard for on-disk extensible template repositories.
diff --git a/operator/pkg/render/manifest.go b/operator/pkg/render/manifest.go
index 26b5d8dc..8a54221d 100644
--- a/operator/pkg/render/manifest.go
+++ b/operator/pkg/render/manifest.go
@@ -149,7 +149,7 @@ func GenerateManifest(files []string, setFlags []string, 
logger clog.Logger, _ k
        // This allows safe access to get/fetch values dynamically, and avoids 
issues are typing and whether we should emit empty fields.
        merged, err := MergeInputs(files, setFlags)
        if err != nil {
-               return nil, nil, fmt.Errorf("merge inputs: %v %v", err)
+               return nil, nil, fmt.Errorf("merge inputs: %v", err)
        }
        // Validate the config. This can emit warnings to the logger. If force 
is set, errors will be logged as warnings but not returned.
        if err := validateDubboOperator(merged, logger); err != nil {
diff --git a/pkg/version/version.go b/pkg/version/version.go
index b5aeacd0..56dce906 100644
--- a/pkg/version/version.go
+++ b/pkg/version/version.go
@@ -27,12 +27,12 @@ var (
        buildVersion = "unknown"
 )
 
-//type BuildInfo struct {
+// type BuildInfo struct {
 //     Version string `json:"version"`
-//}
+// }
 
 func (b BuildInfo) String() string {
-       return fmt.Sprintf("%v-%v-%v", b.Version)
+       return fmt.Sprintf("%v", b.Version)
 }
 
 func (b BuildInfo) LongForm() string {

Reply via email to