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 21d090cd [operator] A
21d090cd is described below
commit 21d090cda069b0337de3b290d7389585d7ceca24
Author: mfordjody <[email protected]>
AuthorDate: Tue Dec 17 12:10:24 2024 +0800
[operator] A
---
operator/pkg/schema/schema.go | 107 ++++++++++++++++++++++++++++++++++++++++--
pkg/schema/schema.go | 73 ----------------------------
2 files changed, 104 insertions(+), 76 deletions(-)
diff --git a/operator/pkg/schema/schema.go b/operator/pkg/schema/schema.go
index 67a354db..e03e0cc1 100644
--- a/operator/pkg/schema/schema.go
+++ b/operator/pkg/schema/schema.go
@@ -1,11 +1,112 @@
package schema
+import (
+ "fmt"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/config"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+)
+
type schemaImpl struct {
+ gvk config.GroupVersionKind
+ plural string
+ clusterScoped bool
+ goPkg string
+ proto string
+ versionAliases []string
}
-type Builder struct {
+func (s *schemaImpl) GroupVersionAliasKinds() []config.GroupVersionKind {
+ gvks := make([]config.GroupVersionKind, len(s.versionAliases))
+ for i, va := range s.versionAliases {
+ gvks[i] = s.gvk
+ gvks[i].Version = va
+ }
+ gvks = append(gvks, s.GroupVersionKind())
+ return gvks
+}
+
+func (s *schemaImpl) IsClusterScoped() bool {
+ //TODO implement me
+ panic("implement me")
}
func (s *schemaImpl) Kind() string {
- return ""
-}
\ No newline at end of file
+ return s.gvk.Kind
+}
+
+func (s *schemaImpl) Group() string {
+ return s.gvk.Group
+}
+
+func (s *schemaImpl) Version() string {
+ return s.gvk.Version
+}
+
+func (s *schemaImpl) Plural() string {
+ return s.plural
+}
+
+func (s *schemaImpl) GroupVersionKind() config.GroupVersionKind {
+ return s.gvk
+}
+
+func (s *schemaImpl) InClusterScoped() bool {
+ return s.clusterScoped
+}
+
+func (s *schemaImpl) String() string {
+ return fmt.Sprintf("[Schema](%s, %q, %s)", s.Kind(), s.goPkg, s.proto)
+}
+
+func (s *schemaImpl) GroupVersionResource() schema.GroupVersionResource {
+ return schema.GroupVersionResource{
+ Group: s.Group(),
+ Version: s.Version(),
+ Resource: s.Plural(),
+ }
+}
+
+func (s *schemaImpl) Validate() (err error) {
+ return
+}
+
+type Builder struct {
+ Plural string
+ ClusterScoped bool
+ ProtoPkg string
+ Proto string
+ Kind string
+ Group string
+ Version string
+}
+
+func (b Builder) BuildNoValidate() Schema {
+ return &schemaImpl{
+ gvk: config.GroupVersionKind{
+ Group: b.Group,
+ Version: b.Version,
+ Kind: b.Kind,
+ },
+ plural: b.Plural,
+ clusterScoped: b.ClusterScoped,
+ goPkg: b.ProtoPkg,
+ proto: b.Proto,
+ }
+}
+
+func (b Builder) Build() (Schema, error) {
+ s := b.BuildNoValidate()
+ if err := s.Validate(); err != nil {
+ return nil, err
+ }
+ return s, nil
+}
+
+type Schema interface {
+ fmt.Stringer
+ GroupVersionResource() schema.GroupVersionResource
+ GroupVersionKind() config.GroupVersionKind
+ GroupVersionAliasKinds() []config.GroupVersionKind
+ Validate() error
+ IsClusterScoped() bool
+}
diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go
deleted file mode 100644
index bc479e38..00000000
--- a/pkg/schema/schema.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package schema
-
-import (
- "fmt"
- "github.com/apache/dubbo-kubernetes/operator/pkg/config"
- "k8s.io/apimachinery/pkg/runtime/schema"
-)
-
-type schemaImpl struct {
- gvk config.GroupVersionKind
- plural string
- clusterScoped bool
- goPkg string
- proto string
-}
-
-func (s *schemaImpl) Kind() string {
- return s.gvk.Kind
-}
-
-func (s *schemaImpl) Group() string {
- return s.gvk.Group
-}
-
-func (s *schemaImpl) Version() string {
- return s.gvk.Version
-}
-
-func (s *schemaImpl) Plural() string {
- return s.plural
-}
-
-func (s *schemaImpl) GroupVersionKind() config.GroupVersionKind {
- return s.gvk
-}
-
-func (s *schemaImpl) InClusterScoped() bool {
- return s.clusterScoped
-}
-
-func (s *schemaImpl) String() string {
- return fmt.Sprintf("[Schema](%s, %q, %s)", s.Kind(), s.goPkg, s.proto)
-}
-
-func (s *schemaImpl) GroupVersionResource() schema.GroupVersionResource {
- return schema.GroupVersionResource{
- Group: s.Group(),
- Version: s.Version(),
- Resource: s.Plural(),
- }
-}
-
-func (s *schemaImpl) Validate() (err error) {
- return
-}
-
-type Builder struct {
-}
-
-func (b Builder) BuildNoValidate() Schema {
-}
-
-func (b Builder) Build() (Schema, error) {
-}
-
-type Schema interface {
- fmt.Stringer
- GroupVersionResource() schema.GroupVersionResource
- GroupVersionKind() schema.GroupVersionKind
- GroupVersionAliasKinds() []config.GroupVersionKind
- Validate() error
- IsClusterScoped() bool
-}