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 0800e6e7 [operator] Wrapping generic maps for helm rendering (#511)
0800e6e7 is described below

commit 0800e6e776833a0e0cb3e076a29c8a5b4657ac92
Author: mfordjody <[email protected]>
AuthorDate: Sat Nov 30 09:46:49 2024 +0800

    [operator] Wrapping generic maps for helm rendering (#511)
---
 operator/cmd/cluster/install.go |  2 +-
 operator/pkg/helm/helm.go       | 23 +++++++----------------
 operator/pkg/values/map.go      | 30 ++++++++++++++++++++++++++++++
 pkg/art/atr.go                  |  7 +++++--
 4 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/operator/cmd/cluster/install.go b/operator/cmd/cluster/install.go
index b11ffa3e..b5ce32ed 100644
--- a/operator/cmd/cluster/install.go
+++ b/operator/cmd/cluster/install.go
@@ -42,7 +42,7 @@ func InstallCmdWithArgs(ctx cli.Context, rootArgs *RootArgs, 
iArgs *InstallArgs)
                dubboctl install --profile=default`,
                Args: cobra.ExactArgs(0),
                RunE: func(cmd *cobra.Command, args []string) error {
-                       _, err := ctx.CliClient()
+                       _, err := ctx.CLIClient()
                        if err != nil {
                                return err
                        }
diff --git a/operator/pkg/helm/helm.go b/operator/pkg/helm/helm.go
index e5326265..0f9a725d 100644
--- a/operator/pkg/helm/helm.go
+++ b/operator/pkg/helm/helm.go
@@ -1,10 +1,10 @@
 package helm
 
 import (
+       "github.com/apache/dubbo-kubernetes/operator/pkg/values"
        "helm.sh/helm/v3/pkg/chart"
        "helm.sh/helm/v3/pkg/chartutil"
        "helm.sh/helm/v3/pkg/engine"
-       "io/fs"
        "sort"
        "strings"
 )
@@ -15,18 +15,6 @@ const (
        NotesFileNameSuffix = ".txt"
 )
 
-func getFilesRecursive() {
-
-}
-
-func stripPrefix() {
-
-}
-
-func loaderChart(f fs.FS, root string) (*chart.Chart, error) {
-       return nil, nil
-}
-
 func readerChart(namespace string, chrt *chart.Chart) ([]string, error) {
        var s []string
        opts := chartutil.ReleaseOptions{
@@ -55,6 +43,9 @@ func readerChart(namespace string, chrt *chart.Chart) 
([]string, error) {
        return s, nil
 }
 
-func Reader() {
-
-}
+func Reader(namespace string, dir string, dop values.Map) {
+       _, ok := dop.GetPathMap("spec.values")
+       if !ok {
+               return
+       }
+}
\ No newline at end of file
diff --git a/operator/pkg/values/map.go b/operator/pkg/values/map.go
index 93910303..e3615272 100644
--- a/operator/pkg/values/map.go
+++ b/operator/pkg/values/map.go
@@ -5,6 +5,7 @@ import (
        "fmt"
        "github.com/apache/dubbo-kubernetes/pkg/pointer"
        "sigs.k8s.io/yaml"
+       "strings"
 )
 
 type Map map[string]any
@@ -60,3 +61,32 @@ func fromYAML[T any](overlay []byte) (T, error) {
        }
        return *v, nil
 }
+
+func parsePath(key string) []string { return strings.Split(key, ".") }
+
+func tableLookup(m Map, simple string) (Map, bool) {
+       v, ok := m[simple]
+       if !ok {
+               return nil, false
+       }
+       if vv, ok := v.(map[string]interface{}); ok {
+               return vv, true
+       }
+       if vv, ok := v.(Map); ok {
+               return vv, true
+       }
+       return nil, false
+}
+
+// GetPathMap key.subkey
+func (m Map) GetPathMap(s string) (Map, bool) {
+       current := m
+       for _, n := range parsePath(s) {
+               subkey, ok := tableLookup(current, n)
+               if !ok {
+                       return nil, false
+               }
+               current = subkey
+       }
+       return current, true
+}
diff --git a/pkg/art/atr.go b/pkg/art/atr.go
index 61274f39..2e41ef25 100644
--- a/pkg/art/atr.go
+++ b/pkg/art/atr.go
@@ -1,6 +1,9 @@
 package art
 
-import "github.com/fatih/color"
+import (
+       _ "embed"
+       "github.com/fatih/color"
+)
 
 //go:embed dubbo-ascii.txt
 var dubboASCIIArt string
@@ -9,6 +12,6 @@ func DubboArt() string {
        return dubboASCIIArt
 }
 
-func DubboColoredArt() {
+func DubboColoredArt() string {
        return color.New(color.FgHiCyan).Add(color.Bold).Sprint(dubboASCIIArt)
 }

Reply via email to