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 18353824 [operator] replenish schemacollection
18353824 is described below
commit 183538241ad5cfe5e6a0d8d49b2d77f12d0fd144
Author: mfordjody <[email protected]>
AuthorDate: Wed Dec 18 10:45:06 2024 +0800
[operator] replenish schemacollection
---
pkg/kube/collection/schemas.go | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/pkg/kube/collection/schemas.go b/pkg/kube/collection/schemas.go
index 8b4f72ba..b18f2b57 100644
--- a/pkg/kube/collection/schemas.go
+++ b/pkg/kube/collection/schemas.go
@@ -11,6 +11,17 @@ type Schemas struct {
byAddOrder []schema.Schema
}
+func (s Schemas) FindByGroupVersionAliasesKind(gvk config.GroupVersionKind)
(schema.Schema, bool) {
+ for _, rs := range s.byAddOrder {
+ for _, va := range rs.GroupVersionAliasKinds() {
+ if va == gvk {
+ return rs, true
+ }
+ }
+ }
+ return nil, false
+}
+
type SchemasBuilder struct {
schemas Schemas
}
@@ -22,6 +33,12 @@ func NewSchemasBuilder() *SchemasBuilder {
return &SchemasBuilder{schemas: s}
}
+func (b *SchemasBuilder) Build() Schemas {
+ s := b.schemas
+ b.schemas = Schemas{}
+ return s
+}
+
func (b *SchemasBuilder) Add(s schema.Schema) error {
if _, found := b.schemas.byCollection[s.GroupVersionKind()]; found {
return fmt.Errorf("collection already exists: %v",
s.GroupVersionKind())