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 6d4c6d7a [dubboctl] Refactor Part of the Directory Structure
6d4c6d7a is described below

commit 6d4c6d7afaeeba737dadcdac4716946027df60d0
Author: mfordjody <[email protected]>
AuthorDate: Wed Oct 30 08:51:23 2024 +0800

    [dubboctl] Refactor Part of the Directory Structure
---
 dubboctl/cmd/root.go                                    | 9 ++++-----
 dubboctl/pkg/common/common.go                           | 3 +++
 dubboctl/{cmd/proxy_context.go => pkg/proxy/context.go} | 2 +-
 dubboctl/{cmd => pkg/proxy}/proxy.go                    | 7 ++++---
 dubboctl/{cmd => pkg/registry}/registry.go              | 4 ++--
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/dubboctl/cmd/root.go b/dubboctl/cmd/root.go
index 82bf9a5e..3e00bea0 100644
--- a/dubboctl/cmd/root.go
+++ b/dubboctl/cmd/root.go
@@ -21,6 +21,8 @@ import (
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/generate"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/manifest"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/profile"
+       "github.com/apache/dubbo-kubernetes/dubboctl/pkg/proxy"
+       "github.com/apache/dubbo-kubernetes/dubboctl/pkg/registry"
 )
 
 import (
@@ -30,7 +32,6 @@ import (
 )
 
 import (
-       "github.com/apache/dubbo-kubernetes/pkg/core"
        cmd2 "github.com/apache/dubbo-kubernetes/pkg/core/cmd"
 )
 
@@ -39,8 +40,6 @@ type RootCommandConfig struct {
        NewClient deploy.ClientFactory
 }
 
-var controlPlaneLog = core.Log.WithName("dubboctl")
-
 // Execute adds all child commands to the root command and sets flags 
appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
 func Execute(args []string) {
@@ -94,6 +93,6 @@ func addSubCommands(rootCmd *cobra.Command, newClient 
deploy.ClientFactory) {
        generate.AddGenerate(rootCmd)
        profile.AddProfile(rootCmd)
        dashboard.AddDashboard(rootCmd)
-       addRegistryCmd(rootCmd)
-       addProxy(cmd2.DefaultRunCmdOpts, rootCmd)
+       registry.AddRegistryCmd(rootCmd)
+       proxy.AddProxy(cmd2.DefaultRunCmdOpts, rootCmd)
 }
diff --git a/dubboctl/pkg/common/common.go b/dubboctl/pkg/common/common.go
index 48fb8f6f..bc8b8e20 100644
--- a/dubboctl/pkg/common/common.go
+++ b/dubboctl/pkg/common/common.go
@@ -17,6 +17,7 @@ package common
 
 import (
        "fmt"
+       "github.com/apache/dubbo-kubernetes/pkg/core"
        "github.com/ory/viper"
        "github.com/spf13/cobra"
        "os"
@@ -24,6 +25,8 @@ import (
        "strings"
 )
 
+var ControlPlaneLog = core.Log.WithName("dubboctl")
+
 // bindFunc which conforms to the cobra PreRunE method signature
 type bindFunc func(*cobra.Command, []string) error
 
diff --git a/dubboctl/cmd/proxy_context.go b/dubboctl/pkg/proxy/context.go
similarity index 99%
rename from dubboctl/cmd/proxy_context.go
rename to dubboctl/pkg/proxy/context.go
index 4de62645..85c061d0 100644
--- a/dubboctl/cmd/proxy_context.go
+++ b/dubboctl/pkg/proxy/context.go
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package cmd
+package proxy
 
 import (
        "os"
diff --git a/dubboctl/cmd/proxy.go b/dubboctl/pkg/proxy/proxy.go
similarity index 97%
rename from dubboctl/cmd/proxy.go
rename to dubboctl/pkg/proxy/proxy.go
index 98f29186..f72c3320 100644
--- a/dubboctl/cmd/proxy.go
+++ b/dubboctl/pkg/proxy/proxy.go
@@ -15,11 +15,12 @@
  * limitations under the License.
  */
 
-package cmd
+package proxy
 
 import (
        "context"
        "fmt"
+       "github.com/apache/dubbo-kubernetes/dubboctl/pkg/common"
        "io"
        "os"
        "path/filepath"
@@ -50,7 +51,7 @@ import (
        "github.com/apache/dubbo-kubernetes/pkg/util/template"
 )
 
-var runLog = controlPlaneLog.WithName("proxy")
+var runLog = common.ControlPlaneLog.WithName("proxy")
 
 type ResourceType string
 
@@ -95,7 +96,7 @@ func writeFile(filename string, data []byte, perm 
os.FileMode) error {
        return os.WriteFile(filename, data, perm)
 }
 
-func addProxy(opts dubbo_cmd.RunCmdOpts, cmd *cobra.Command) {
+func AddProxy(opts dubbo_cmd.RunCmdOpts, cmd *cobra.Command) {
        proxyArgs := DefaultProxyConfig()
        cfg := proxyArgs.Config
        var proxyResource model.Resource
diff --git a/dubboctl/cmd/registry.go b/dubboctl/pkg/registry/registry.go
similarity index 97%
rename from dubboctl/cmd/registry.go
rename to dubboctl/pkg/registry/registry.go
index b47f6491..222615ff 100644
--- a/dubboctl/cmd/registry.go
+++ b/dubboctl/pkg/registry/registry.go
@@ -13,7 +13,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package cmd
+package registry
 
 import (
        "github.com/spf13/cobra"
@@ -23,7 +23,7 @@ import (
        "github.com/apache/dubbo-kubernetes/dubboctl/internal/registry/zk"
 )
 
-func addRegistryCmd(rootCmd *cobra.Command) {
+func AddRegistryCmd(rootCmd *cobra.Command) {
        addZkRegistryCmd(rootCmd)
 }
 

Reply via email to