Skip to content

Commit

Permalink
[operator] Wrapping generic maps for helm rendering (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfordjody authored Nov 30, 2024
1 parent 1695230 commit 0800e6e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
2 changes: 1 addition & 1 deletion operator/cmd/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
23 changes: 7 additions & 16 deletions operator/pkg/helm/helm.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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{
Expand Down Expand Up @@ -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
}
}
30 changes: 30 additions & 0 deletions operator/pkg/values/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/apache/dubbo-kubernetes/pkg/pointer"
"sigs.k8s.io/yaml"
"strings"
)

type Map map[string]any
Expand Down Expand Up @@ -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
}
7 changes: 5 additions & 2 deletions pkg/art/atr.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +12,6 @@ func DubboArt() string {
return dubboASCIIArt
}

func DubboColoredArt() {
func DubboColoredArt() string {
return color.New(color.FgHiCyan).Add(color.Bold).Sprint(dubboASCIIArt)
}

0 comments on commit 0800e6e

Please sign in to comment.