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 c266f022 [dubboctl] Fixing misquoted packages
c266f022 is described below

commit c266f02246c0c55bf6738f9c8a6fe2c82e61bd25
Author: mfordjody <[email protected]>
AuthorDate: Tue Oct 29 21:20:04 2024 +0800

    [dubboctl] Fixing misquoted packages
---
 dubboctl/cmd/root.go                               | 16 +++----
 dubboctl/pkg/deploy/build.go                       | 23 +++++-----
 dubboctl/pkg/deploy/create.go                      | 39 +++++++++--------
 dubboctl/pkg/deploy/deploy.go                      | 47 ++++++++++----------
 dubboctl/pkg/deploy/repository.go                  | 51 +++++++++++-----------
 .../pkg/deploy/{completion_util.go => util.go}     |  0
 6 files changed, 90 insertions(+), 86 deletions(-)

diff --git a/dubboctl/cmd/root.go b/dubboctl/cmd/root.go
index 0ee0bc97..0fa886d8 100644
--- a/dubboctl/cmd/root.go
+++ b/dubboctl/cmd/root.go
@@ -17,8 +17,8 @@ package cmd
 
 import (
        "fmt"
-       "github.com/apache/dubbo-kubernetes/dubboctl/pkg/build"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/dashboard"
+       "github.com/apache/dubbo-kubernetes/dubboctl/pkg/deploy"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/generate"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/manifest"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/profile"
@@ -40,7 +40,7 @@ import (
 
 type RootCommandConfig struct {
        Name      string
-       NewClient build.ClientFactory
+       NewClient deploy.ClientFactory
 }
 
 var controlPlaneLog = core.Log.WithName("dubboctl")
@@ -81,7 +81,7 @@ func GetRootCmd(args []string) *cobra.Command {
        viper.SetEnvPrefix("dubbo") // ensure that all have the prefix
        newClient := cfg.NewClient
        if newClient == nil {
-               newClient = build.NewClient
+               newClient = deploy.NewClient
        }
 
        addSubCommands(rootCmd, newClient)
@@ -89,11 +89,11 @@ func GetRootCmd(args []string) *cobra.Command {
        return rootCmd
 }
 
-func addSubCommands(rootCmd *cobra.Command, newClient build.ClientFactory) {
-       build.AddBuild(rootCmd, newClient)
-       build.AddCreate(rootCmd, newClient)
-       build.AddRepository(rootCmd, newClient)
-       build.AddDeploy(rootCmd, newClient)
+func addSubCommands(rootCmd *cobra.Command, newClient deploy.ClientFactory) {
+       deploy.AddBuild(rootCmd, newClient)
+       deploy.AddCreate(rootCmd, newClient)
+       deploy.AddRepository(rootCmd, newClient)
+       deploy.AddDeploy(rootCmd, newClient)
        manifest.AddManifest(rootCmd)
        generate.AddGenerate(rootCmd)
        profile.AddProfile(rootCmd)
diff --git a/dubboctl/pkg/deploy/build.go b/dubboctl/pkg/deploy/build.go
index ac3e82b1..e70f150b 100644
--- a/dubboctl/pkg/deploy/build.go
+++ b/dubboctl/pkg/deploy/build.go
@@ -17,6 +17,7 @@ package deploy
 
 import (
        "fmt"
+       "github.com/apache/dubbo-kubernetes/dubboctl/cmd"
        "os"
        "strings"
 )
@@ -36,33 +37,33 @@ import (
        "github.com/apache/dubbo-kubernetes/dubboctl/internal/util"
 )
 
-func addBuild(baseCmd *cobra.Command, newClient ClientFactory) {
-       cmd := &cobra.Command{
+func AddBuild(baseCmd *cobra.Command, newClient ClientFactory) {
+       cmds := &cobra.Command{
                Use:        "build",
                Short:      "Build the image for the application",
                Long:       ``,
                SuggestFor: []string{"biuld", "buidl", "built"},
-               PreRunE: bindEnv("useDockerfile", "image", "path", "push", 
"force", "envs",
+               PreRunE: cmd.BindEnv("useDockerfile", "image", "path", "push", 
"force", "envs",
                        "builder-image"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runBuildCmd(cmd, newClient)
                },
        }
 
-       cmd.Flags().StringP("builder-image", "b", "",
+       cmds.Flags().StringP("builder-image", "b", "",
                "Specify a custom builder image for use by the builder other 
than its default.")
-       cmd.Flags().BoolP("useDockerfile", "d", false,
+       cmds.Flags().BoolP("useDockerfile", "d", false,
                "Use the dockerfile with the specified path to build")
-       cmd.Flags().StringP("image", "i", "",
+       cmds.Flags().StringP("image", "i", "",
                "Container image( [registry]/[namespace]/[name]:[tag] )")
-       cmd.Flags().BoolP("push", "", true,
+       cmds.Flags().BoolP("push", "", true,
                "Whether to push the image to the registry center by the way")
-       cmd.Flags().BoolP("force", "f", false,
+       cmds.Flags().BoolP("force", "f", false,
                "Whether to force build")
-       cmd.Flags().StringArrayP("envs", "e", []string{},
+       cmds.Flags().StringArrayP("envs", "e", []string{},
                "environment variable for an application, KEY=VALUE format")
-       addPathFlag(cmd)
-       baseCmd.AddCommand(cmd)
+       cmd.AddPathFlag(cmds)
+       baseCmd.AddCommand(cmds)
 }
 
 func runBuildCmd(cmd *cobra.Command, newClient ClientFactory) error {
diff --git a/dubboctl/pkg/deploy/create.go b/dubboctl/pkg/deploy/create.go
index 1fc0cc92..caaeaee7 100644
--- a/dubboctl/pkg/deploy/create.go
+++ b/dubboctl/pkg/deploy/create.go
@@ -18,6 +18,7 @@ package deploy
 import (
        "errors"
        "fmt"
+       "github.com/apache/dubbo-kubernetes/dubboctl/cmd"
        "os"
        "strings"
        "text/tabwriter"
@@ -47,8 +48,8 @@ type ErrInvalidRuntime error
 type ErrInvalidTemplate error
 
 // NewCreateCmd creates a create command using the given client creator.
-func addCreate(baseCmd *cobra.Command, newClient ClientFactory) {
-       cmd := &cobra.Command{
+func AddCreate(baseCmd *cobra.Command, newClient ClientFactory) {
+       cmds := &cobra.Command{
                Use:   "create",
                Short: "Create an application",
                Long: `
@@ -94,7 +95,7 @@ EXAMPLES
          $ {{.Name}} create -l go -t common mydubbo
                `,
                SuggestFor: []string{"vreate", "creaet", "craete", "new"},
-               PreRunE:    bindEnv("language", "template", "repository", 
"confirm", "init"),
+               PreRunE:    cmd.BindEnv("language", "template", "repository", 
"confirm", "init"),
                Aliases:    []string{"init"},
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runCreate(cmd, args, newClient)
@@ -102,26 +103,26 @@ EXAMPLES
        }
 
        // Flags
-       cmd.Flags().StringP("language", "l", "", "Language Runtime (see help 
text for list) ($DUBBO_LANGUAGE)")
-       cmd.Flags().StringP("template", "t", "", "Application template. (see 
help text for list) ($DUBBO_TEMPLATE)")
-       cmd.Flags().StringP("repository", "r", "", "URI to a Git repository 
containing the specified template ($DUBBO_REPOSITORY)")
-       cmd.Flags().BoolP("init", "i", false,
+       cmds.Flags().StringP("language", "l", "", "Language Runtime (see help 
text for list) ($DUBBO_LANGUAGE)")
+       cmds.Flags().StringP("template", "t", "", "Application template. (see 
help text for list) ($DUBBO_TEMPLATE)")
+       cmds.Flags().StringP("repository", "r", "", "URI to a Git repository 
containing the specified template ($DUBBO_REPOSITORY)")
+       cmds.Flags().BoolP("init", "i", false,
                "Initialize the current project directly into a dubbo project 
without using a template")
 
-       addConfirmFlag(cmd, false)
+       cmd.AddConfirmFlag(cmds, false)
 
        // Help Action
-       cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { 
runCreateHelp(cmd, args, newClient) })
+       cmds.SetHelpFunc(func(cmd *cobra.Command, args []string) { 
runCreateHelp(cmd, args, newClient) })
 
        // Tab completion
-       if err := cmd.RegisterFlagCompletionFunc("language", 
newRuntimeCompletionFunc(newClient)); err != nil {
+       if err := cmds.RegisterFlagCompletionFunc("language", 
newRuntimeCompletionFunc(newClient)); err != nil {
                fmt.Fprintf(os.Stderr, "unable to provide language runtime 
suggestions: %v\n", err)
        }
-       if err := cmd.RegisterFlagCompletionFunc("template", 
newTemplateCompletionFunc(newClient)); err != nil {
+       if err := cmds.RegisterFlagCompletionFunc("template", 
newTemplateCompletionFunc(newClient)); err != nil {
                fmt.Fprintf(os.Stderr, "unable to provide template suggestions: 
%v\n", err)
        }
 
-       baseCmd.AddCommand(cmd)
+       baseCmd.AddCommand(cmds)
 }
 
 // Run Create
@@ -188,7 +189,7 @@ type createConfig struct {
 // The client constructor function is used to create a transient client for
 // accessing things like the current valid templates list, and uses the
 // current value of the config at time of prompting.
-func newCreateConfig(cmd *cobra.Command, args []string, newClient 
ClientFactory) (cfg createConfig, err error) {
+func newCreateConfig(cmds *cobra.Command, args []string, newClient 
ClientFactory) (cfg createConfig, err error) {
        var (
                path         string
                dirName      string
@@ -199,7 +200,7 @@ func newCreateConfig(cmd *cobra.Command, args []string, 
newClient ClientFactory)
                path = args[0]
        }
 
-       dirName, absolutePath = deriveNameAndAbsolutePathFromPath(path)
+       dirName, absolutePath = cmd.DeriveNameAndAbsolutePathFromPath(path)
 
        // Config is the final default values based off the execution context.
        // When prompting, these become the defaults presented.
@@ -229,7 +230,7 @@ func newCreateConfig(cmd *cobra.Command, args []string, 
newClient ClientFactory)
                        return createdCfg, err
                }
                fmt.Println("Command:")
-               fmt.Println(singleCommand(cmd, args, createdCfg))
+               fmt.Println(singleCommand(cmds, args, createdCfg))
                return createdCfg, nil
        }
 
@@ -271,7 +272,7 @@ func singleCommand(cmd *cobra.Command, args []string, cfg 
createConfig) string {
 // pre-client validation should not be required, as the Client does its own
 // validation.
 func (c createConfig) Validate(client *dubbo.Client) (err error) {
-       dirName, _ := deriveNameAndAbsolutePathFromPath(c.Path)
+       dirName, _ := cmd.DeriveNameAndAbsolutePathFromPath(c.Path)
        if err = util.ValidateApplicationName(dirName); err != nil {
                return
        }
@@ -403,11 +404,11 @@ func (c createConfig) prompt(client *dubbo.Client) 
(createConfig, error) {
                                Default: c.Path,
                        },
                        Validate: func(val interface{}) error {
-                               derivedName, _ := 
deriveNameAndAbsolutePathFromPath(val.(string))
+                               derivedName, _ := 
cmd.DeriveNameAndAbsolutePathFromPath(val.(string))
                                return util.ValidateApplicationName(derivedName)
                        },
                        Transform: func(ans interface{}) interface{} {
-                               _, absolutePath := 
deriveNameAndAbsolutePathFromPath(ans.(string))
+                               _, absolutePath := 
cmd.DeriveNameAndAbsolutePathFromPath(ans.(string))
                                return absolutePath
                        },
                }, {
@@ -415,7 +416,7 @@ func (c createConfig) prompt(client *dubbo.Client) 
(createConfig, error) {
                        Prompt: &survey.Select{
                                Message: "Language Runtime:",
                                Options: runtimes,
-                               Default: surveySelectDefault(c.Runtime, 
runtimes),
+                               Default: cmd.SurveySelectDefault(c.Runtime, 
runtimes),
                        },
                },
        }
diff --git a/dubboctl/pkg/deploy/deploy.go b/dubboctl/pkg/deploy/deploy.go
index f7de1561..0f6dfc4f 100644
--- a/dubboctl/pkg/deploy/deploy.go
+++ b/dubboctl/pkg/deploy/deploy.go
@@ -18,6 +18,7 @@ package deploy
 import (
        "errors"
        "fmt"
+       "github.com/apache/dubbo-kubernetes/dubboctl/cmd"
        "os"
        "os/exec"
        "path/filepath"
@@ -48,8 +49,8 @@ const (
        portLimit = 32767
 )
 
-func addDeploy(baseCmd *cobra.Command, newClient ClientFactory) {
-       cmd := &cobra.Command{
+func AddDeploy(baseCmd *cobra.Command, newClient ClientFactory) {
+       cmds := &cobra.Command{
                Use:   "deploy",
                Short: "Generate the k8s yaml of the application. By the way, 
you can choose to build the image, push the image and apply to the k8s 
cluster.",
                Long: `
@@ -60,55 +61,55 @@ SYNOPSIS
        dubboctl deploy [flags]
 `,
                SuggestFor: []string{"delpoy", "deplyo"},
-               PreRunE: bindEnv("path", "output", "namespace", "image", 
"envs", "name", "containerPort",
+               PreRunE: cmd.BindEnv("path", "output", "namespace", "image", 
"envs", "name", "containerPort",
                        "targetPort", "nodePort", "apply", "useDockerfile", 
"force", "builder-image", "build", "context",
                        "kubeConfig", "push"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runDeploy(cmd, newClient)
                },
        }
-       cmd.Flags().StringP("namespace", "n", "default",
+       cmds.Flags().StringP("namespace", "n", "default",
                "Deploy into a specific namespace")
-       cmd.Flags().StringP("output", "o", "kube.yaml",
+       cmds.Flags().StringP("output", "o", "kube.yaml",
                "output kubernetes manifest")
-       cmd.Flags().StringP("name", "", "",
+       cmds.Flags().StringP("name", "", "",
                "The name of application")
-       cmd.Flags().IntP("containerPort", "", 0,
+       cmds.Flags().IntP("containerPort", "", 0,
                "The port of the deployment to listen on pod (required)")
-       cmd.Flags().IntP("targetPort", "", 0,
+       cmds.Flags().IntP("targetPort", "", 0,
                "The targetPort of the deployment, default to port")
-       cmd.Flags().IntP("nodePort", "", 0,
+       cmds.Flags().IntP("nodePort", "", 0,
                "The nodePort of the deployment to expose")
 
-       cmd.Flags().StringP("context", "", "",
+       cmds.Flags().StringP("context", "", "",
                "Context in kubeconfig to use")
-       cmd.Flags().StringP("kubeConfig", "k", "",
+       cmds.Flags().StringP("kubeConfig", "k", "",
                "Path to kubeconfig")
 
-       cmd.Flags().StringArrayP("envs", "e", nil,
+       cmds.Flags().StringArrayP("envs", "e", nil,
                "DeployMode variable to set in the form NAME=VALUE. "+
                        "This is for the environment variables passed in by the 
builderpack build method.")
-       cmd.Flags().StringP("builder-image", "b", "",
+       cmds.Flags().StringP("builder-image", "b", "",
                "Specify a custom builder image for use by the builder other 
than its default.")
-       cmd.Flags().BoolP("useDockerfile", "d", false,
+       cmds.Flags().BoolP("useDockerfile", "d", false,
                "Use the dockerfile with the specified path to build")
-       cmd.Flags().StringP("image", "i", "",
+       cmds.Flags().StringP("image", "i", "",
                "Container image( [registry]/[namespace]/[name]:[tag] )")
-       cmd.Flags().BoolP("push", "", true,
+       cmds.Flags().BoolP("push", "", true,
                "Whether to push the image to the registry center by the way")
-       cmd.Flags().BoolP("force", "f", false,
+       cmds.Flags().BoolP("force", "f", false,
                "Whether to force build")
 
-       cmd.Flags().BoolP("build", "", true,
+       cmds.Flags().BoolP("build", "", true,
                "Whether to build the image")
-       cmd.Flags().BoolP("apply", "a", false,
+       cmds.Flags().BoolP("apply", "a", false,
                "Whether to apply the application to the k8s cluster by the 
way")
-       cmd.Flags().StringP("portName", "", "http",
+       cmds.Flags().StringP("portName", "", "http",
                "Name of the port to be exposed")
 
-       addPathFlag(cmd)
-       cmd.Flags().SetInterspersed(false)
-       baseCmd.AddCommand(cmd)
+       cmd.AddPathFlag(cmds)
+       cmds.Flags().SetInterspersed(false)
+       baseCmd.AddCommand(cmds)
 }
 
 func runDeploy(cmd *cobra.Command, newClient ClientFactory) error {
diff --git a/dubboctl/pkg/deploy/repository.go 
b/dubboctl/pkg/deploy/repository.go
index 3d39c0ef..771b2191 100644
--- a/dubboctl/pkg/deploy/repository.go
+++ b/dubboctl/pkg/deploy/repository.go
@@ -18,6 +18,7 @@ package deploy
 import (
        "errors"
        "fmt"
+       "github.com/apache/dubbo-kubernetes/dubboctl/cmd"
        "os"
 )
 
@@ -36,8 +37,8 @@ import (
 
 // command constructors
 // --------------------
-func addRepository(baseCmd *cobra.Command, newClient ClientFactory) {
-       cmd := &cobra.Command{
+func AddRepository(baseCmd *cobra.Command, newClient ClientFactory) {
+       cmds := &cobra.Command{
                Short:   "Manage installed template repositories",
                Use:     "repository",
                Aliases: []string{"repo", "repositories"},
@@ -165,81 +166,81 @@ EXAMPLES
          default
 `,
                SuggestFor: []string{"repositories", "repos", "template", 
"templates", "pack", "packs"},
-               PreRunE:    bindEnv("confirm"),
+               PreRunE:    cmd.BindEnv("confirm"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runRepository(cmd, args, newClient)
                },
        }
 
-       addConfirmFlag(cmd, false)
+       cmd.AddConfirmFlag(cmds, false)
 
-       cmd.AddCommand(NewRepositoryListCmd(newClient))
-       cmd.AddCommand(NewRepositoryAddCmd(newClient))
-       cmd.AddCommand(NewRepositoryRenameCmd(newClient))
-       cmd.AddCommand(NewRepositoryRemoveCmd(newClient))
+       cmds.AddCommand(NewRepositoryListCmd(newClient))
+       cmds.AddCommand(NewRepositoryAddCmd(newClient))
+       cmds.AddCommand(NewRepositoryRenameCmd(newClient))
+       cmds.AddCommand(NewRepositoryRemoveCmd(newClient))
 
-       baseCmd.AddCommand(cmd)
+       baseCmd.AddCommand(cmds)
 }
 
 func NewRepositoryListCmd(newClient ClientFactory) *cobra.Command {
-       cmd := &cobra.Command{
+       cmds := &cobra.Command{
                Short:   "List repositories",
                Use:     "list",
                Aliases: []string{"ls"},
-               PreRunE: bindEnv("confirm"),
+               PreRunE: cmd.BindEnv("confirm"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runRepositoryList(cmd, args, newClient)
                },
        }
 
-       addConfirmFlag(cmd, false)
-       return cmd
+       cmd.AddConfirmFlag(cmds, false)
+       return cmds
 }
 
 func NewRepositoryAddCmd(newClient ClientFactory) *cobra.Command {
-       cmd := &cobra.Command{
+       cmds := &cobra.Command{
                Short:      "Add a repository",
                Use:        "add <name> <url>",
                SuggestFor: []string{"ad", "install"},
-               PreRunE:    bindEnv("confirm"),
+               PreRunE:    cmd.BindEnv("confirm"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runRepositoryAdd(cmd, args, newClient)
                },
        }
 
-       addConfirmFlag(cmd, false)
-       return cmd
+       cmd.AddConfirmFlag(cmds, false)
+       return cmds
 }
 
 func NewRepositoryRenameCmd(newClient ClientFactory) *cobra.Command {
-       cmd := &cobra.Command{
+       cmds := &cobra.Command{
                Short:   "Rename a repository",
                Use:     "rename <old> <new>",
                Aliases: []string{"mv"},
-               PreRunE: bindEnv("confirm"),
+               PreRunE: cmd.BindEnv("confirm"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runRepositoryRename(cmd, args, newClient)
                },
        }
 
-       addConfirmFlag(cmd, false)
-       return cmd
+       cmd.AddConfirmFlag(cmds, false)
+       return cmds
 }
 
 func NewRepositoryRemoveCmd(newClient ClientFactory) *cobra.Command {
-       cmd := &cobra.Command{
+       cmds := &cobra.Command{
                Short:      "Remove a repository",
                Use:        "remove <name>",
                Aliases:    []string{"rm"},
                SuggestFor: []string{"delete", "del"},
-               PreRunE:    bindEnv("confirm"),
+               PreRunE:    cmd.BindEnv("confirm"),
                RunE: func(cmd *cobra.Command, args []string) error {
                        return runRepositoryRemove(cmd, args, newClient)
                },
        }
 
-       addConfirmFlag(cmd, false)
-       return cmd
+       cmd.AddConfirmFlag(cmds, false)
+       return cmds
 }
 
 // command implementations
diff --git a/dubboctl/pkg/deploy/completion_util.go 
b/dubboctl/pkg/deploy/util.go
similarity index 100%
rename from dubboctl/pkg/deploy/completion_util.go
rename to dubboctl/pkg/deploy/util.go

Reply via email to