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 89776428 [operator]Encapsulating map and new component resources (#512)
89776428 is described below
commit 8977642833cc06e36d53fdb7672f4efbb67c85f4
Author: mfordjody <[email protected]>
AuthorDate: Sat Nov 30 11:39:37 2024 +0800
[operator]Encapsulating map and new component resources (#512)
---
manifests/{embedded.go => manifest.go} | 0
operator/manifest/manifest.go | 16 +++++++++++
operator/pkg/apis/types.go | 15 ++++++----
operator/pkg/comp/comp.go | 51 ++++++++++++++++++++++++++++++++++
operator/pkg/values/map.go | 43 ++++++++++++++++++++++++++++
5 files changed, 119 insertions(+), 6 deletions(-)
diff --git a/manifests/embedded.go b/manifests/manifest.go
similarity index 100%
rename from manifests/embedded.go
rename to manifests/manifest.go
diff --git a/operator/manifest/manifest.go b/operator/manifest/manifest.go
new file mode 100644
index 00000000..eb1ef6a0
--- /dev/null
+++ b/operator/manifest/manifest.go
@@ -0,0 +1,16 @@
+package manifest
+
+import (
+ "github.com/apache/dubbo-kubernetes/operator/pkg/comp"
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+)
+
+type Manifest struct {
+ *unstructured.Unstructured
+ Content string
+}
+
+type ManifestSet struct {
+ Components comp.Name
+ Manifests []Manifest
+}
diff --git a/operator/pkg/apis/types.go b/operator/pkg/apis/types.go
index 29f4853a..bee0963e 100644
--- a/operator/pkg/apis/types.go
+++ b/operator/pkg/apis/types.go
@@ -21,7 +21,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
-//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubetype-gen
// +kubetype-gen:groupVersion=install.dubbo.io/v1alpha1
@@ -37,13 +36,12 @@ type DubboOperator struct {
type DubboOperatorSpec struct {
Profile string `json:"profile,omitempty"`
Namespace string `json:"namespace,omitempty"`
- Revision string `json:"revision,omitempty"`
- Components *DubboComponentSpec `json:"components,omitempty"`
- Values json.RawMessage `json:"values,omitempty"`
- UnvalidatedValues any `json:"unvalidatedValues,omitempty"`
+ Revision string `json:"revision,omitempty"`
+ Components *DubboCompSpec `json:"components,omitempty"`
+ Values json.RawMessage `json:"values,omitempty"`
}
-type DubboComponentSpec struct {
+type DubboCompSpec struct {
Base *BaseComponentSpec `json:"base,omitempty"`
}
@@ -56,6 +54,11 @@ type ComponentSpec struct {
Raw map[string]any `json:"-"`
}
+type MetadataCompSpec struct {
+ ComponentSpec
+ Name string `json:"name,omitempty"`
+ Label map[string]string `json:"label,omitempty"`
+}
type BoolValue struct {
bool
diff --git a/operator/pkg/comp/comp.go b/operator/pkg/comp/comp.go
new file mode 100644
index 00000000..c9498197
--- /dev/null
+++ b/operator/pkg/comp/comp.go
@@ -0,0 +1,51 @@
+package comp
+
+import (
+ "github.com/apache/dubbo-kubernetes/operator/pkg/apis"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/values"
+)
+
+type Name string
+
+const (
+ BaseComponentName Name = "Base"
+)
+
+type Comp struct {
+ UserFacingName Name
+ SpecName string
+ Default bool
+ HelmSubDir string
+ HelmTreeRoot string
+}
+
+var AllComps = []Comp{
+ {
+ UserFacingName: BaseComponentName,
+ SpecName: "base",
+ Default: true,
+ HelmSubDir: "base",
+ HelmTreeRoot: "global",
+ },
+}
+
+var (
+ userFacingCompNames = map[Name]string{
+ BaseComponentName: "Dubbo Core",
+ }
+ Icons = map[Name]string{
+ BaseComponentName: "🚄",
+ }
+)
+
+func UserFacingCompName(name Name) string {
+ s, ok := userFacingCompNames[name]
+ if !ok {
+ return "Unknown"
+ }
+ return s
+}
+
+func (c Comp) Get(merged values.Map) ([]apis.MetadataCompSpec, error) {
+ return nil, nil
+}
diff --git a/operator/pkg/values/map.go b/operator/pkg/values/map.go
index e3615272..ec33acdc 100644
--- a/operator/pkg/values/map.go
+++ b/operator/pkg/values/map.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/dubbo-kubernetes/pkg/pointer"
+ "path/filepath"
"sigs.k8s.io/yaml"
"strings"
)
@@ -90,3 +91,45 @@ func (m Map) GetPathMap(s string) (Map, bool) {
}
return current, true
}
+
+func splitEscaped(s string, r rune) []string {
+ var prev rune
+ if len(s) == 0 {
+ return []string{}
+ }
+ prevIndex := 0
+ var out []string
+ for i, c := range s {
+ if c == r && (i == 0 || i > 0 && prev != '\\') {
+ out = append(out, s[prevIndex:i])
+ prevIndex = i + 1
+ }
+ prev = c
+ }
+ out = append(out, s[prevIndex:])
+ return out
+}
+
+func splitPath(path string) []string {
+ path = filepath.Clean(path)
+ path = strings.TrimPrefix(path, ".")
+ path = strings.TrimSuffix(path, ".")
+ pv := splitEscaped(path, '.')
+ var r []string
+ for _, str := range pv {
+ if str != "" {
+ str = strings.ReplaceAll(str, "\\.", ".")
+ nBracket := strings.IndexRune(str, '[')
+ if nBracket > 0 {
+ r = append(r, str[:nBracket], str[nBracket:])
+ } else {
+ r = append(r, str)
+ }
+ }
+ }
+ return r
+}
+
+func GetPathHelper[T any](m Map, name string) T {
+ return nil
+}