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 5b8b84a6 [operator] add Option determinator (#509)
5b8b84a6 is described below

commit 5b8b84a63b6556a91e4edc1d7280ec33e02b867f
Author: mfordjody <[email protected]>
AuthorDate: Sat Nov 30 08:22:15 2024 +0800

    [operator] add Option determinator (#509)
---
 dubboctl/pkg/cli/context.go     |  6 +++---
 operator/cmd/cluster/install.go |  2 +-
 operator/cmd/cluster/shared.go  | 45 +++++++++++++++++++++++++++++++++++++++++
 pkg/kube/client.go              |  6 +++---
 4 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/dubboctl/pkg/cli/context.go b/dubboctl/pkg/cli/context.go
index b3a2957a..b4fbaf3b 100644
--- a/dubboctl/pkg/cli/context.go
+++ b/dubboctl/pkg/cli/context.go
@@ -3,13 +3,13 @@ package cli
 import "github.com/apache/dubbo-kubernetes/pkg/kube"
 
 type instance struct {
-       client map[string]kube.CliClient
+       client map[string]kube.CLIClient
 }
 
 type Context interface {
-       CliClient() (kube.CliClient, error)
+       CLIClient() (kube.CLIClient, error)
 }
 
-func (i *instance) CliClient() (kube.CliClient, error) {
+func (i *instance) CLIClient() (kube.CLIClient, error) {
        return nil, nil
 }
diff --git a/operator/cmd/cluster/install.go b/operator/cmd/cluster/install.go
index 88c45014..b11ffa3e 100644
--- a/operator/cmd/cluster/install.go
+++ b/operator/cmd/cluster/install.go
@@ -52,6 +52,6 @@ func InstallCmdWithArgs(ctx cli.Context, rootArgs *RootArgs, 
iArgs *InstallArgs)
        return ic
 }
 
-func install(kubeClient kube.CliClient, rootArgs *RootArgs, iArgs 
*InstallArgs) error {
+func install(kubeClient kube.CLIClient, rootArgs *RootArgs, iArgs 
*InstallArgs) error {
        return nil
 }
diff --git a/operator/cmd/cluster/shared.go b/operator/cmd/cluster/shared.go
new file mode 100644
index 00000000..b394c570
--- /dev/null
+++ b/operator/cmd/cluster/shared.go
@@ -0,0 +1,45 @@
+package cluster
+
+import (
+       "fmt"
+       "io"
+       "strings"
+)
+
+type writerPrinter struct {
+       writer io.Writer
+}
+
+type Printer interface {
+       Printf(string, ...any)
+       Println(string)
+}
+
+func NewPtrForWtr(w io.Writer) Printer {
+       return &writerPrinter{writer: w}
+}
+
+func (w writerPrinter) Printf(format string, a ...any) {
+       _, _ = fmt.Fprintf(w.writer, format, a...)
+}
+
+func (w writerPrinter) Println(s string) {
+       _, _ = fmt.Fprintln(w.writer, s)
+}
+
+func OptionDeterminator(msg string, writer io.Writer) bool {
+       for {
+               _, _ = fmt.Fprintf(writer, "%s ", msg)
+               var resp string
+               _, err := fmt.Scanln(&resp)
+               if err != nil {
+                       return false
+               }
+               switch strings.ToUpper(resp) {
+               case "Y", "YES", "y", "yes":
+                       return true
+               case "N", "NO", "n", "no":
+                       return false
+               }
+       }
+}
diff --git a/pkg/kube/client.go b/pkg/kube/client.go
index 5cb871f6..ffe63086 100644
--- a/pkg/kube/client.go
+++ b/pkg/kube/client.go
@@ -6,10 +6,10 @@ type client struct {
 type Client interface {
 }
 
-type CliClient interface {
+type CLIClient interface {
 }
 
 var (
        _ Client    = &client{}
-       _ CliClient = &client{}
-)
\ No newline at end of file
+       _ CLIClient = &client{}
+)

Reply via email to