refactor(v2): upgrade module to github.com/alibaba/higress/v2 (#2922)

Signed-off-by: Xijun Dai <daixijun1990@gmail.com>
This commit is contained in:
Xijun Dai
2025-09-21 14:29:07 +08:00
committed by GitHub
parent cd2082033c
commit 47827ad271
235 changed files with 1077 additions and 1045 deletions

View File

@@ -49,28 +49,28 @@ import (
listersv1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
higressext "github.com/alibaba/higress/api/extensions/v1alpha1"
higressv1 "github.com/alibaba/higress/api/networking/v1"
extlisterv1 "github.com/alibaba/higress/client/pkg/listers/extensions/v1alpha1"
netlisterv1 "github.com/alibaba/higress/client/pkg/listers/networking/v1"
"github.com/alibaba/higress/pkg/cert"
higressconst "github.com/alibaba/higress/pkg/config/constants"
"github.com/alibaba/higress/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/pkg/ingress/kube/common"
"github.com/alibaba/higress/pkg/ingress/kube/configmap"
"github.com/alibaba/higress/pkg/ingress/kube/gateway"
"github.com/alibaba/higress/pkg/ingress/kube/http2rpc"
"github.com/alibaba/higress/pkg/ingress/kube/ingress"
"github.com/alibaba/higress/pkg/ingress/kube/ingressv1"
"github.com/alibaba/higress/pkg/ingress/kube/mcpbridge"
"github.com/alibaba/higress/pkg/ingress/kube/mcpserver"
"github.com/alibaba/higress/pkg/ingress/kube/secret"
"github.com/alibaba/higress/pkg/ingress/kube/util"
"github.com/alibaba/higress/pkg/ingress/kube/wasmplugin"
. "github.com/alibaba/higress/pkg/ingress/log"
"github.com/alibaba/higress/pkg/kube"
"github.com/alibaba/higress/registry"
"github.com/alibaba/higress/registry/reconcile"
higressext "github.com/alibaba/higress/v2/api/extensions/v1alpha1"
higressv1 "github.com/alibaba/higress/v2/api/networking/v1"
extlisterv1 "github.com/alibaba/higress/v2/client/pkg/listers/extensions/v1alpha1"
netlisterv1 "github.com/alibaba/higress/v2/client/pkg/listers/networking/v1"
"github.com/alibaba/higress/v2/pkg/cert"
higressconst "github.com/alibaba/higress/v2/pkg/config/constants"
"github.com/alibaba/higress/v2/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/v2/pkg/ingress/kube/common"
"github.com/alibaba/higress/v2/pkg/ingress/kube/configmap"
"github.com/alibaba/higress/v2/pkg/ingress/kube/gateway"
"github.com/alibaba/higress/v2/pkg/ingress/kube/http2rpc"
"github.com/alibaba/higress/v2/pkg/ingress/kube/ingress"
"github.com/alibaba/higress/v2/pkg/ingress/kube/ingressv1"
"github.com/alibaba/higress/v2/pkg/ingress/kube/mcpbridge"
"github.com/alibaba/higress/v2/pkg/ingress/kube/mcpserver"
"github.com/alibaba/higress/v2/pkg/ingress/kube/secret"
"github.com/alibaba/higress/v2/pkg/ingress/kube/util"
"github.com/alibaba/higress/v2/pkg/ingress/kube/wasmplugin"
. "github.com/alibaba/higress/v2/pkg/ingress/log"
"github.com/alibaba/higress/v2/pkg/kube"
"github.com/alibaba/higress/v2/registry"
"github.com/alibaba/higress/v2/registry/reconcile"
)
var (
@@ -292,7 +292,7 @@ func (m *IngressConfig) List(typ config.GroupVersionKind, namespace string) []co
typ != gvk.WasmPlugin {
return nil
}
var configs = make([]config.Config, 0)
configs := make([]config.Config, 0)
if configsFromIngress := m.listFromIngressControllers(typ, namespace); configsFromIngress != nil {
// Process templates for ingress configs
@@ -579,9 +579,11 @@ func (m *IngressConfig) convertVirtualService(configs []common.WrapperConfig) []
cleanHost := common.CleanHost(host)
// namespace/name, name format: (istio cluster id)-host
gateways := []string{m.namespace + "/" +
common.CreateConvertedName(m.clusterId.String(), cleanHost),
common.CreateConvertedName(constants.IstioIngressGatewayName, cleanHost)}
gateways := []string{
m.namespace + "/" +
common.CreateConvertedName(m.clusterId.String(), cleanHost),
common.CreateConvertedName(constants.IstioIngressGatewayName, cleanHost),
}
wrapperVS, exist := convertOptions.VirtualServices[host]
if !exist {
@@ -1563,19 +1565,19 @@ func (m *IngressConfig) constructHttp2RpcMethods(dubbo *higressv1.DubboService)
}`
var methods []interface{}
for _, serviceMethod := range dubbo.GetMethods() {
var method = make(map[string]interface{})
method := make(map[string]interface{})
method["name"] = serviceMethod.GetServiceMethod()
var params []interface{}
// paramFromEntireBody is for methods with single parameter. So when paramFromEntireBody exists, we just ignore params.
var paramFromEntireBody = serviceMethod.GetParamFromEntireBody()
paramFromEntireBody := serviceMethod.GetParamFromEntireBody()
if paramFromEntireBody != nil {
var param = make(map[string]interface{})
param := make(map[string]interface{})
param["extract_key_spec"] = Http2RpcParamSourceMap()["BODY"]
param["mapping_type"] = paramFromEntireBody.GetParamType()
params = append(params, param)
} else {
for _, methodParam := range serviceMethod.GetParams() {
var param = make(map[string]interface{})
param := make(map[string]interface{})
param["extract_key"] = methodParam.GetParamKey()
param["extract_key_spec"] = Http2RpcParamSourceMap()[methodParam.GetParamSource()]
param["mapping_type"] = methodParam.GetParamType()
@@ -1583,12 +1585,12 @@ func (m *IngressConfig) constructHttp2RpcMethods(dubbo *higressv1.DubboService)
}
}
method["parameter_mapping"] = params
var path_matcher = make(map[string]interface{})
path_matcher := make(map[string]interface{})
path_matcher["match_http_method_spec"] = Http2RpcMethodMap()[serviceMethod.HttpMethods[0]]
path_matcher["match_pattern"] = serviceMethod.GetHttpPath()
method["path_matcher"] = path_matcher
var passthrough_setting = make(map[string]interface{})
var headersAttach = serviceMethod.GetHeadersAttach()
passthrough_setting := make(map[string]interface{})
headersAttach := serviceMethod.GetHeadersAttach()
if headersAttach == "" {
passthrough_setting["passthrough_all_headers"] = false
} else if headersAttach == "*" {
@@ -1599,8 +1601,8 @@ func (m *IngressConfig) constructHttp2RpcMethods(dubbo *higressv1.DubboService)
method["passthrough_setting"] = passthrough_setting
methods = append(methods, method)
}
var serviceMapping = make(map[string]interface{})
var dubboServiceGroup = dubbo.GetGroup()
serviceMapping := make(map[string]interface{})
dubboServiceGroup := dubbo.GetGroup()
if dubboServiceGroup != "" {
serviceMapping["group"] = dubboServiceGroup
}

View File

@@ -28,11 +28,11 @@ import (
ingress "k8s.io/api/networking/v1"
ingressv1beta1 "k8s.io/api/networking/v1beta1"
"github.com/alibaba/higress/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/pkg/ingress/kube/common"
controllerv1beta1 "github.com/alibaba/higress/pkg/ingress/kube/ingress"
controllerv1 "github.com/alibaba/higress/pkg/ingress/kube/ingressv1"
"github.com/alibaba/higress/pkg/kube"
"github.com/alibaba/higress/v2/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/v2/pkg/ingress/kube/common"
controllerv1beta1 "github.com/alibaba/higress/v2/pkg/ingress/kube/ingress"
controllerv1 "github.com/alibaba/higress/v2/pkg/ingress/kube/ingressv1"
"github.com/alibaba/higress/v2/pkg/kube"
)
func TestNormalizeWeightedCluster(t *testing.T) {

View File

@@ -20,7 +20,7 @@ import (
"regexp"
"strings"
. "github.com/alibaba/higress/pkg/ingress/log"
. "github.com/alibaba/higress/v2/pkg/ingress/log"
"google.golang.org/protobuf/proto"
"istio.io/istio/pkg/config"
)

View File

@@ -30,14 +30,14 @@ import (
listersv1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"github.com/alibaba/higress/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/pkg/ingress/kube/common"
"github.com/alibaba/higress/pkg/ingress/kube/kingress"
"github.com/alibaba/higress/pkg/ingress/kube/secret"
"github.com/alibaba/higress/pkg/ingress/kube/util"
. "github.com/alibaba/higress/pkg/ingress/log"
"github.com/alibaba/higress/pkg/kube"
"github.com/alibaba/higress/registry/reconcile"
"github.com/alibaba/higress/v2/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/v2/pkg/ingress/kube/common"
"github.com/alibaba/higress/v2/pkg/ingress/kube/kingress"
"github.com/alibaba/higress/v2/pkg/ingress/kube/secret"
"github.com/alibaba/higress/v2/pkg/ingress/kube/util"
. "github.com/alibaba/higress/v2/pkg/ingress/log"
"github.com/alibaba/higress/v2/pkg/kube"
"github.com/alibaba/higress/v2/registry/reconcile"
)
var (
@@ -310,9 +310,11 @@ func (m *KIngressConfig) convertVirtualService(configs []common.WrapperConfig) [
cleanHost := common.CleanHost(host)
// namespace/name, name format: (istio cluster id)-host
gateways := []string{m.namespace + "/" +
common.CreateConvertedName(m.clusterId.String(), cleanHost),
common.CreateConvertedName(constants.IstioIngressGatewayName, cleanHost)}
gateways := []string{
m.namespace + "/" +
common.CreateConvertedName(m.clusterId.String(), cleanHost),
common.CreateConvertedName(constants.IstioIngressGatewayName, cleanHost),
}
wrapperVS, exist := convertOptions.VirtualServices[host]
if !exist {

View File

@@ -27,10 +27,10 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
ingress "knative.dev/networking/pkg/apis/networking/v1alpha1"
"github.com/alibaba/higress/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/pkg/ingress/kube/common"
kcontrollerv1 "github.com/alibaba/higress/pkg/ingress/kube/kingress"
"github.com/alibaba/higress/pkg/kube"
"github.com/alibaba/higress/v2/pkg/ingress/kube/annotations"
"github.com/alibaba/higress/v2/pkg/ingress/kube/common"
kcontrollerv1 "github.com/alibaba/higress/v2/pkg/ingress/kube/kingress"
"github.com/alibaba/higress/v2/pkg/kube"
)
func TestNormalizeKWeightedCluster(t *testing.T) {
@@ -402,7 +402,7 @@ func TestConvertGatewaysForKIngress(t *testing.T) {
Tls: &networking.ServerTLSSettings{
Mode: networking.ServerTLSSettings_SIMPLE,
CredentialName: "kubernetes-ingress://kingress__/wakanda/foo-com",
//CipherSuites: []string{"ECDHE-RSA-AES128-GCM-SHA256", "AES256-SHA"},
// CipherSuites: []string{"ECDHE-RSA-AES128-GCM-SHA256", "AES256-SHA"},
},
},
},
@@ -441,7 +441,7 @@ func TestConvertGatewaysForKIngress(t *testing.T) {
Tls: &networking.ServerTLSSettings{
Mode: networking.ServerTLSSettings_SIMPLE,
CredentialName: "kubernetes-ingress://kingress__/wakanda/test-com",
//CipherSuites: []string{"ECDHE-RSA-AES128-GCM-SHA256", "AES256-SHA"},
// CipherSuites: []string{"ECDHE-RSA-AES128-GCM-SHA256", "AES256-SHA"},
},
},
},
@@ -489,11 +489,11 @@ func TestConvertGatewaysForKIngress(t *testing.T) {
for _, item := range result {
host := common.GetHost(item.Annotations)
fmt.Print(item)
//assert.Equal(t, testCase.expect[host], item)
// assert.Equal(t, testCase.expect[host], item)
target[host] = item
//break
// break
}
//assert.Equal(t, testCase.expect, target)
// assert.Equal(t, testCase.expect, target)
if diff := cmp.Diff(target, testCase.expect, cmpopts.IgnoreUnexported(unexportedIgnoredTypes...)); diff != "" {
t.Errorf("convertGateways() mismatch (-want +got):\n%s", diff)
}

View File

@@ -18,8 +18,8 @@ import (
"fmt"
"sync"
"github.com/alibaba/higress/pkg/ingress/kube/util"
. "github.com/alibaba/higress/pkg/ingress/log"
"github.com/alibaba/higress/v2/pkg/ingress/kube/util"
. "github.com/alibaba/higress/v2/pkg/ingress/log"
istiomodel "istio.io/istio/pilot/pkg/model"
"istio.io/istio/pkg/config"
"istio.io/istio/pkg/config/schema/kind"

View File

@@ -15,10 +15,11 @@
package config
import (
"k8s.io/apimachinery/pkg/types"
"testing"
"github.com/alibaba/higress/pkg/ingress/kube/util"
"k8s.io/apimachinery/pkg/types"
"github.com/alibaba/higress/v2/pkg/ingress/kube/util"
"github.com/stretchr/testify/assert"
istiomodel "istio.io/istio/pilot/pkg/model"
"istio.io/istio/pkg/cluster"
@@ -32,27 +33,27 @@ type mockXdsUpdater struct {
}
func (m *mockXdsUpdater) EDSUpdate(shard istiomodel.ShardKey, hostname string, namespace string, entry []*istiomodel.IstioEndpoint) {
//TODO implement me
// TODO implement me
panic("implement me")
}
func (m *mockXdsUpdater) EDSCacheUpdate(shard istiomodel.ShardKey, hostname string, namespace string, entry []*istiomodel.IstioEndpoint) {
//TODO implement me
// TODO implement me
panic("implement me")
}
func (m *mockXdsUpdater) SvcUpdate(shard istiomodel.ShardKey, hostname string, namespace string, event istiomodel.Event) {
//TODO implement me
// TODO implement me
panic("implement me")
}
func (m *mockXdsUpdater) ProxyUpdate(clusterID cluster.ID, ip string) {
//TODO implement me
// TODO implement me
panic("implement me")
}
func (m *mockXdsUpdater) RemoveShard(shardKey istiomodel.ShardKey) {
//TODO implement me
// TODO implement me
panic("implement me")
}