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 2ee7760d [operator] Supplementing generic map logic and changing 
project directory names
2ee7760d is described below

commit 2ee7760d1f2281a9effa327e92718341352acea9
Author: mfordjody <[email protected]>
AuthorDate: Fri Dec 13 18:58:14 2024 +0800

    [operator] Supplementing generic map logic and changing project directory 
names
---
 operator/pkg/helm/helm.go            |  6 +++---
 operator/pkg/{yml => parts}/parts.go |  2 +-
 operator/pkg/render/manifest.go      | 13 ++++++++++++-
 operator/pkg/values/map.go           | 18 ++++++++++++++++++
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/operator/pkg/helm/helm.go b/operator/pkg/helm/helm.go
index 14f8fed4..51226082 100644
--- a/operator/pkg/helm/helm.go
+++ b/operator/pkg/helm/helm.go
@@ -3,9 +3,9 @@ package helm
 import (
        "fmt"
        "github.com/apache/dubbo-kubernetes/operator/pkg/manifest"
+       "github.com/apache/dubbo-kubernetes/operator/pkg/parts"
        "github.com/apache/dubbo-kubernetes/operator/pkg/util"
        "github.com/apache/dubbo-kubernetes/operator/pkg/values"
-       "github.com/apache/dubbo-kubernetes/operator/pkg/yml"
        "github.com/apache/dubbo-kubernetes/pkg/util/slices"
        "helm.sh/helm/v3/pkg/chart"
        "helm.sh/helm/v3/pkg/chart/loader"
@@ -54,13 +54,13 @@ func readerChart(namespace string, chrtVals values.Map, 
chrt *chart.Chart) ([]st
        sort.Strings(keys)
        res := make([]string, 0, len(keys))
        for _, k := range keys {
-               res = append(res, yml.SplitString(files[k])...)
+               res = append(res, parts.SplitString(files[k])...)
        }
        slices.SortBy(crdFiles, func(a chart.CRD) string {
                return a.Name
        })
        for _, crd := range crdFiles {
-               res = append(res, yml.SplitString(string(crd.File.Data))...)
+               res = append(res, parts.SplitString(string(crd.File.Data))...)
        }
        return res, warnings, nil
 }
diff --git a/operator/pkg/yml/parts.go b/operator/pkg/parts/parts.go
similarity index 97%
rename from operator/pkg/yml/parts.go
rename to operator/pkg/parts/parts.go
index d3545fc4..a7df3018 100644
--- a/operator/pkg/yml/parts.go
+++ b/operator/pkg/parts/parts.go
@@ -1,4 +1,4 @@
-package yml
+package parts
 
 import (
        "bufio"
diff --git a/operator/pkg/render/manifest.go b/operator/pkg/render/manifest.go
index 3f49e668..93d11f05 100644
--- a/operator/pkg/render/manifest.go
+++ b/operator/pkg/render/manifest.go
@@ -35,6 +35,16 @@ func MergeInputs(filenames []string, flags []string) 
([]values.Map, error) {
                } else {
                        b, err = os.ReadFile(strings.TrimSpace(fn))
                }
+               if err := checkDops(string(b)); err != nil {
+                       return nil, fmt.Errorf("checkDops err:%v", err)
+               }
+               m, err := values.MapFromYAML(b)
+               if err != nil {
+                       return nil, fmt.Errorf("yaml Unmarshal err:%v", err)
+               }
+               if m["spec"] == nil {
+                       delete(m, "spec")
+               }
        }
        return nil, nil
 }
@@ -64,6 +74,7 @@ func GenerateManifest(files []string, setFlags []string, 
logger clog.Logger) ([]
                        return nil, nil, fmt.Errorf("get component %v: %v", 
comp.UserFacingName, err)
                }
                for _, spec := range specs {
+                       compVals := applyComponentValuesToHelmValues(comp, 
spec, merged)
                }
        }
        return nil, nil, nil
@@ -71,7 +82,7 @@ func GenerateManifest(files []string, setFlags []string, 
logger clog.Logger) ([]
 
 func validateDubboOperator(dop values.Map, logger clog.Logger) error {
        warnings, errs := validation.ParseAndValidateDubboOperator(dop)
-       if err := errs.ToError(); err != nil {
+       if err := errs.ToErrors(); err != nil {
                return err
        }
        if logger != nil {
diff --git a/operator/pkg/values/map.go b/operator/pkg/values/map.go
index 4232ff99..ab961509 100644
--- a/operator/pkg/values/map.go
+++ b/operator/pkg/values/map.go
@@ -237,3 +237,21 @@ func extractKeyValue(seg string) (string, string, bool) {
        sanitized := seg[1 : len(seg)-1]
        return strings.Cut(sanitized, ":")
 }
+
+func (m Map) MergeFrom(other Map) {
+       for k, v := range other {
+               if vm, ok := v.(Map); ok {
+                       v = map[string]any(vm)
+               }
+               if v, ok := v.(map[string]any); ok {
+                       if bv, ok := m[k]; ok {
+
+                               if bv, ok := bv.(map[string]any); ok {
+                                       Map(bv).MergeFrom(v)
+                                       continue
+                               }
+                       }
+               }
+               m[k] = v
+       }
+}

Reply via email to