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 2025/07/21 16:52:54 UTC

(dubbo-kubernetes) branch master updated: [dubboctl] Change docker login option and other chore (#753)

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 eae35967 [dubboctl] Change docker login option and other chore (#753)
eae35967 is described below

commit eae359677f1c474512992bf14cf42505cfd42067
Author: Jian Zhong <11...@qq.com>
AuthorDate: Tue Jul 22 00:52:49 2025 +0800

    [dubboctl] Change docker login option and other chore (#753)
---
 .asf.yaml                                     |  2 ++
 README.md                                     | 13 ++------
 dubboctl/cmd/root.go                          | 21 ++++++++----
 dubboctl/cmd/seek.go                          | 17 ++++++++++
 dubboctl/pkg/chat/openai.go                   | 17 ++++++++++
 dubboctl/pkg/hub/credentials/prompt/prompt.go | 48 +++++++++++++++++++++++++++
 6 files changed, 102 insertions(+), 16 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 5852d510..933e7253 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -38,3 +38,5 @@ github:
     - kubernetes
     - microservices
     - service-mesh
+    - proxyless
+    - ai
diff --git a/README.md b/README.md
index a933c4d4..f56678c3 100644
--- a/README.md
+++ b/README.md
@@ -2,27 +2,20 @@
 The Dubbo Kubernetes Integration
 </h1>
 
-[![Build](https://github.com/apache/dubbo-kubernetes/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/dubbo-kubernetes/actions/workflows/ci.yml)
-[![codecov](https://codecov.io/gh/apache/dubbo-kubernetes/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-kubernetes)
 ![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)
 
-Provides observability features and supporting tools for building and deploying Dubbo applications in various environments, including Kubernetes and Alibaba Cloud ACK.
+Provides support for building and deploying Dubbo applications in various environments, including Kubernetes and Alibaba Cloud ACK.
 
 ## Repositories
 The main code repositories of Dubbo on Kubernetes include:
 
 - [dubboctl](dubboctl/). This directory contains code for the command line utility.
-- [admin](app/). This directory contains code for the
-[dubbo admin dashboard](https://github.com/apache/dubbo-kubernetes/blob/master/app/README.md).
-
-
+- [operator](operator/). Dubbo operator provides user friendly options to operate the Dubbo proxyless mesh
+- [helm-charts](manifests/charts). This directory contains the [Helm chart](https://github.com/apache/dubbo-helm-charts) sources, which are versioned, built, and pushed to the following Helm repositories with each Dubbo release.
 
 ## Quick Start
 Please refer to [official website](https://cn.dubbo.apache.org/zh-cn/overview/home/)
 
-## Roadmap
-Kubernetes mode support and proxyless mesh development.
-
 ## Contributing
 
 Refer to [CONTRIBUTING.md](https://github.com/apache/dubbo-kubernetes/blob/master/CONTRIBUTING.md)
diff --git a/dubboctl/cmd/root.go b/dubboctl/cmd/root.go
index b73a1ed4..25341821 100644
--- a/dubboctl/cmd/root.go
+++ b/dubboctl/cmd/root.go
@@ -19,6 +19,7 @@ package cmd
 
 import (
 	"flag"
+	"fmt"
 	"github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli"
 	"github.com/apache/dubbo-kubernetes/dubboctl/pkg/hub/builder/pack"
 	"github.com/apache/dubbo-kubernetes/dubboctl/pkg/hub/credentials"
@@ -33,7 +34,6 @@ import (
 	"github.com/spf13/cobra"
 	"net/http"
 	"os"
-	// "os"
 )
 
 const ChartFlag = "charts"
@@ -69,11 +69,20 @@ func newTransport(insecureSkipVerify bool) pusher.RoundTripCloser {
 }
 
 func newCredentialsProvider(configPath string, t http.RoundTripper) pusher.CredentialsProvider {
-	options := []credentials.Opt{
-		credentials.WithPromptForCredentials(prompt.NewPromptForCredentials(os.Stdin, os.Stdout, os.Stderr)),
-		credentials.WithPromptForCredentialStore(prompt.NewPromptForCredentialStore()),
-		credentials.WithTransport(t),
-	}
+	options := []credentials.Opt{}
+
+	options = append(options, credentials.WithPromptForCredentials(func(registry string) (pusher.Credentials, error) {
+		if creds, err := prompt.GetDockerAuth(registry); err == nil {
+			fmt.Fprintf(os.Stderr, "Using Docker credentials for registry: %s\n", registry)
+			return creds, nil
+		}
+		fmt.Fprintf(os.Stderr, "No saved Docker credentials found for %s, prompting...\n", registry)
+		return prompt.NewPromptForCredentials(os.Stdin, os.Stdout, os.Stderr)(registry)
+	}))
+
+	options = append(options, credentials.WithPromptForCredentialStore(prompt.NewPromptForCredentialStore()))
+	options = append(options, credentials.WithTransport(t))
+
 	return credentials.NewCredentialsProvider(configPath, options...)
 }
 
diff --git a/dubboctl/cmd/seek.go b/dubboctl/cmd/seek.go
index 06392607..f558cd28 100644
--- a/dubboctl/cmd/seek.go
+++ b/dubboctl/cmd/seek.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package cmd
 
 import (
diff --git a/dubboctl/pkg/chat/openai.go b/dubboctl/pkg/chat/openai.go
index af2f2784..fdbe154c 100644
--- a/dubboctl/pkg/chat/openai.go
+++ b/dubboctl/pkg/chat/openai.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package chat
 
 import llmopenai "github.com/tmc/langchaingo/llms/openai"
diff --git a/dubboctl/pkg/hub/credentials/prompt/prompt.go b/dubboctl/pkg/hub/credentials/prompt/prompt.go
index 5d422d5e..8ee705a6 100644
--- a/dubboctl/pkg/hub/credentials/prompt/prompt.go
+++ b/dubboctl/pkg/hub/credentials/prompt/prompt.go
@@ -19,6 +19,7 @@ package prompt
 
 import (
 	"bufio"
+	"encoding/base64"
 	"fmt"
 	"github.com/AlecAivazis/survey/v2"
 	"github.com/AlecAivazis/survey/v2/terminal"
@@ -27,6 +28,7 @@ import (
 	"golang.org/x/term"
 	"io"
 	"os"
+	"path/filepath"
 	"strings"
 )
 
@@ -147,3 +149,49 @@ you can install docker credential helper https://github.com/docker/docker-creden
 		return resp, nil
 	}
 }
+
+func GetDockerAuth(registry string) (pusher.Credentials, error) {
+	configFile := filepath.Join(os.Getenv("HOME"), ".docker", "config.json")
+	data, err := os.ReadFile(configFile)
+	if err != nil {
+		return pusher.Credentials{}, err
+	}
+
+	var config struct {
+		Auths map[string]struct {
+			Auth string `json:"auth"`
+		} `json:"auths"`
+	}
+
+	if err := json.Unmarshal(data, &config); err != nil {
+		return pusher.Credentials{}, err
+	}
+
+	// Define lookup order
+	lookupKeys := []string{
+		registry,
+		"https://" + registry,
+		"https://" + registry + "/v1/",
+	}
+
+	// Docker Hub special case
+	if registry == "index.docker.io" {
+		lookupKeys = append(lookupKeys, "https://index.docker.io/v1/")
+	}
+
+	for _, key := range lookupKeys {
+		if entry, ok := config.Auths[key]; ok {
+			decoded, err := base64.StdEncoding.DecodeString(entry.Auth)
+			if err != nil {
+				return pusher.Credentials{}, fmt.Errorf("failed to decode credentials: %w", err)
+			}
+			parts := strings.SplitN(string(decoded), ":", 2)
+			if len(parts) != 2 {
+				return pusher.Credentials{}, fmt.Errorf("invalid credentials format for %s", key)
+			}
+			return pusher.Credentials{Username: parts[0], Password: parts[1]}, nil
+		}
+	}
+
+	return pusher.Credentials{}, fmt.Errorf("no credentials found for registry: %s", registry)
+}