fix ai fallback (#1541)

This commit is contained in:
澄潭
2024-11-25 16:48:59 +08:00
committed by GitHub
parent e68a8ac25f
commit a7593381e1
5 changed files with 24 additions and 23 deletions

View File

@@ -144,7 +144,7 @@ docker-buildx-push: clean-env docker.higress-buildx
export PARENT_GIT_TAG:=$(shell cat VERSION) export PARENT_GIT_TAG:=$(shell cat VERSION)
export PARENT_GIT_REVISION:=$(TAG) export PARENT_GIT_REVISION:=$(TAG)
export ENVOY_PACKAGE_URL_PATTERN?=https://github.com/higress-group/proxy/releases/download/v2.0.0/envoy-symbol-ARCH.tar.gz export ENVOY_PACKAGE_URL_PATTERN?=https://github.com/higress-group/proxy/releases/download/v2.1.0/envoy-symbol-ARCH.tar.gz
build-envoy: prebuild build-envoy: prebuild
./tools/hack/build-envoy.sh ./tools/hack/build-envoy.sh

View File

@@ -906,6 +906,7 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
StructValue: rule.Config, StructValue: rule.Config,
} }
validRule := false
var matchItems []*_struct.Value var matchItems []*_struct.Value
// match ingress // match ingress
for _, ing := range rule.Ingress { for _, ing := range rule.Ingress {
@@ -916,6 +917,7 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}) })
} }
if len(matchItems) > 0 { if len(matchItems) > 0 {
validRule = true
v.StructValue.Fields["_match_route_"] = &_struct.Value{ v.StructValue.Fields["_match_route_"] = &_struct.Value{
Kind: &_struct.Value_ListValue{ Kind: &_struct.Value_ListValue{
ListValue: &_struct.ListValue{ ListValue: &_struct.ListValue{
@@ -923,12 +925,9 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}, },
}, },
} }
ruleValues = append(ruleValues, &_struct.Value{
Kind: v,
})
continue
} }
// match service // match service
matchItems = nil
for _, service := range rule.Service { for _, service := range rule.Service {
matchItems = append(matchItems, &_struct.Value{ matchItems = append(matchItems, &_struct.Value{
Kind: &_struct.Value_StringValue{ Kind: &_struct.Value_StringValue{
@@ -937,6 +936,7 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}) })
} }
if len(matchItems) > 0 { if len(matchItems) > 0 {
validRule = true
v.StructValue.Fields["_match_service_"] = &_struct.Value{ v.StructValue.Fields["_match_service_"] = &_struct.Value{
Kind: &_struct.Value_ListValue{ Kind: &_struct.Value_ListValue{
ListValue: &_struct.ListValue{ ListValue: &_struct.ListValue{
@@ -944,12 +944,9 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}, },
}, },
} }
ruleValues = append(ruleValues, &_struct.Value{
Kind: v,
})
continue
} }
// match domain // match domain
matchItems = nil
for _, domain := range rule.Domain { for _, domain := range rule.Domain {
matchItems = append(matchItems, &_struct.Value{ matchItems = append(matchItems, &_struct.Value{
Kind: &_struct.Value_StringValue{ Kind: &_struct.Value_StringValue{
@@ -957,9 +954,8 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}, },
}) })
} }
if len(matchItems) == 0 { if len(matchItems) > 0 {
return nil, fmt.Errorf("invalid match rule has no match condition, rule:%v", rule) validRule = true
}
v.StructValue.Fields["_match_domain_"] = &_struct.Value{ v.StructValue.Fields["_match_domain_"] = &_struct.Value{
Kind: &_struct.Value_ListValue{ Kind: &_struct.Value_ListValue{
ListValue: &_struct.ListValue{ ListValue: &_struct.ListValue{
@@ -967,9 +963,14 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
}, },
}, },
} }
}
if validRule {
ruleValues = append(ruleValues, &_struct.Value{ ruleValues = append(ruleValues, &_struct.Value{
Kind: v, Kind: v,
}) })
} else {
return nil, fmt.Errorf("invalid match rule has no match condition, rule:%v", rule)
}
} }
if len(ruleValues) > 0 { if len(ruleValues) > 0 {
hasValidRule = true hasValidRule = true