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 8022621c Update generated files and comments serviceentry (#859)
8022621c is described below
commit 8022621c5da00f7ec129b128ef0d96f21728b518
Author: mfordjody <[email protected]>
AuthorDate: Tue Feb 3 12:03:05 2026 +0800
Update generated files and comments serviceentry (#859)
---
dubbod/discovery/pkg/bootstrap/server.go | 16 +-
dubbod/discovery/pkg/config/kube/crd/conversion.go | 13 +-
.../discovery/pkg/config/kube/crdclient/client.go | 5 +-
.../pkg/config/kube/crdclient/types.gen.go | 90 ++---
dubbod/discovery/pkg/model/context.go | 6 +-
dubbod/discovery/pkg/model/endpointshards.go | 8 +-
dubbod/discovery/pkg/model/push_context.go | 17 +-
dubbod/discovery/pkg/networking/grpcgen/lds.go | 25 +-
dubbod/discovery/pkg/xds/discovery.go | 13 +-
dubbod/discovery/pkg/xds/eds.go | 33 +-
.../pkg/xds/endpoints/endpoint_builder.go | 7 +-
pkg/config/schema/codegen/collections.go | 12 +-
pkg/config/schema/codegen/common.go | 4 +-
.../schema/codegen/templates/clients.go.tmpl | 4 +-
.../schema/codegen/templates/crdclient.go.tmpl | 6 +-
pkg/config/schema/codegen/templates/types.go.tmpl | 4 +-
pkg/config/schema/collection/schema.go | 366 ++-------------------
pkg/config/schema/collection/schemas.go | 33 +-
pkg/config/schema/collections/collections.gen.go | 26 +-
pkg/config/schema/gvk/resources.gen.go | 9 -
pkg/config/schema/gvr/resources.gen.go | 9 -
pkg/config/schema/kind/kind.go | 16 -
pkg/config/schema/kubeclient/resources.gen.go | 22 +-
pkg/config/schema/kubetypes/resources.gen.go | 8 +
pkg/config/schema/metadata.yaml | 8 +-
pkg/config/schema/resource/schema.go | 69 ++--
pkg/env/dubbo.go | 4 +-
pkg/webhooks/server/server.go | 3 +-
28 files changed, 257 insertions(+), 579 deletions(-)
diff --git a/dubbod/discovery/pkg/bootstrap/server.go
b/dubbod/discovery/pkg/bootstrap/server.go
index a19b72da..59923e34 100644
--- a/dubbod/discovery/pkg/bootstrap/server.go
+++ b/dubbod/discovery/pkg/bootstrap/server.go
@@ -445,7 +445,7 @@ func (s *Server) initRegistryEventHandlers() {
log.Debugf("configController is available, registering event handlers")
configHandler := func(prev config.Config, curr config.Config, event
model.Event) {
- log.Infof("configHandler: received event %s for config %v
(prev.Name=%s, curr.Name=%s, prev.Namespace=%s, curr.Namespace=%s)",
+ log.Infof("received event %s for config %v (prev.Name=%s,
curr.Name=%s, prev.Namespace=%s, curr.Namespace=%s)",
event, curr.GroupVersionKind, prev.Name, curr.Name,
prev.Namespace, curr.Namespace)
cfg := curr
@@ -461,32 +461,32 @@ func (s *Server) initRegistryEventHandlers() {
schema, found =
collections.DubboGatewayAPI().FindByGroupVersionKind(cfg.GroupVersionKind)
}
if !found {
- log.Warnf("configHandler: schema not found for %v,
skipping", cfg.GroupVersionKind)
+ log.Warnf("schema not found for %v, skipping",
cfg.GroupVersionKind)
return
}
// Map GVK to kind.Kind using schema identifier
// This matches Dubbo's approach of using gvk.MustToKind, but
we use schema.Identifier() instead
schemaID := schema.Identifier()
- log.Infof("configHandler: processing config change, schema
identifier=%s, GVK=%v, name=%s/%s, event=%s",
+ log.Infof("processing config change, schema identifier=%s,
GVK=%v, name=%s/%s, event=%s",
schemaID, cfg.GroupVersionKind, cfg.Namespace,
cfg.Name, event)
var configKind kind.Kind
switch schemaID {
case "DestinationRule":
configKind = kind.DestinationRule
- case "virtualService", "VirtualService":
+ case "VirtualService":
configKind = kind.VirtualService
case "PeerAuthentication":
configKind = kind.PeerAuthentication
case "GatewayClass":
configKind = kind.GatewayClass
- case "Gateway":
- configKind = kind.Gateway
+ case "KubernetesGateway":
+ configKind = kind.KubernetesGateway
case "HTTPRoute":
configKind = kind.HTTPRoute
default:
- log.Debugf("configHandler: unknown schema identifier %s
for %v, skipping", schemaID, cfg.GroupVersionKind)
+ log.Debugf("unknown schema identifier %s for %v,
skipping", schemaID, cfg.GroupVersionKind)
return
}
@@ -497,7 +497,7 @@ func (s *Server) initRegistryEventHandlers() {
}
// Log the config change
- log.Infof("configHandler: %s event for %s/%s/%s", event,
configKey.Kind, configKey.Namespace, configKey.Name)
+ log.Infof("%s event for %s/%s/%s", event, configKey.Kind,
configKey.Namespace, configKey.Name)
// Some configs
(DestinationRule/VirtualService/PeerAuthentication/HTTPRoute) require Full push
to ensure
// PushContext is re-initialized and configuration is reloaded.
diff --git a/dubbod/discovery/pkg/config/kube/crd/conversion.go
b/dubbod/discovery/pkg/config/kube/crd/conversion.go
index 6a18bb4f..749b5f90 100644
--- a/dubbod/discovery/pkg/config/kube/crd/conversion.go
+++ b/dubbod/discovery/pkg/config/kube/crd/conversion.go
@@ -24,7 +24,8 @@ import (
"reflect"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
+
kubeyaml "k8s.io/apimachinery/pkg/util/yaml"
dubbolog "github.com/apache/dubbo-kubernetes/pkg/log"
@@ -32,7 +33,7 @@ import (
var log = dubbolog.RegisterScope("crdconversion", "crd conversion debugging")
-type ConversionFunc = func(s collection.Schema, js string) (config.Spec, error)
+type ConversionFunc = func(s resource.Schema, js string) (config.Spec, error)
func parseInputsImpl(inputs string, withValidate bool) ([]config.Config,
[]DubboKind, error) {
var varr []config.Config
@@ -84,7 +85,7 @@ func ParseInputs(inputs string) ([]config.Config,
[]DubboKind, error) {
return parseInputsImpl(inputs, true)
}
-func FromJSON(s collection.Schema, js string) (config.Spec, error) {
+func FromJSON(s resource.Schema, js string) (config.Spec, error) {
c, err := s.NewInstance()
if err != nil {
return nil, err
@@ -95,11 +96,11 @@ func FromJSON(s collection.Schema, js string) (config.Spec,
error) {
return c, nil
}
-func ConvertObject(schema collection.Schema, object DubboObject, domain
string) (*config.Config, error) {
+func ConvertObject(schema resource.Schema, object DubboObject, domain string)
(*config.Config, error) {
return ConvertObjectInternal(schema, object, domain, FromJSON)
}
-func StatusJSONFromMap(schema collection.Schema, jsonMap *json.RawMessage)
(config.Status, error) {
+func StatusJSONFromMap(schema resource.Schema, jsonMap *json.RawMessage)
(config.Status, error) {
if jsonMap == nil {
return nil, nil
}
@@ -118,7 +119,7 @@ func StatusJSONFromMap(schema collection.Schema, jsonMap
*json.RawMessage) (conf
return status, nil
}
-func ConvertObjectInternal(schema collection.Schema, object DubboObject,
domain string, convert ConversionFunc) (*config.Config, error) {
+func ConvertObjectInternal(schema resource.Schema, object DubboObject, domain
string, convert ConversionFunc) (*config.Config, error) {
js, err := json.Marshal(object.GetSpec())
if err != nil {
return nil, err
diff --git a/dubbod/discovery/pkg/config/kube/crdclient/client.go
b/dubbod/discovery/pkg/config/kube/crdclient/client.go
index 89cb135e..9904a4a6 100644
--- a/dubbod/discovery/pkg/config/kube/crdclient/client.go
+++ b/dubbod/discovery/pkg/config/kube/crdclient/client.go
@@ -19,6 +19,7 @@ package crdclient
import (
"encoding/json"
"fmt"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
"sync"
"time"
@@ -47,7 +48,7 @@ type Client struct {
kinds map[config.GroupVersionKind]nsStore
kindsMu sync.RWMutex
domainSuffix string
- schemasByCRDName map[string]collection.Schema
+ schemasByCRDName map[string]resource.Schema
schemas collection.Schemas
client kube.Client
filtersByGVK map[config.GroupVersionKind]kubetypes.Filter
@@ -70,7 +71,7 @@ type Option struct {
}
func NewForSchemas(client kube.Client, opts Option, schemas
collection.Schemas) *Client {
- schemasByCRDName := map[string]collection.Schema{}
+ schemasByCRDName := map[string]resource.Schema{}
for _, s := range schemas.All() {
// From the spec: "Its name MUST be in the format
<.spec.name>.<.spec.group>."
name := fmt.Sprintf("%s.%s", s.Plural(), s.Group())
diff --git a/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
b/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
index 564443e4..3805b77b 100755
--- a/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
+++ b/dubbod/discovery/pkg/config/kube/crdclient/types.gen.go
@@ -17,13 +17,23 @@ import (
githubcomapachedubbokubernetesapimetav1alpha1
"github.com/apache/dubbo-kubernetes/api/meta/v1alpha1"
githubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
githubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/api/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
+ k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
+ k8sioapiappsv1 "k8s.io/api/apps/v1"
+ k8sioapiautoscalingv2 "k8s.io/api/autoscaling/v2"
+ k8sioapicoordinationv1 "k8s.io/api/coordination/v1"
+ k8sioapicorev1 "k8s.io/api/core/v1"
+ k8sioapidiscoveryv1 "k8s.io/api/discovery/v1"
+ k8sioapipolicyv1 "k8s.io/api/policy/v1"
+ k8sioapiextensionsapiserverpkgapisapiextensionsv1
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
sigsk8siogatewayapiapisv1 "sigs.k8s.io/gateway-api/apis/v1"
)
func create(c kube.Client, cfg config.Config, objMeta metav1.ObjectMeta)
(metav1.Object, error) {
switch cfg.GroupVersionKind {
case gvk.DestinationRule:
- return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).Create(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
+ return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).Create(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule)),
}, metav1.CreateOptions{})
@@ -43,12 +53,12 @@ func create(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
Spec:
*(cfg.Spec.(*sigsk8siogatewayapiapisv1.GatewaySpec)),
}, metav1.CreateOptions{})
case gvk.PeerAuthentication:
- return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Create(context.TODO(),
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
+ return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Create(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication)),
}, metav1.CreateOptions{})
case gvk.VirtualService:
- return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).Create(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
+ return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).Create(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService)),
}, metav1.CreateOptions{})
@@ -60,7 +70,7 @@ func create(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
func update(c kube.Client, cfg config.Config, objMeta metav1.ObjectMeta)
(metav1.Object, error) {
switch cfg.GroupVersionKind {
case gvk.DestinationRule:
- return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).Update(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
+ return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).Update(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule)),
}, metav1.UpdateOptions{})
@@ -80,12 +90,12 @@ func update(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
Spec:
*(cfg.Spec.(*sigsk8siogatewayapiapisv1.GatewaySpec)),
}, metav1.UpdateOptions{})
case gvk.PeerAuthentication:
- return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Update(context.TODO(),
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
+ return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).Update(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication)),
}, metav1.UpdateOptions{})
case gvk.VirtualService:
- return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).Update(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
+ return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).Update(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
ObjectMeta: objMeta,
Spec:
*(cfg.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService)),
}, metav1.UpdateOptions{})
@@ -97,7 +107,7 @@ func update(c kube.Client, cfg config.Config, objMeta
metav1.ObjectMeta) (metav1
func updateStatus(c kube.Client, cfg config.Config, objMeta metav1.ObjectMeta)
(metav1.Object, error) {
switch cfg.GroupVersionKind {
case gvk.DestinationRule:
- return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).UpdateStatus(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
+ return
c.Dubbo().NetworkingV1alpha3().DestinationRules(cfg.Namespace).UpdateStatus(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
ObjectMeta: objMeta,
Status:
*(cfg.Status.(*githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus)),
}, metav1.UpdateOptions{})
@@ -114,15 +124,15 @@ func updateStatus(c kube.Client, cfg config.Config,
objMeta metav1.ObjectMeta) (
case gvk.KubernetesGateway:
return
c.GatewayAPI().GatewayV1().Gateways(cfg.Namespace).UpdateStatus(context.TODO(),
&sigsk8siogatewayapiapisv1.Gateway{
ObjectMeta: objMeta,
- Status:
*(cfg.Status.(*sigsk8siogatewayapiapisv1.HTTPRouteStatus)),
+ Status:
*(cfg.Status.(*sigsk8siogatewayapiapisv1.GatewayStatus)),
}, metav1.UpdateOptions{})
case gvk.PeerAuthentication:
- return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).UpdateStatus(context.TODO(),
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
+ return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(cfg.Namespace).UpdateStatus(context.TODO(),
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: objMeta,
Status:
*(cfg.Status.(*githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus)),
}, metav1.UpdateOptions{})
case gvk.VirtualService:
- return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).UpdateStatus(context.TODO(),
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
+ return
c.Dubbo().NetworkingV1alpha3().VirtualServices(cfg.Namespace).UpdateStatus(context.TODO(),
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
ObjectMeta: objMeta,
Status:
*(cfg.Status.(*githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus)),
}, metav1.UpdateOptions{})
@@ -137,11 +147,11 @@ func patch(c kube.Client, orig config.Config, origMeta
metav1.ObjectMeta, mod co
}
switch orig.GroupVersionKind {
case gvk.DestinationRule:
- oldRes :=
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
+ oldRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
ObjectMeta: origMeta,
Spec:
*(orig.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule)),
}
- modRes :=
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
+ modRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{
ObjectMeta: modMeta,
Spec:
*(mod.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule)),
}
@@ -197,11 +207,11 @@ func patch(c kube.Client, orig config.Config, origMeta
metav1.ObjectMeta, mod co
return c.GatewayAPI().GatewayV1().Gateways(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes,
metav1.PatchOptions{FieldManager: "pilot-discovery"})
case gvk.PeerAuthentication:
- oldRes :=
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
+ oldRes :=
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: origMeta,
Spec:
*(orig.Spec.(*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication)),
}
- modRes :=
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
+ modRes :=
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{
ObjectMeta: modMeta,
Spec:
*(mod.Spec.(*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication)),
}
@@ -212,11 +222,11 @@ func patch(c kube.Client, orig config.Config, origMeta
metav1.ObjectMeta, mod co
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(orig.Namespace).
Patch(context.TODO(), orig.Name, typ, patchBytes,
metav1.PatchOptions{FieldManager: "pilot-discovery"})
case gvk.VirtualService:
- oldRes :=
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
+ oldRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
ObjectMeta: origMeta,
Spec:
*(orig.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService)),
}
- modRes :=
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
+ modRes :=
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{
ObjectMeta: modMeta,
Spec:
*(mod.Spec.(*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService)),
}
@@ -256,7 +266,7 @@ func delete(c kube.Client, typ config.GroupVersionKind,
name, namespace string,
var translationMap = map[config.GroupVersionKind]func(r runtime.Object)
config.Config{
gvk.ConfigMap: func(r runtime.Object) config.Config {
- obj := r.(*ConfigMap)
+ obj := r.(*k8sioapicorev1.ConfigMap)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.ConfigMap,
@@ -274,7 +284,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.CustomResourceDefinition: func(r runtime.Object) config.Config {
- obj := r.(*CustomResourceDefinition)
+ obj :=
r.(*k8sioapiextensionsapiserverpkgapisapiextensionsv1.CustomResourceDefinition)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.CustomResourceDefinition,
@@ -292,7 +302,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.DaemonSet: func(r runtime.Object) config.Config {
- obj := r.(*DaemonSet)
+ obj := r.(*k8sioapiappsv1.DaemonSet)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.DaemonSet,
@@ -310,7 +320,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Deployment: func(r runtime.Object) config.Config {
- obj := r.(*Deployment)
+ obj := r.(*k8sioapiappsv1.Deployment)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Deployment,
@@ -328,7 +338,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.DestinationRule: func(r runtime.Object) config.Config {
- obj := r.(*DestinationRule)
+ obj :=
r.(*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.DestinationRule,
@@ -347,7 +357,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.EndpointSlice: func(r runtime.Object) config.Config {
- obj := r.(*EndpointSlice)
+ obj := r.(*k8sioapidiscoveryv1.EndpointSlice)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.EndpointSlice,
@@ -365,7 +375,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Endpoints: func(r runtime.Object) config.Config {
- obj := r.(*Endpoints)
+ obj := r.(*k8sioapicorev1.Endpoints)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Endpoints,
@@ -383,7 +393,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.GatewayClass: func(r runtime.Object) config.Config {
- obj := r.(*GatewayClass)
+ obj := r.(*sigsk8siogatewayapiapisv1.GatewayClass)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.GatewayClass,
@@ -402,7 +412,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.HTTPRoute: func(r runtime.Object) config.Config {
- obj := r.(*HTTPRoute)
+ obj := r.(*sigsk8siogatewayapiapisv1.HTTPRoute)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.HTTPRoute,
@@ -421,7 +431,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.HorizontalPodAutoscaler: func(r runtime.Object) config.Config {
- obj := r.(*HorizontalPodAutoscaler)
+ obj := r.(*k8sioapiautoscalingv2.HorizontalPodAutoscaler)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.HorizontalPodAutoscaler,
@@ -440,7 +450,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.KubernetesGateway: func(r runtime.Object) config.Config {
- obj := r.(*Gateway)
+ obj := r.(*sigsk8siogatewayapiapisv1.Gateway)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.KubernetesGateway,
@@ -459,7 +469,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Lease: func(r runtime.Object) config.Config {
- obj := r.(*Lease)
+ obj := r.(*k8sioapicoordinationv1.Lease)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Lease,
@@ -477,7 +487,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.MutatingWebhookConfiguration: func(r runtime.Object) config.Config {
- obj := r.(*MutatingWebhookConfiguration)
+ obj :=
r.(*k8sioapiadmissionregistrationv1.MutatingWebhookConfiguration)
return config.Config{
Meta: config.Meta{
GroupVersionKind:
gvk.MutatingWebhookConfiguration,
@@ -495,7 +505,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Namespace: func(r runtime.Object) config.Config {
- obj := r.(*Namespace)
+ obj := r.(*k8sioapicorev1.Namespace)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Namespace,
@@ -513,7 +523,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Node: func(r runtime.Object) config.Config {
- obj := r.(*Node)
+ obj := r.(*k8sioapicorev1.Node)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Node,
@@ -531,7 +541,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.PeerAuthentication: func(r runtime.Object) config.Config {
- obj := r.(*PeerAuthentication)
+ obj :=
r.(*apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.PeerAuthentication,
@@ -550,7 +560,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Pod: func(r runtime.Object) config.Config {
- obj := r.(*Pod)
+ obj := r.(*k8sioapicorev1.Pod)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Pod,
@@ -568,7 +578,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.PodDisruptionBudget: func(r runtime.Object) config.Config {
- obj := r.(*PodDisruptionBudget)
+ obj := r.(*k8sioapipolicyv1.PodDisruptionBudget)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.PodDisruptionBudget,
@@ -587,7 +597,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Secret: func(r runtime.Object) config.Config {
- obj := r.(*Secret)
+ obj := r.(*k8sioapicorev1.Secret)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Secret,
@@ -605,7 +615,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.Service: func(r runtime.Object) config.Config {
- obj := r.(*Service)
+ obj := r.(*k8sioapicorev1.Service)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.Service,
@@ -624,7 +634,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.ServiceAccount: func(r runtime.Object) config.Config {
- obj := r.(*ServiceAccount)
+ obj := r.(*k8sioapicorev1.ServiceAccount)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.ServiceAccount,
@@ -642,7 +652,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.StatefulSet: func(r runtime.Object) config.Config {
- obj := r.(*StatefulSet)
+ obj := r.(*k8sioapiappsv1.StatefulSet)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.StatefulSet,
@@ -660,7 +670,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.ValidatingWebhookConfiguration: func(r runtime.Object)
config.Config {
- obj := r.(*ValidatingWebhookConfiguration)
+ obj :=
r.(*k8sioapiadmissionregistrationv1.ValidatingWebhookConfiguration)
return config.Config{
Meta: config.Meta{
GroupVersionKind:
gvk.ValidatingWebhookConfiguration,
@@ -678,7 +688,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
}
},
gvk.VirtualService: func(r runtime.Object) config.Config {
- obj := r.(*VirtualService)
+ obj :=
r.(*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService)
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.VirtualService,
diff --git a/dubbod/discovery/pkg/model/context.go
b/dubbod/discovery/pkg/model/context.go
index 6dae3eae..abd3ae7f 100644
--- a/dubbod/discovery/pkg/model/context.go
+++ b/dubbod/discovery/pkg/model/context.go
@@ -34,7 +34,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/host"
"github.com/apache/dubbo-kubernetes/pkg/config/mesh"
"github.com/apache/dubbo-kubernetes/pkg/config/mesh/meshwatcher"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
"github.com/apache/dubbo-kubernetes/pkg/maps"
pm "github.com/apache/dubbo-kubernetes/pkg/model"
"github.com/apache/dubbo-kubernetes/pkg/util/protomarshal"
@@ -266,7 +265,10 @@ func (node *Proxy) IsProxylessGrpc() bool {
func (node *Proxy) ShouldUpdateServiceTargets(updates sets.Set[ConfigKey])
bool {
for config := range updates {
- if config.Kind == kind.ServiceEntry || config.Namespace ==
node.Metadata.Namespace {
+ // if config.Kind == kind.ServiceEntry || config.Namespace ==
node.Metadata.Namespace {
+ // return true
+ // }
+ if config.Namespace == node.Metadata.Namespace {
return true
}
}
diff --git a/dubbod/discovery/pkg/model/endpointshards.go
b/dubbod/discovery/pkg/model/endpointshards.go
index 4a908a2b..dfc13dfa 100644
--- a/dubbod/discovery/pkg/model/endpointshards.go
+++ b/dubbod/discovery/pkg/model/endpointshards.go
@@ -19,8 +19,6 @@ package model
import (
"sync"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
-
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/serviceregistry/provider"
"github.com/apache/dubbo-kubernetes/pkg/cluster"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
@@ -276,9 +274,9 @@ func (e *EndpointIndex) deleteServiceInner(shard ShardKey,
serviceName, namespac
func (e *EndpointIndex) clearCacheForService(svc, ns string) {
e.cache.Clear(sets.Set[ConfigKey]{{
- Kind: kind.ServiceEntry,
- Name: svc,
- Namespace: ns,
+ // Kind: kind.ServiceEntry,
+ // Name: svc,
+ // Namespace: ns,
}: {}})
}
diff --git a/dubbod/discovery/pkg/model/push_context.go
b/dubbod/discovery/pkg/model/push_context.go
index 97ab0d8c..5300e4f4 100644
--- a/dubbod/discovery/pkg/model/push_context.go
+++ b/dubbod/discovery/pkg/model/push_context.go
@@ -416,17 +416,17 @@ func resolveServiceAliases(allServices []*Service,
configsUpdated sets.Set[Confi
aliasesForService[concrete] =
append(aliasesForService[concrete], alias)
aliasKey := ConfigKey{
- Kind: kind.ServiceEntry,
- Name: alias.Hostname.String(),
- Namespace: alias.Namespace,
+ // Kind: kind.ServiceEntry,
+ // Name: alias.Hostname.String(),
+ // Namespace: alias.Namespace,
}
if configsUpdated.Contains(aliasKey) {
for _, svc := range allServices {
if svc.Hostname == concrete {
configsUpdated.Insert(ConfigKey{
- Kind: kind.ServiceEntry,
- Name: concrete.String(),
- Namespace:
svc.Attributes.Namespace,
+ // Kind: kind.ServiceEntry,
+ // Name: concrete.String(),
+ // Namespace:
svc.Attributes.Namespace,
})
}
}
@@ -532,8 +532,9 @@ func (ps *PushContext) updateContext(env *Environment,
oldPushContext *PushConte
// 1. ServiceEntry updates in ConfigsUpdated
// 2. Address changes
// 3. Actual service count changes from environment (for Kubernetes
Service changes)
- servicesChanged := pushReq != nil &&
(HasConfigsOfKind(pushReq.ConfigsUpdated, kind.ServiceEntry) ||
- len(pushReq.AddressesUpdated) > 0)
+ // servicesChanged := pushReq != nil &&
(HasConfigsOfKind(pushReq.ConfigsUpdated, kind.ServiceEntry) ||
+ // len(pushReq.AddressesUpdated) > 0)
+ servicesChanged := pushReq != nil && len(pushReq.AddressesUpdated) > 0
// Check if virtualServices have changed base on:
// 1. VirtualService updates in ConfigsUpdated
diff --git a/dubbod/discovery/pkg/networking/grpcgen/lds.go
b/dubbod/discovery/pkg/networking/grpcgen/lds.go
index 85fe0a52..cc8ddce4 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/lds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/lds.go
@@ -60,9 +60,9 @@ func (g *GrpcConfigGenerator) BuildListeners(node
*model.Proxy, push *model.Push
names = append(names, listenerName)
}
}
- log.Debugf("BuildListeners: wildcard request for %s, generating
%d listeners from ServiceTargets: %v", node.ID, len(names), names)
+ log.Debugf("wildcard request for %s, generating %d listeners
from ServiceTargets: %v", node.ID, len(names), names)
} else if len(names) > 0 {
- log.Debugf("BuildListeners: specific request for %s, requested
listeners: %v", node.ID, names)
+ log.Debugf("specific request for %s, requested listeners: %v",
node.ID, names)
}
// If names is provided (non-empty), we MUST only generate those
specific listeners
@@ -84,7 +84,7 @@ func (g *GrpcConfigGenerator) BuildListeners(node
*model.Proxy, push *model.Push
if requestedSet.Contains(r.Name) {
filtered = append(filtered, r)
} else {
- log.Debugf("BuildListeners: filtering out
unrequested listener %s (requested: %v)", r.Name, names)
+ log.Debugf("filtering out unrequested listener
%s (requested: %v)", r.Name, names)
}
}
return filtered
@@ -200,16 +200,13 @@ func buildInboundListeners(node *model.Proxy, push
*model.PushContext, names []s
// Check if this is a Gateway Pod by checking service name
// Gateway Pods typically have "gateway" in their service name
isGatewayPod :=
strings.Contains(strings.ToLower(si.Service.Attributes.Name), "gateway")
- log.Debugf("buildInboundListeners: listener %s, service=%s,
isGatewayPod=%v, node.Type=%v, node.IsRouter()=%v",
+ log.Debugf(" listener %s, service=%s, isGatewayPod=%v,
node.Type=%v, node.IsRouter()=%v",
name, si.Service.Attributes.Name, isGatewayPod,
node.Type, node.IsRouter())
// - DestinationRule with DUBBO_MUTUAL only configures
CLIENT-SIDE (outbound) mTLS
// - PeerAuthentication with STRICT configures SERVER-SIDE
(inbound) mTLS
// Both are REQUIRED for mTLS to work. Server-side mTLS should
ONLY be controlled by PeerAuthentication.
mode := push.InboundMTLSModeForProxy(node, uint32(listenPort))
- if mode == model.MTLSPermissive {
- log.Warnf("buildInboundListeners: PERMISSIVE mTLS is
not supported for proxyless gRPC; defaulting to plaintext on listener %s", name)
- }
// For proxyless gRPC inbound listeners, we need a FilterChain
with HttpConnectionManager filter
// to satisfy gRPC client requirements. According to grpc-go
issue #7691 and the error
@@ -222,9 +219,9 @@ func buildInboundListeners(node *model.Proxy, push
*model.PushContext, names []s
// This allows Gateway to route external traffic to backend
services based on HTTPRoute rules
if node.IsRouter() || isGatewayPod {
if isGatewayPod && !node.IsRouter() {
- log.Warnf("buildInboundListeners: Gateway Pod
detected but node.Type is not Router (node.Type=%v, node.ID=%s), treating as
router anyway", node.Type, node.ID)
+ log.Warnf(" Gateway Pod detected but node.Type
is not Router (node.Type=%v, node.ID=%s), treating as router anyway",
node.Type, node.ID)
}
- log.Infof("buildInboundListeners: Gateway Pod (router)
using RDS for listener %s, routeName=%s, node.ID=%s, node.Type=%v, service=%s",
name, routeName, node.ID, node.Type, si.Service.Attributes.Name)
+ log.Infof(" Gateway Pod (router) using RDS for listener
%s, routeName=%s, node.ID=%s, node.Type=%v, service=%s", name, routeName,
node.ID, node.Type, si.Service.Attributes.Name)
// Gateway Pods need RDS to route traffic based on
HTTPRoute
hcm = &hcmv3.HttpConnectionManager{
CodecType: hcmv3.HttpConnectionManager_AUTO,
@@ -248,7 +245,7 @@ func buildInboundListeners(node *model.Proxy, push
*model.PushContext, names []s
},
},
}
- log.Infof("buildInboundListeners: Gateway Pod (router)
using RDS for listener %s, routeName=%s, node.ID=%s, node.Type=%v", name,
routeName, node.ID, node.Type)
+ log.Infof(" Gateway Pod (router) using RDS for listener
%s, routeName=%s, node.ID=%s, node.Type=%v", name, routeName, node.ID,
node.Type)
} else {
// For regular service Pods, use inline RouteConfig
with NonForwardingAction
// Use inline RouteConfig instead of RDS to avoid
triggering additional RDS requests that cause push loops
@@ -286,7 +283,7 @@ func buildInboundListeners(node *model.Proxy, push
*model.PushContext, names []s
},
},
}
- log.Debugf("buildInboundListeners: regular service Pod
using inline RouteConfig for listener %s", name)
+ log.Debugf(" regular service Pod using inline
RouteConfig for listener %s", name)
}
// For Gateway Pods and regular service Pods, use FilterChain
@@ -309,14 +306,14 @@ func buildInboundListeners(node *model.Proxy, push
*model.PushContext, names []s
// When TransportSocket is present, only TLS
connections can match this FilterChain
// No FilterChainMatch needed - gRPC proxyless will
automatically match based on TransportSocket presence
filterChain.TransportSocket = ts
- log.Infof("buildInboundListeners: applied STRICT mTLS
transport socket to listener %s (mode=%v, requires client cert=true)", name,
mode)
+ log.Infof(" applied STRICT mTLS transport socket to
listener %s (mode=%v, requires client cert=true)", name, mode)
} else if mode == model.MTLSStrict {
- log.Warnf("buildInboundListeners: expected to enable
STRICT mTLS on listener %s but failed to build transport socket (mode=%v)",
name, mode)
+ log.Warnf(" expected to enable STRICT mTLS on listener
%s but failed to build transport socket (mode=%v)", name, mode)
} else {
// For plaintext mode, no TransportSocket means only
plaintext connections can match
// No FilterChainMatch needed - gRPC proxyless will
automatically match based on TransportSocket absence
// TLS connections will fail to match this FilterChain
(no TransportSocket) and connection will fail
- log.Debugf("buildInboundListeners: listener %s using
plaintext (mode=%v) - clients using TLS will fail to connect", name, mode)
+ log.Debugf(" listener %s using plaintext (mode=%v) -
clients using TLS will fail to connect", name, mode)
}
ll := &listener.Listener{
diff --git a/dubbod/discovery/pkg/xds/discovery.go
b/dubbod/discovery/pkg/xds/discovery.go
index 1aadcf17..680cac1b 100644
--- a/dubbod/discovery/pkg/xds/discovery.go
+++ b/dubbod/discovery/pkg/xds/discovery.go
@@ -19,7 +19,6 @@ package xds
import (
"context"
"fmt"
- "github.com/apache/dubbo-kubernetes/pkg/util/sets"
"strconv"
"sync"
"time"
@@ -393,9 +392,9 @@ func (s *DiscoveryServer) EDSUpdate(shard model.ShardKey,
serviceName string, na
if pushType == model.IncrementalPush || pushType == model.FullPush {
log.Debugf("service %s/%s triggering %v push [endpoints=%d]",
namespace, serviceName, pushType, len(dubboEndpoints))
s.ConfigUpdate(&model.PushRequest{
- Full: pushType == model.FullPush,
- ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.ServiceEntry, Name: serviceName, Namespace: namespace}),
- Reason:
model.NewReasonStats(model.EndpointUpdate),
+ // Full: pushType == model.FullPush,
+ // ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.ServiceEntry, Name: serviceName, Namespace: namespace}),
+ // Reason:
model.NewReasonStats(model.EndpointUpdate),
})
} else if pushType == model.NoPush {
// Even when UpdateServiceEndpoints returns NoPush, we may
still need to push
@@ -406,9 +405,9 @@ func (s *DiscoveryServer) EDSUpdate(shard model.ShardKey,
serviceName string, na
if len(dubboEndpoints) == 0 {
log.Debugf("service %s/%s endpoints became empty
[NoPush], forcing push to clear client cache", namespace, serviceName)
s.ConfigUpdate(&model.PushRequest{
- Full: false, // Incremental push
- ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.ServiceEntry, Name: serviceName, Namespace: namespace}),
- Reason:
model.NewReasonStats(model.EndpointUpdate),
+ // Full: false, // Incremental push
+ // ConfigsUpdated:
sets.New(model.ConfigKey{Kind: kind.ServiceEntry, Name: serviceName, Namespace:
namespace}),
+ // Reason:
model.NewReasonStats(model.EndpointUpdate),
})
} else {
// Endpoints exist but NoPush was returned - this means
health status didn't change
diff --git a/dubbod/discovery/pkg/xds/eds.go b/dubbod/discovery/pkg/xds/eds.go
index 33694466..b927a8cd 100644
--- a/dubbod/discovery/pkg/xds/eds.go
+++ b/dubbod/discovery/pkg/xds/eds.go
@@ -95,7 +95,7 @@ func (eds *EdsGenerator) buildEndpoints(proxy *model.Proxy,
req *model.PushReque
// Despite this code existing on the SotW code path, sending these
partial pushes is still allowed;
// see
https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#grouping-resources-into-responses
if !req.Full || canSendPartialFullPushes(req) {
- edsUpdatedServices =
model.ConfigNamesOfKind(req.ConfigsUpdated, kind.ServiceEntry)
+ // edsUpdatedServices =
model.ConfigNamesOfKind(req.ConfigsUpdated, kind.ServiceEntry)
if len(edsUpdatedServices) > 0 {
log.Debugf("edsUpdatedServices count=%d (Full=%v)",
len(edsUpdatedServices), req.Full)
}
@@ -113,15 +113,15 @@ func (eds *EdsGenerator) buildEndpoints(proxy
*model.Proxy, req *model.PushReque
configKeys := make([]string, 0, len(req.ConfigsUpdated))
for ckey := range req.ConfigsUpdated {
configKeys = append(configKeys,
fmt.Sprintf("%s/%s/%s", ckey.Kind, ckey.Namespace, ckey.Name))
- if ckey.Kind == kind.ServiceEntry {
- // Match ConfigsUpdated.Name with
hostname
- // Both should be FQDN (e.g.,
"consumer.grpc-app.svc.cluster.local")
- if ckey.Name == hostname {
- serviceWasUpdated = true
- log.Debugf("service %s was
updated, forcing regeneration", hostname)
- break
- }
+ // if ckey.Kind == kind.ServiceEntry {
+ // Match ConfigsUpdated.Name with hostname
+ // Both should be FQDN (e.g.,
"consumer.grpc-app.svc.cluster.local")
+ if ckey.Name == hostname {
+ serviceWasUpdated = true
+ log.Debugf("service %s was updated,
forcing regeneration", hostname)
+ break
}
+ // }
}
}
@@ -165,7 +165,8 @@ func (eds *EdsGenerator) buildEndpoints(proxy *model.Proxy,
req *model.PushReque
if !shouldRegenerate && !req.Full && req.ConfigsUpdated != nil {
// For incremental pushes, check if any ServiceEntry in
ConfigsUpdated matches this hostname
for ckey := range req.ConfigsUpdated {
- if ckey.Kind == kind.ServiceEntry && ckey.Name
== hostname {
+ // if ckey.Kind == kind.ServiceEntry &&
ckey.Name == hostname {
+ if ckey.Name == hostname {
shouldRegenerate = true
log.Debugf("forcing regeneration for
cluster %s (hostname=%s) due to ConfigsUpdated", clusterName, hostname)
break
@@ -241,7 +242,8 @@ func (eds *EdsGenerator) buildEndpoints(proxy *model.Proxy,
req *model.PushReque
// buildDeltaEndpoints builds endpoints for delta XDS
func (eds *EdsGenerator) buildDeltaEndpoints(proxy *model.Proxy, req
*model.PushRequest, w *model.WatchedResource) (model.Resources, []string,
model.XdsLogDetails) {
- edsUpdatedServices := model.ConfigNamesOfKind(req.ConfigsUpdated,
kind.ServiceEntry)
+ // edsUpdatedServices := model.ConfigNamesOfKind(req.ConfigsUpdated,
kind.ServiceEntry)
+ var edsUpdatedServices map[string]struct{}
var resources model.Resources
var removed []string
empty := 0
@@ -295,7 +297,8 @@ func (eds *EdsGenerator) buildDeltaEndpoints(proxy
*model.Proxy, req *model.Push
if !shouldRegenerate && !req.Full && req.ConfigsUpdated != nil {
// For incremental pushes, check if any ServiceEntry in
ConfigsUpdated matches this hostname
for ckey := range req.ConfigsUpdated {
- if ckey.Kind == kind.ServiceEntry && ckey.Name
== hostname {
+ // if ckey.Kind == kind.ServiceEntry &&
ckey.Name == hostname {
+ if ckey.Name == hostname {
shouldRegenerate = true
log.Debugf("forcing regeneration for
cluster %s (hostname=%s) due to ConfigsUpdated", clusterName, hostname)
break
@@ -386,9 +389,9 @@ func canSendPartialFullPushes(req *model.PushRequest) bool {
// this happens when push requests are merged due to
debounce
continue
}
- if cfg.Kind != kind.ServiceEntry {
- return false
- }
+ // if cfg.Kind != kind.ServiceEntry {
+ // return false
+ // }
}
return true
}
diff --git a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
index f5b617f9..61a28683 100644
--- a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
+++ b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/networking/util"
"github.com/apache/dubbo-kubernetes/pkg/config/host"
"github.com/apache/dubbo-kubernetes/pkg/config/labels"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
dubbolog "github.com/apache/dubbo-kubernetes/pkg/log"
"github.com/cespare/xxhash/v2"
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
@@ -348,9 +347,9 @@ func (b *EndpointBuilder) DependentConfigs()
[]model.ConfigHash {
}
// Create ConfigKey for ServiceEntry and return its hash
configKey := model.ConfigKey{
- Kind: kind.ServiceEntry,
- Name: string(b.hostname),
- Namespace: b.service.Attributes.Namespace,
+ // Kind: kind.ServiceEntry,
+ // Name: string(b.hostname),
+ // Namespace: b.service.Attributes.Namespace,
}
return []model.ConfigHash{configKey.HashCode()}
}
diff --git a/pkg/config/schema/codegen/collections.go
b/pkg/config/schema/codegen/collections.go
index adda7c3a..b85ecdf4 100644
--- a/pkg/config/schema/codegen/collections.go
+++ b/pkg/config/schema/codegen/collections.go
@@ -64,7 +64,7 @@ type inputs struct {
}
func buildInputs() (inputs, error) {
- b, err := os.ReadFile(filepath.Join(env.DubboRootDir,
"/pkg/config/schema/metadata.yaml"))
+ b, err := os.ReadFile(filepath.Join(env.DubboSrc,
"/pkg/config/schema/metadata.yaml"))
if err != nil {
fmt.Printf("unable to read input file: %v", err)
return inputs{}, err
@@ -147,7 +147,7 @@ func toTypePath(r *ast.Resource) string {
}
func toGetter(protoPackage string) string {
- if strings.Contains(protoPackage, "dubbo") {
+ if strings.Contains(protoPackage, "github.com/apache/dubbo-kubernetes")
{
return "Dubbo"
} else if strings.Contains(protoPackage, "sigs.k8s.io/gateway-api") {
return "GatewayAPI"
@@ -180,9 +180,9 @@ func toImport(p string) string {
func toDubboImport(protoPackage string, version string) string {
p := strings.Split(protoPackage, "/")
base := strings.Join(p[:len(p)-1], "")
- imp := strings.ReplaceAll(strings.ReplaceAll(base, ".", ""), "-", "") +
version
- if strings.Contains(protoPackage, "dubbo.apache.org") {
- return "api" + imp
+ dmp := strings.ReplaceAll(strings.ReplaceAll(base, ".", ""), "-", "") +
version
+ if strings.Contains(protoPackage, "github.com/apache/dubbo-kubernetes")
{
+ return "api" + dmp
}
- return imp
+ return dmp
}
diff --git a/pkg/config/schema/codegen/common.go
b/pkg/config/schema/codegen/common.go
index 15ed66af..48bf44f6 100644
--- a/pkg/config/schema/codegen/common.go
+++ b/pkg/config/schema/codegen/common.go
@@ -80,7 +80,7 @@ func Run() error {
"Packages": inp.Packages,
"PackageName": "collections",
"FilePrefix": "// +build !agent",
- "CustomImport": "",
+ "CustomImport": ` ""`,
}),
writeTemplate("pkg/config/schema/collections/collections.agent.gen.go",
collectionsTemplate, map[string]any{
"Entries": agentEntries,
@@ -97,7 +97,7 @@ func writeTemplate(path, tmpl string, i any) error {
if err != nil {
return fmt.Errorf("apply template %v: %v", path, err)
}
- dst := filepath.Join(env.DubboRootDir, path)
+ dst := filepath.Join(env.DubboSrc, path)
if err = os.WriteFile(dst, []byte(t), os.ModePerm); err != nil {
return fmt.Errorf("write template %v: %v", path, err)
}
diff --git a/pkg/config/schema/codegen/templates/clients.go.tmpl
b/pkg/config/schema/codegen/templates/clients.go.tmpl
index 0ec50ed4..1fdb65bc 100644
--- a/pkg/config/schema/codegen/templates/clients.go.tmpl
+++ b/pkg/config/schema/codegen/templates/clients.go.tmpl
@@ -17,8 +17,8 @@ import (
ktypes "github.com/apache/dubbo-kubernetes/pkg/kube/kubetypes"
"github.com/apache/dubbo-kubernetes/pkg/util/ptr"
- apidubboapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
- apidubboapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
{{- end}}
diff --git a/pkg/config/schema/codegen/templates/crdclient.go.tmpl
b/pkg/config/schema/codegen/templates/crdclient.go.tmpl
index e52e3d1d..340aa307 100644
--- a/pkg/config/schema/codegen/templates/crdclient.go.tmpl
+++ b/pkg/config/schema/codegen/templates/crdclient.go.tmpl
@@ -14,8 +14,8 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/kube"
- apidubboapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
- apidubboapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
{{- end}}
@@ -120,7 +120,7 @@ var translationMap = map[config.GroupVersionKind]func(r
runtime.Object) config.C
{{- range .Entries }}
{{- if and (not .Resource.Synthetic) }}
gvk.{{.Resource.Identifier}}: func(r runtime.Object) config.Config {
- obj := r.(*{{.Resource.Kind}})
+ obj := r.(*{{ .DubboClientImport }}.{{.Resource.Kind}})
return config.Config{
Meta: config.Meta{
GroupVersionKind: gvk.{{.Resource.Identifier}},
diff --git a/pkg/config/schema/codegen/templates/types.go.tmpl
b/pkg/config/schema/codegen/templates/types.go.tmpl
index fd14a820..29b141ef 100644
--- a/pkg/config/schema/codegen/templates/types.go.tmpl
+++ b/pkg/config/schema/codegen/templates/types.go.tmpl
@@ -8,8 +8,8 @@ import (
{{- range .Packages}}
{{.ImportName}} "{{.PackageName}}"
{{- end}}
- apidubboapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
- apidubboapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
)
func getGvk(obj any) (config.GroupVersionKind, bool) {
diff --git a/pkg/config/schema/collection/schema.go
b/pkg/config/schema/collection/schema.go
index 741bde21..2768823c 100644
--- a/pkg/config/schema/collection/schema.go
+++ b/pkg/config/schema/collection/schema.go
@@ -1,184 +1,43 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
package collection
import (
- "errors"
"fmt"
- "reflect"
-
- "github.com/hashicorp/go-multierror"
- "google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
- "k8s.io/apimachinery/pkg/runtime/schema"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/labels"
- "github.com/apache/dubbo-kubernetes/pkg/config/validation"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
)
-var protoMessageType = protoregistry.GlobalTypes.FindMessageByName
-
-// Schema for a resource.
+// Schema for a collection.
type Schema interface {
fmt.Stringer
- // GroupVersionKind of the resource. This is the only way to uniquely
identify a resource.
- GroupVersionKind() config.GroupVersionKind
-
- // GroupVersionResource of the resource.
- GroupVersionResource() schema.GroupVersionResource
-
- // IsClusterScoped indicates that this resource is scoped to a
particular namespace within a cluster.
- IsClusterScoped() bool
-
- // IsBuiltin indicates that this resource is builtin (not a CRD)
- IsBuiltin() bool
-
- // Identifier returns a unique identifier for the resource
- Identifier() string
-
- // Kind for this resource.
- Kind() string
-
- // Plural returns the plural form of the Kind.
- Plural() string
-
- // Group for this resource.
- Group() string
-
- // Version of this resource.
- Version() string
-
- // GroupVersionAliasKinds is the GVK of this resource,
- // but the version is from its version aliases to perform version
conversion.
- GroupVersionAliasKinds() []config.GroupVersionKind
-
- // APIVersion is a utility that returns a k8s API version string of the
form "Group/Version".
- APIVersion() string
+ // VariableName is a utility method used to help with codegen. It
provides the name of a Schema instance variable.
+ VariableName() string
- // Proto returns the protocol buffer type name for this resource.
- Proto() string
-
- // ProtoPackage returns the golang package for the protobuf resource.
- ProtoPackage() string
-
- // NewInstance returns a new instance of the protocol buffer message
for this resource.
- NewInstance() (config.Spec, error)
-
- // Status returns the associated status of the schema
- Status() (config.Status, error)
-
- // StatusKind returns the Kind of the status field. If unset, the field
does not support status.
- StatusKind() string
- StatusPackage() string
-
- // MustNewInstance calls NewInstance and panics if an error occurs.
- MustNewInstance() config.Spec
-
- // Validate this schema.
- Validate() error
-
- // ValidateConfig validates that the given config message is of the
correct type for this schema
- // and that the contents are valid.
- ValidateConfig(cfg config.Config) (validation.Warning, error)
+ // Resource is the schema for resources contained in this collection.
+ Resource() resource.Schema
// Equal is a helper function for testing equality between Schema
instances. This supports comparison
// with the cmp library.
Equal(other Schema) bool
}
-// Builder for a Schema.
+// Builder is config for the creation of a Schema
type Builder struct {
- // ClusterScoped is true for resource in cluster-level.
- ClusterScoped bool
-
- // Synthetic is true for resource that do not actually exist in a
cluster
- Synthetic bool
-
- // Builtin is true for resources that are builtin (not CRD)
- Builtin bool
-
- // Identifier is the unique identifier for the resource
- Identifier string
-
- // Kind is the config proto type.
- Kind string
-
- // Plural is the type in plural.
- Plural string
-
- // Group is the config proto group.
- Group string
-
- // Version is the config proto version.
- Version string
-
- // VersionAliases is the config proto version aliases.
- VersionAliases []string
-
- // Proto refers to the protobuf message type name corresponding to the
type
- Proto string
-
- StatusProto string
-
- // ReflectType is the type of the go struct
- ReflectType reflect.Type
-
- // StatusType is the type of the associated status.
- StatusType reflect.Type
-
- // ProtoPackage refers to the name of golang package for the protobuf
message.
- ProtoPackage string
-
- // StatusPackage refers to the name of the golang status package.
- StatusPackage string
-
- // ValidateProto performs validation on protobuf messages based on this
schema.
- ValidateProto validation.ValidateFunc
-}
-
-type schemaImpl struct {
- clusterScoped bool
- builtin bool
- gvk config.GroupVersionKind
- versionAliases []string
- plural string
- apiVersion string
- proto string
- goPackage string
- validateConfig validation.ValidateFunc
- reflectType reflect.Type
- statusType reflect.Type
- statusPackage string
- identifier string
- synthetic bool
+ VariableName string
+ Resource resource.Schema
}
// Build a Schema instance.
func (b Builder) Build() (Schema, error) {
- s := b.BuildNoValidate()
-
- // Validate the schema.
- if err := s.Validate(); err != nil {
- return nil, err
+ if b.Resource == nil {
+ return nil, fmt.Errorf("collection %s: resource must be
non-nil", b.VariableName)
}
- return s, nil
+ return &schemaImpl{
+ variableName: b.VariableName,
+ resource: b.Resource,
+ }, nil
}
// MustBuild calls Build and panics if it fails.
@@ -187,199 +46,30 @@ func (b Builder) MustBuild() Schema {
if err != nil {
panic(fmt.Sprintf("MustBuild: %v", err))
}
- return s
-}
-
-// BuildNoValidate builds the Schema without checking the fields.
-func (b Builder) BuildNoValidate() Schema {
- if b.ValidateProto == nil {
- b.ValidateProto = validation.EmptyValidate
- }
-
- return &schemaImpl{
- clusterScoped: b.ClusterScoped,
- synthetic: b.Synthetic,
- builtin: b.Builtin,
- gvk: config.GroupVersionKind{
- Group: b.Group,
- Version: b.Version,
- Kind: b.Kind,
- },
- plural: b.Plural,
- apiVersion: b.Group + "/" + b.Version,
- versionAliases: b.VersionAliases,
- proto: b.Proto,
- goPackage: b.ProtoPackage,
- identifier: b.Identifier,
- reflectType: b.ReflectType,
- validateConfig: b.ValidateProto,
- statusType: b.StatusType,
- statusPackage: b.StatusPackage,
- }
-}
-func (s *schemaImpl) GroupVersionKind() config.GroupVersionKind {
- return s.gvk
-}
-
-func (s *schemaImpl) GroupVersionResource() schema.GroupVersionResource {
- return schema.GroupVersionResource{
- Group: s.Group(),
- Version: s.Version(),
- Resource: s.Plural(),
- }
-}
-
-func (s *schemaImpl) IsClusterScoped() bool {
- return s.clusterScoped
-}
-
-func (s *schemaImpl) IsBuiltin() bool {
- return s.builtin
-}
-
-func (s *schemaImpl) Identifier() string {
- return s.identifier
-}
-
-func (s *schemaImpl) Kind() string {
- return s.gvk.Kind
-}
-
-func (s *schemaImpl) Plural() string {
- return s.plural
-}
-
-func (s *schemaImpl) Group() string {
- return s.gvk.Group
-}
-
-func (s *schemaImpl) Version() string {
- return s.gvk.Version
-}
-
-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) APIVersion() string {
- return s.apiVersion
-}
-
-func (s *schemaImpl) Proto() string {
- return s.proto
-}
-
-func (s *schemaImpl) ProtoPackage() string {
- return s.goPackage
-}
-
-func (s *schemaImpl) StatusPackage() string {
- return s.statusPackage
+ return s
}
-func (s *schemaImpl) Validate() (err error) {
- if !labels.IsDNS1123Label(s.Kind()) {
- err = multierror.Append(err, fmt.Errorf("invalid kind: %s",
s.Kind()))
- }
- if !labels.IsDNS1123Label(s.plural) {
- err = multierror.Append(err, fmt.Errorf("invalid plural for
kind %s: %s", s.Kind(), s.plural))
- }
- if s.reflectType == nil && getProtoMessageType(s.proto) == nil {
- err = multierror.Append(err, fmt.Errorf("proto message or
reflect type not found: %v", s.proto))
- }
- return
+type schemaImpl struct {
+ resource resource.Schema
+ name config.GroupVersionKind
+ variableName string
}
+// String interface method implementation.
func (s *schemaImpl) String() string {
- return fmt.Sprintf("[Schema](%s, %q, %s)", s.Kind(), s.goPackage,
s.proto)
+ return fmt.Sprintf("[Schema](%s, %q, %s)", s.name,
s.resource.ProtoPackage(), s.resource.Proto())
}
-func (s *schemaImpl) NewInstance() (config.Spec, error) {
- rt := s.reflectType
- var instance any
- if rt == nil {
- // Use proto
- t, err := protoMessageType(protoreflect.FullName(s.proto))
- if err != nil || t == nil {
- return nil, errors.New("failed to find reflect type")
- }
- instance = t.New().Interface()
- } else {
- instance = reflect.New(rt).Interface()
- }
-
- p, ok := instance.(config.Spec)
- if !ok {
- return nil, fmt.Errorf(
- "newInstance: message is not an instance of
config.Spec. kind:%s, type:%v, value:%v",
- s.Kind(), rt, instance)
- }
- return p, nil
-}
-
-func (s *schemaImpl) Status() (config.Status, error) {
- statTyp := s.statusType
- if statTyp == nil {
- return nil, errors.New("unknown status type")
- }
- instance := reflect.New(statTyp).Interface()
- p, ok := instance.(config.Status)
- if !ok {
- return nil, fmt.Errorf("status: statusType not an instance of
config.Status. type: %v, value: %v", statTyp, instance)
- }
- return p, nil
+func (s *schemaImpl) VariableName() string {
+ return s.variableName
}
-func (s *schemaImpl) StatusKind() string {
- if s.statusType == nil {
- return ""
- }
- return s.statusType.Name()
-}
-
-func (s *schemaImpl) MustNewInstance() config.Spec {
- p, err := s.NewInstance()
- if err != nil {
- panic(err)
- }
- return p
-}
-
-func (s *schemaImpl) ValidateConfig(cfg config.Config) (validation.Warning,
error) {
- return s.validateConfig(cfg)
+func (s *schemaImpl) Resource() resource.Schema {
+ return s.resource
}
func (s *schemaImpl) Equal(o Schema) bool {
- return s.IsClusterScoped() == o.IsClusterScoped() &&
- s.Kind() == o.Kind() &&
- s.Plural() == o.Plural() &&
- s.Group() == o.Group() &&
- s.Version() == o.Version() &&
- s.Proto() == o.Proto() &&
- s.ProtoPackage() == o.ProtoPackage()
-}
-
-// FromKubernetesGVK converts a Kubernetes GVK to an Dubbo GVK
-func FromKubernetesGVK(in *schema.GroupVersionKind) config.GroupVersionKind {
- return config.GroupVersionKind{
- Group: in.Group,
- Version: in.Version,
- Kind: in.Kind,
- }
-}
-
-// getProtoMessageType returns the Go lang type of the proto with the
specified name.
-func getProtoMessageType(protoMessageName string) reflect.Type {
- t, err := protoMessageType(protoreflect.FullName(protoMessageName))
- if err != nil || t == nil {
- return nil
- }
- return reflect.TypeOf(t.Zero().Interface())
+ return s.variableName == o.VariableName() &&
+ s.Resource().Equal(o.Resource())
}
diff --git a/pkg/config/schema/collection/schemas.go
b/pkg/config/schema/collection/schemas.go
index 7492e59e..85ad08ae 100644
--- a/pkg/config/schema/collection/schemas.go
+++ b/pkg/config/schema/collection/schemas.go
@@ -18,25 +18,24 @@ package collection
import (
"fmt"
-
- "github.com/apache/dubbo-kubernetes/pkg/slices"
-
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/go-multierror"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/apache/dubbo-kubernetes/pkg/config"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
+ "github.com/apache/dubbo-kubernetes/pkg/slices"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
)
// Schemas contains metadata about configuration resources.
type Schemas struct {
- byCollection map[config.GroupVersionKind]Schema
- byAddOrder []Schema
+ byCollection map[config.GroupVersionKind]resource.Schema
+ byAddOrder []resource.Schema
}
// SchemasFor is a shortcut for creating Schemas. It uses MustAdd for each
element.
-func SchemasFor(schemas ...Schema) Schemas {
+func SchemasFor(schemas ...resource.Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range schemas {
b.MustAdd(s)
@@ -52,7 +51,7 @@ type SchemasBuilder struct {
// NewSchemasBuilder returns a new instance of SchemasBuilder.
func NewSchemasBuilder() *SchemasBuilder {
s := Schemas{
- byCollection: make(map[config.GroupVersionKind]Schema),
+ byCollection: make(map[config.GroupVersionKind]resource.Schema),
}
return &SchemasBuilder{
@@ -61,7 +60,7 @@ func NewSchemasBuilder() *SchemasBuilder {
}
// Add a new collection to the schemas.
-func (b *SchemasBuilder) Add(s Schema) error {
+func (b *SchemasBuilder) Add(s resource.Schema) error {
if _, found := b.schemas.byCollection[s.GroupVersionKind()]; found {
return fmt.Errorf("collection already exists: %v",
s.GroupVersionKind())
}
@@ -72,7 +71,7 @@ func (b *SchemasBuilder) Add(s Schema) error {
}
// MustAdd calls Add and panics if it fails.
-func (b *SchemasBuilder) MustAdd(s Schema) *SchemasBuilder {
+func (b *SchemasBuilder) MustAdd(s resource.Schema) *SchemasBuilder {
if err := b.Add(s); err != nil {
panic(fmt.Sprintf("SchemasBuilder.MustAdd: %v", err))
}
@@ -90,7 +89,7 @@ func (b *SchemasBuilder) Build() Schemas {
}
// ForEach executes the given function on each contained schema, until the
function returns true.
-func (s Schemas) ForEach(handleSchema func(Schema) (done bool)) {
+func (s Schemas) ForEach(handleSchema func(resource.Schema) (done bool)) {
for _, schema := range s.byAddOrder {
if handleSchema(schema) {
return
@@ -129,7 +128,7 @@ func (s Schemas) Intersect(otherSchemas Schemas) Schemas {
}
// FindByGroupVersionKind searches and returns the first schema with the given
GVK
-func (s Schemas) FindByGroupVersionKind(gvk config.GroupVersionKind) (Schema,
bool) {
+func (s Schemas) FindByGroupVersionKind(gvk config.GroupVersionKind)
(resource.Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.GroupVersionKind() == gvk {
return rs, true
@@ -141,7 +140,7 @@ func (s Schemas) FindByGroupVersionKind(gvk
config.GroupVersionKind) (Schema, bo
// FindByGroupVersionAliasesKind searches and returns the first schema with
the given GVK,
// if not found, it will search for version aliases for the schema to see if
there is a match.
-func (s Schemas) FindByGroupVersionAliasesKind(gvk config.GroupVersionKind)
(Schema, bool) {
+func (s Schemas) FindByGroupVersionAliasesKind(gvk config.GroupVersionKind)
(resource.Schema, bool) {
for _, rs := range s.byAddOrder {
for _, va := range rs.GroupVersionAliasKinds() {
if va == gvk {
@@ -155,7 +154,7 @@ func (s Schemas) FindByGroupVersionAliasesKind(gvk
config.GroupVersionKind) (Sch
// FindByGroupKind searches and returns the first schema with the given GVK,
ignoring versions.
// Generally it's a good idea to use FindByGroupVersionAliasesKind, which
validates the version as well.
// FindByGroupKind provides future proofing against versions we don't yet know
about; given we don't know them, its risky.
-func (s Schemas) FindByGroupKind(gvk config.GroupVersionKind) (Schema, bool) {
+func (s Schemas) FindByGroupKind(gvk config.GroupVersionKind)
(resource.Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.Group() == gvk.Group && rs.Kind() == gvk.Kind {
return rs, true
@@ -165,7 +164,7 @@ func (s Schemas) FindByGroupKind(gvk
config.GroupVersionKind) (Schema, bool) {
}
// FindByGroupVersionResource searches and returns the first schema with the
given GVR
-func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource)
(Schema, bool) {
+func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource)
(resource.Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.GroupVersionResource() == gvr {
return rs, true
@@ -176,7 +175,7 @@ func (s Schemas) FindByGroupVersionResource(gvr
schema.GroupVersionResource) (Sc
}
// All returns all known Schemas
-func (s Schemas) All() []Schema {
+func (s Schemas) All() []resource.Schema {
return slices.Clone(s.byAddOrder)
}
@@ -190,7 +189,7 @@ func (s Schemas) GroupVersionKinds()
[]config.GroupVersionKind {
}
// Add creates a copy of this Schemas with the given schemas added.
-func (s Schemas) Add(toAdd ...Schema) Schemas {
+func (s Schemas) Add(toAdd ...resource.Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range s.byAddOrder {
@@ -205,7 +204,7 @@ func (s Schemas) Add(toAdd ...Schema) Schemas {
}
// Remove creates a copy of this Schemas with the given schemas removed.
-func (s Schemas) Remove(toRemove ...Schema) Schemas {
+func (s Schemas) Remove(toRemove ...resource.Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range s.byAddOrder {
diff --git a/pkg/config/schema/collections/collections.gen.go
b/pkg/config/schema/collections/collections.gen.go
index 52942992..51c729d4 100755
--- a/pkg/config/schema/collections/collections.gen.go
+++ b/pkg/config/schema/collections/collections.gen.go
@@ -6,16 +6,15 @@
package collections
import (
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
- "github.com/apache/dubbo-kubernetes/pkg/config/validation"
-
"reflect"
githubcomapachedubbokubernetesapimeshv1alpha1
"github.com/apache/dubbo-kubernetes/api/mesh/v1alpha1"
githubcomapachedubbokubernetesapimetav1alpha1
"github.com/apache/dubbo-kubernetes/api/meta/v1alpha1"
githubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
githubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/api/security/v1alpha3"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
+ "github.com/apache/dubbo-kubernetes/pkg/config/validation"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
k8sioapiautoscalingv2 "k8s.io/api/autoscaling/v2"
@@ -94,10 +93,7 @@ var (
Kind: "DestinationRule",
Plural: "destinationrules",
Version: "v1alpha3",
- VersionAliases: []string{
- "v1alpha3",
- },
- Proto: "dubbo.networking.v1alpha3.DestinationRule",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
+ Proto: "dubbo.networking.v1alpha3.DestinationRule",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
ReflectType:
reflect.TypeOf(&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{}).Elem(),
StatusType:
reflect.TypeOf(&githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus{}).Elem(),
ProtoPackage:
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3", StatusPackage:
"github.com/apache/dubbo-kubernetes/api/meta/v1alpha1",
ClusterScoped: false,
@@ -196,8 +192,8 @@ var (
VersionAliases: []string{
"v1",
},
- Proto: "k8s.io.gateway_api.api.v1alpha1.GatewaySpec",
StatusProto: "k8s.io.gateway_api.api.v1alpha1.HTTPRouteStatus",
- ReflectType:
reflect.TypeOf(&sigsk8siogatewayapiapisv1.GatewaySpec{}).Elem(), StatusType:
reflect.TypeOf(&sigsk8siogatewayapiapisv1.HTTPRouteStatus{}).Elem(),
+ Proto: "k8s.io.gateway_api.api.v1alpha1.GatewaySpec",
StatusProto: "k8s.io.gateway_api.api.v1alpha1.GatewayStatus",
+ ReflectType:
reflect.TypeOf(&sigsk8siogatewayapiapisv1.GatewaySpec{}).Elem(), StatusType:
reflect.TypeOf(&sigsk8siogatewayapiapisv1.GatewayStatus{}).Elem(),
ProtoPackage: "sigs.k8s.io/gateway-api/apis/v1", StatusPackage:
"sigs.k8s.io/gateway-api/apis/v1",
ClusterScoped: false,
Synthetic: false,
@@ -286,10 +282,7 @@ var (
Kind: "PeerAuthentication",
Plural: "peerauthentications",
Version: "v1alpha3",
- VersionAliases: []string{
- "v1alpha3",
- },
- Proto: "dubbo.security.v1alpha3.PeerAuthentication",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
+ Proto: "dubbo.security.v1alpha3.PeerAuthentication",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
ReflectType:
reflect.TypeOf(&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{}).Elem(),
StatusType:
reflect.TypeOf(&githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus{}).Elem(),
ProtoPackage:
"github.com/apache/dubbo-kubernetes/api/security/v1alpha3", StatusPackage:
"github.com/apache/dubbo-kubernetes/api/meta/v1alpha1",
ClusterScoped: false,
@@ -409,10 +402,7 @@ var (
Kind: "VirtualService",
Plural: "virtualservices",
Version: "v1alpha3",
- VersionAliases: []string{
- "v1alpha3",
- },
- Proto: "dubbo.networking.v1alpha3.VirtualService", StatusProto:
"dubbo.meta.v1alpha1.DubboStatus",
+ Proto: "dubbo.networking.v1alpha3.VirtualService",
StatusProto: "dubbo.meta.v1alpha1.DubboStatus",
ReflectType:
reflect.TypeOf(&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{}).Elem(),
StatusType:
reflect.TypeOf(&githubcomapachedubbokubernetesapimetav1alpha1.DubboStatus{}).Elem(),
ProtoPackage:
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3", StatusPackage:
"github.com/apache/dubbo-kubernetes/api/meta/v1alpha1",
ClusterScoped: false,
diff --git a/pkg/config/schema/gvk/resources.gen.go
b/pkg/config/schema/gvk/resources.gen.go
index 394454b0..992f0ea6 100755
--- a/pkg/config/schema/gvk/resources.gen.go
+++ b/pkg/config/schema/gvk/resources.gen.go
@@ -15,7 +15,6 @@ var (
DaemonSet = config.GroupVersionKind{Group: "apps",
Version: "v1", Kind: "DaemonSet"}
Deployment = config.GroupVersionKind{Group: "apps",
Version: "v1", Kind: "Deployment"}
DestinationRule = config.GroupVersionKind{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Kind: "DestinationRule"}
- DestinationRule_v1alpha3 = config.GroupVersionKind{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Kind: "DestinationRule"}
EndpointSlice = config.GroupVersionKind{Group:
"discovery.k8s.io", Version: "v1", Kind: "EndpointSlice"}
Endpoints = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Endpoints"}
GatewayClass = config.GroupVersionKind{Group:
"gateway.networking.k8s.io", Version: "v1", Kind: "GatewayClass"}
@@ -31,7 +30,6 @@ var (
Namespace = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Namespace"}
Node = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Node"}
PeerAuthentication = config.GroupVersionKind{Group:
"security.dubbo.apache.org", Version: "v1alpha3", Kind: "PeerAuthentication"}
- PeerAuthentication_v1alpha3 = config.GroupVersionKind{Group:
"security.dubbo.apache.org", Version: "v1alpha3", Kind: "PeerAuthentication"}
Pod = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Pod"}
PodDisruptionBudget = config.GroupVersionKind{Group:
"policy", Version: "v1", Kind: "PodDisruptionBudget"}
Secret = config.GroupVersionKind{Group: "",
Version: "v1", Kind: "Secret"}
@@ -40,7 +38,6 @@ var (
StatefulSet = config.GroupVersionKind{Group: "apps",
Version: "v1", Kind: "StatefulSet"}
ValidatingWebhookConfiguration = config.GroupVersionKind{Group:
"admissionregistration.k8s.io", Version: "v1", Kind:
"ValidatingWebhookConfiguration"}
VirtualService = config.GroupVersionKind{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Kind: "VirtualService"}
- VirtualService_v1alpha3 = config.GroupVersionKind{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Kind: "VirtualService"}
)
// ToGVR converts a GVK to a GVR.
@@ -56,8 +53,6 @@ func ToGVR(g config.GroupVersionKind)
(schema.GroupVersionResource, bool) {
return gvr.Deployment, true
case DestinationRule:
return gvr.DestinationRule, true
- case DestinationRule_v1alpha3:
- return gvr.DestinationRule_v1alpha3, true
case EndpointSlice:
return gvr.EndpointSlice, true
case Endpoints:
@@ -88,8 +83,6 @@ func ToGVR(g config.GroupVersionKind)
(schema.GroupVersionResource, bool) {
return gvr.Node, true
case PeerAuthentication:
return gvr.PeerAuthentication, true
- case PeerAuthentication_v1alpha3:
- return gvr.PeerAuthentication_v1alpha3, true
case Pod:
return gvr.Pod, true
case PodDisruptionBudget:
@@ -106,8 +99,6 @@ func ToGVR(g config.GroupVersionKind)
(schema.GroupVersionResource, bool) {
return gvr.ValidatingWebhookConfiguration, true
case VirtualService:
return gvr.VirtualService, true
- case VirtualService_v1alpha3:
- return gvr.VirtualService_v1alpha3, true
}
return schema.GroupVersionResource{}, false
diff --git a/pkg/config/schema/gvr/resources.gen.go
b/pkg/config/schema/gvr/resources.gen.go
index eb0a8333..4cc97110 100755
--- a/pkg/config/schema/gvr/resources.gen.go
+++ b/pkg/config/schema/gvr/resources.gen.go
@@ -10,7 +10,6 @@ var (
DaemonSet = schema.GroupVersionResource{Group:
"apps", Version: "v1", Resource: "daemonsets"}
Deployment = schema.GroupVersionResource{Group:
"apps", Version: "v1", Resource: "deployments"}
DestinationRule = schema.GroupVersionResource{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Resource:
"destinationrules"}
- DestinationRule_v1alpha3 = schema.GroupVersionResource{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Resource:
"destinationrules"}
EndpointSlice = schema.GroupVersionResource{Group:
"discovery.k8s.io", Version: "v1", Resource: "endpointslices"}
Endpoints = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "endpoints"}
GatewayClass = schema.GroupVersionResource{Group:
"gateway.networking.k8s.io", Version: "v1", Resource: "gatewayclasses"}
@@ -26,7 +25,6 @@ var (
Namespace = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "namespaces"}
Node = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "nodes"}
PeerAuthentication = schema.GroupVersionResource{Group:
"security.dubbo.apache.org", Version: "v1alpha3", Resource:
"peerauthentications"}
- PeerAuthentication_v1alpha3 = schema.GroupVersionResource{Group:
"security.dubbo.apache.org", Version: "v1alpha3", Resource:
"peerauthentications"}
Pod = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "pods"}
PodDisruptionBudget = schema.GroupVersionResource{Group:
"policy", Version: "v1", Resource: "poddisruptionbudgets"}
Secret = schema.GroupVersionResource{Group: "",
Version: "v1", Resource: "secrets"}
@@ -35,7 +33,6 @@ var (
StatefulSet = schema.GroupVersionResource{Group:
"apps", Version: "v1", Resource: "statefulsets"}
ValidatingWebhookConfiguration = schema.GroupVersionResource{Group:
"admissionregistration.k8s.io", Version: "v1", Resource:
"validatingwebhookconfigurations"}
VirtualService = schema.GroupVersionResource{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Resource: "virtualservices"}
- VirtualService_v1alpha3 = schema.GroupVersionResource{Group:
"networking.dubbo.apache.org", Version: "v1alpha3", Resource: "virtualservices"}
)
func IsClusterScoped(g schema.GroupVersionResource) bool {
@@ -50,8 +47,6 @@ func IsClusterScoped(g schema.GroupVersionResource) bool {
return false
case DestinationRule:
return false
- case DestinationRule_v1alpha3:
- return false
case EndpointSlice:
return false
case Endpoints:
@@ -80,8 +75,6 @@ func IsClusterScoped(g schema.GroupVersionResource) bool {
return true
case PeerAuthentication:
return false
- case PeerAuthentication_v1alpha3:
- return false
case Pod:
return false
case PodDisruptionBudget:
@@ -98,8 +91,6 @@ func IsClusterScoped(g schema.GroupVersionResource) bool {
return true
case VirtualService:
return false
- case VirtualService_v1alpha3:
- return false
}
// shouldn't happen
return false
diff --git a/pkg/config/schema/kind/kind.go b/pkg/config/schema/kind/kind.go
index c10afddf..6c29e6ef 100644
--- a/pkg/config/schema/kind/kind.go
+++ b/pkg/config/schema/kind/kind.go
@@ -1,19 +1,3 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
package kind
type Kind uint8
diff --git a/pkg/config/schema/kubeclient/resources.gen.go
b/pkg/config/schema/kubeclient/resources.gen.go
index ff1a4ea2..f4d4f4cb 100755
--- a/pkg/config/schema/kubeclient/resources.gen.go
+++ b/pkg/config/schema/kubeclient/resources.gen.go
@@ -17,8 +17,8 @@ import (
ktypes "github.com/apache/dubbo-kubernetes/pkg/kube/kubetypes"
"github.com/apache/dubbo-kubernetes/pkg/util/ptr"
- githubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
- githubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/api/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
k8sioapiappsv1 "k8s.io/api/apps/v1"
k8sioapiautoscalingv2 "k8s.io/api/autoscaling/v2"
@@ -40,7 +40,7 @@ func GetWriteClient[T runtime.Object](c ClientGetter,
namespace string) ktypes.W
return
c.Kube().AppsV1().DaemonSets(namespace).(ktypes.WriteAPI[T])
case *k8sioapiappsv1.Deployment:
return
c.Kube().AppsV1().Deployments(namespace).(ktypes.WriteAPI[T])
- case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
return
c.Dubbo().NetworkingV1alpha3().DestinationRules(namespace).(ktypes.WriteAPI[T])
case *k8sioapidiscoveryv1.EndpointSlice:
return
c.Kube().DiscoveryV1().EndpointSlices(namespace).(ktypes.WriteAPI[T])
@@ -62,7 +62,7 @@ func GetWriteClient[T runtime.Object](c ClientGetter,
namespace string) ktypes.W
return c.Kube().CoreV1().Namespaces().(ktypes.WriteAPI[T])
case *k8sioapicorev1.Node:
return c.Kube().CoreV1().Nodes().(ktypes.WriteAPI[T])
- case
*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
+ case
*apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(namespace).(ktypes.WriteAPI[T])
case *k8sioapicorev1.Pod:
return c.Kube().CoreV1().Pods(namespace).(ktypes.WriteAPI[T])
@@ -78,7 +78,7 @@ func GetWriteClient[T runtime.Object](c ClientGetter,
namespace string) ktypes.W
return
c.Kube().AppsV1().StatefulSets(namespace).(ktypes.WriteAPI[T])
case *k8sioapiadmissionregistrationv1.ValidatingWebhookConfiguration:
return
c.Kube().AdmissionregistrationV1().ValidatingWebhookConfigurations().(ktypes.WriteAPI[T])
- case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
return
c.Dubbo().NetworkingV1alpha3().VirtualServices(namespace).(ktypes.WriteAPI[T])
default:
panic(fmt.Sprintf("Unknown type %T", ptr.Empty[T]()))
@@ -95,7 +95,7 @@ func GetClient[T, TL runtime.Object](c ClientGetter,
namespace string) ktypes.Re
return
c.Kube().AppsV1().DaemonSets(namespace).(ktypes.ReadWriteAPI[T, TL])
case *k8sioapiappsv1.Deployment:
return
c.Kube().AppsV1().Deployments(namespace).(ktypes.ReadWriteAPI[T, TL])
- case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
return
c.Dubbo().NetworkingV1alpha3().DestinationRules(namespace).(ktypes.ReadWriteAPI[T,
TL])
case *k8sioapidiscoveryv1.EndpointSlice:
return
c.Kube().DiscoveryV1().EndpointSlices(namespace).(ktypes.ReadWriteAPI[T, TL])
@@ -117,7 +117,7 @@ func GetClient[T, TL runtime.Object](c ClientGetter,
namespace string) ktypes.Re
return c.Kube().CoreV1().Namespaces().(ktypes.ReadWriteAPI[T,
TL])
case *k8sioapicorev1.Node:
return c.Kube().CoreV1().Nodes().(ktypes.ReadWriteAPI[T, TL])
- case
*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
+ case
*apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
return
c.Dubbo().SecurityV1alpha3().PeerAuthentications(namespace).(ktypes.ReadWriteAPI[T,
TL])
case *k8sioapicorev1.Pod:
return
c.Kube().CoreV1().Pods(namespace).(ktypes.ReadWriteAPI[T, TL])
@@ -133,7 +133,7 @@ func GetClient[T, TL runtime.Object](c ClientGetter,
namespace string) ktypes.Re
return
c.Kube().AppsV1().StatefulSets(namespace).(ktypes.ReadWriteAPI[T, TL])
case *k8sioapiadmissionregistrationv1.ValidatingWebhookConfiguration:
return
c.Kube().AdmissionregistrationV1().ValidatingWebhookConfigurations().(ktypes.ReadWriteAPI[T,
TL])
- case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
return
c.Dubbo().NetworkingV1alpha3().VirtualServices(namespace).(ktypes.ReadWriteAPI[T,
TL])
default:
panic(fmt.Sprintf("Unknown type %T", ptr.Empty[T]()))
@@ -151,7 +151,7 @@ func gvrToObject(g schema.GroupVersionResource)
runtime.Object {
case gvr.Deployment:
return &k8sioapiappsv1.Deployment{}
case gvr.DestinationRule:
- return
&githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{}
+ return
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule{}
case gvr.EndpointSlice:
return &k8sioapidiscoveryv1.EndpointSlice{}
case gvr.Endpoints:
@@ -173,7 +173,7 @@ func gvrToObject(g schema.GroupVersionResource)
runtime.Object {
case gvr.Node:
return &k8sioapicorev1.Node{}
case gvr.PeerAuthentication:
- return
&githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{}
+ return
&apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication{}
case gvr.Pod:
return &k8sioapicorev1.Pod{}
case gvr.PodDisruptionBudget:
@@ -189,7 +189,7 @@ func gvrToObject(g schema.GroupVersionResource)
runtime.Object {
case gvr.ValidatingWebhookConfiguration:
return
&k8sioapiadmissionregistrationv1.ValidatingWebhookConfiguration{}
case gvr.VirtualService:
- return
&githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{}
+ return
&apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService{}
default:
panic(fmt.Sprintf("Unknown type %v", g))
}
diff --git a/pkg/config/schema/kubetypes/resources.gen.go
b/pkg/config/schema/kubetypes/resources.gen.go
index d8da3b6b..be27f14e 100755
--- a/pkg/config/schema/kubetypes/resources.gen.go
+++ b/pkg/config/schema/kubetypes/resources.gen.go
@@ -6,6 +6,8 @@ import (
githubcomapachedubbokubernetesapimeshv1alpha1
"github.com/apache/dubbo-kubernetes/api/mesh/v1alpha1"
githubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
githubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/api/security/v1alpha3"
+ apigithubcomapachedubbokubernetesapinetworkingv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/networking/v1alpha3"
+ apigithubcomapachedubbokubernetesapisecurityv1alpha3
"github.com/apache/dubbo-kubernetes/client-go/pkg/apis/security/v1alpha3"
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
k8sioapiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
@@ -31,6 +33,8 @@ func getGvk(obj any) (config.GroupVersionKind, bool) {
return gvk.Deployment, true
case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
return gvk.DestinationRule, true
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.DestinationRule:
+ return gvk.DestinationRule, true
case *k8sioapidiscoveryv1.EndpointSlice:
return gvk.EndpointSlice, true
case *k8sioapicorev1.Endpoints:
@@ -55,6 +59,8 @@ func getGvk(obj any) (config.GroupVersionKind, bool) {
return gvk.Node, true
case
*githubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
return gvk.PeerAuthentication, true
+ case
*apigithubcomapachedubbokubernetesapisecurityv1alpha3.PeerAuthentication:
+ return gvk.PeerAuthentication, true
case *k8sioapicorev1.Pod:
return gvk.Pod, true
case *k8sioapipolicyv1.PodDisruptionBudget:
@@ -71,6 +77,8 @@ func getGvk(obj any) (config.GroupVersionKind, bool) {
return gvk.ValidatingWebhookConfiguration, true
case
*githubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
return gvk.VirtualService, true
+ case
*apigithubcomapachedubbokubernetesapinetworkingv1alpha3.VirtualService:
+ return gvk.VirtualService, true
default:
return config.GroupVersionKind{}, false
}
diff --git a/pkg/config/schema/metadata.yaml b/pkg/config/schema/metadata.yaml
index 928af4ea..8ab7dd6d 100644
--- a/pkg/config/schema/metadata.yaml
+++ b/pkg/config/schema/metadata.yaml
@@ -177,7 +177,7 @@ resources:
protoPackage: "sigs.k8s.io/gateway-api/apis/v1"
proto: "k8s.io.gateway_api.api.v1alpha1.GatewaySpec"
validate: "validation.EmptyValidate"
- statusProto: "k8s.io.gateway_api.api.v1alpha1.HTTPRouteStatus"
+ statusProto: "k8s.io.gateway_api.api.v1alpha1.GatewayStatus"
statusProtoPackage: "sigs.k8s.io/gateway-api/apis/v1"
- kind: "HTTPRoute"
@@ -196,8 +196,6 @@ resources:
plural: "virtualservices"
group: "networking.dubbo.apache.org"
version: "v1alpha3"
- versionAliases:
- - "v1alpha3"
proto: "dubbo.networking.v1alpha3.VirtualService"
protoPackage: "github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
statusProto: "dubbo.meta.v1alpha1.DubboStatus"
@@ -207,8 +205,6 @@ resources:
plural: "destinationrules"
group: "networking.dubbo.apache.org"
version: "v1alpha3"
- versionAliases:
- - "v1alpha3"
proto: "dubbo.networking.v1alpha3.DestinationRule"
protoPackage: "github.com/apache/dubbo-kubernetes/api/networking/v1alpha3"
statusProto: "dubbo.meta.v1alpha1.DubboStatus"
@@ -226,8 +222,6 @@ resources:
plural: "peerauthentications"
group: "security.dubbo.apache.org"
version: "v1alpha3"
- versionAliases:
- - "v1alpha3"
proto: "dubbo.security.v1alpha3.PeerAuthentication"
protoPackage: "github.com/apache/dubbo-kubernetes/api/security/v1alpha3"
statusProto: "dubbo.meta.v1alpha1.DubboStatus"
diff --git a/pkg/config/schema/resource/schema.go
b/pkg/config/schema/resource/schema.go
index 49f6bcc0..d2cdc86d 100644
--- a/pkg/config/schema/resource/schema.go
+++ b/pkg/config/schema/resource/schema.go
@@ -1,20 +1,36 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package resource
import (
"errors"
"fmt"
- "reflect"
-
+ "github.com/apache/dubbo-kubernetes/pkg/config"
+ "github.com/apache/dubbo-kubernetes/pkg/config/labels"
+ "github.com/apache/dubbo-kubernetes/pkg/config/validation"
"github.com/hashicorp/go-multierror"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"k8s.io/apimachinery/pkg/runtime/schema"
-
- "github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/labels"
- "github.com/apache/dubbo-kubernetes/pkg/config/validation"
+ "reflect"
)
+var protoMessageType = protoregistry.GlobalTypes.FindMessageByName
+
// Schema for a resource.
type Schema interface {
fmt.Stringer
@@ -67,6 +83,7 @@ type Schema interface {
// StatusKind returns the Kind of the status field. If unset, the field
does not support status.
StatusKind() string
+
StatusPackage() string
// MustNewInstance calls NewInstance and panics if an error occurs.
@@ -134,6 +151,27 @@ type Builder struct {
ValidateProto validation.ValidateFunc
}
+type schemaImpl struct {
+ clusterScoped bool
+ builtin bool
+ gvk config.GroupVersionKind
+ versionAliases []string
+ plural string
+ apiVersion string
+ proto string
+ goPackage string
+ validateConfig validation.ValidateFunc
+ reflectType reflect.Type
+ statusType reflect.Type
+ statusPackage string
+ identifier string
+ synthetic bool
+
+ variableName string
+ resource Schema
+ name config.GroupVersionKind
+}
+
// Build a Schema instance.
func (b Builder) Build() (Schema, error) {
s := b.BuildNoValidate()
@@ -183,23 +221,6 @@ func (b Builder) BuildNoValidate() Schema {
}
}
-type schemaImpl struct {
- clusterScoped bool
- builtin bool
- gvk config.GroupVersionKind
- versionAliases []string
- plural string
- apiVersion string
- proto string
- goPackage string
- validateConfig validation.ValidateFunc
- reflectType reflect.Type
- statusType reflect.Type
- statusPackage string
- identifier string
- synthetic bool
-}
-
func (s *schemaImpl) GroupVersionKind() config.GroupVersionKind {
return s.gvk
}
@@ -365,5 +386,3 @@ func getProtoMessageType(protoMessageName string)
reflect.Type {
}
return reflect.TypeOf(t.Zero().Interface())
}
-
-var protoMessageType = protoregistry.GlobalTypes.FindMessageByName
diff --git a/pkg/env/dubbo.go b/pkg/env/dubbo.go
index 0d3c2267..8f554f68 100644
--- a/pkg/env/dubbo.go
+++ b/pkg/env/dubbo.go
@@ -10,7 +10,7 @@ var (
// nolint: revive, stylecheck
REPO_ROOT Variable = "REPO_ROOT"
- DubboRootDir = REPO_ROOT.ValueOrDefaultFunc(getDefaultDubboRootDir)
+ DubboSrc = REPO_ROOT.ValueOrDefaultFunc(getDefaultDubboSrc)
)
var (
@@ -21,6 +21,6 @@ var (
Root = filepath.Clean(filepath.Join(filepath.Dir(b), "../.."))
)
-func getDefaultDubboRootDir() string {
+func getDefaultDubboSrc() string {
return Root
}
diff --git a/pkg/webhooks/server/server.go b/pkg/webhooks/server/server.go
index 4b32f7c5..c4a5d151 100644
--- a/pkg/webhooks/server/server.go
+++ b/pkg/webhooks/server/server.go
@@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
admissionv1 "k8s.io/api/admission/v1"
kubeApiAdmissionv1beta1 "k8s.io/api/admission/v1beta1"
"net/http"
@@ -123,7 +124,7 @@ func (wh *Webhook) validate(request *kube.AdmissionRequest)
*kube.AdmissionRespo
gvk := obj.GroupVersionKind()
- s, exists :=
wh.schemas.FindByGroupKind(collection.FromKubernetesGVK(&gvk))
+ s, exists :=
wh.schemas.FindByGroupKind(resource.FromKubernetesGVK(&gvk))
if !exists {
log.Infof("unrecognized type %v",
addDryRunMessageIfNeeded(obj.GroupVersionKind().String()))
return toAdmissionResponse(fmt.Errorf("unrecognized type %v",
obj.GroupVersionKind()))