support virtualservice multi port
Signed-off-by: zackzhangkai <zhangkaiamm@gmail.com>
This commit is contained in:
@@ -118,6 +118,7 @@ func FillDestinationPort(vs *v1alpha3.VirtualService, service *corev1.Service) {
|
||||
vs.Spec.Http[i].Route[j].Destination.Port = &apiv1alpha3.PortSelector{
|
||||
Number: uint32(service.Spec.Ports[0].Port),
|
||||
}
|
||||
vs.Spec.Http[i].Match[j].Port = uint32(service.Spec.Ports[0].Port)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +136,18 @@ func FillDestinationPort(vs *v1alpha3.VirtualService, service *corev1.Service) {
|
||||
vs.Spec.Tcp[i].Route[j].Destination.Port = &apiv1alpha3.PortSelector{
|
||||
Number: uint32(service.Spec.Ports[0].Port),
|
||||
}
|
||||
vs.Spec.Tcp[i].Match[j].Port = uint32(service.Spec.Ports[0].Port)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SupportHttpProtocol(protocol string) bool {
|
||||
httpPro := []string{"http", "http2", "grpc"}
|
||||
for _, i := range httpPro {
|
||||
if strings.ToLower(protocol) == i || strings.HasPrefix(strings.ToLower(protocol), i+"-") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
21
pkg/controller/utils/servicemesh/application_test.go
Normal file
21
pkg/controller/utils/servicemesh/application_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package servicemesh
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsHTTP(t *testing.T) {
|
||||
if !SupportHttpProtocol("gRPC") {
|
||||
t.Errorf("gRPC is HTTP protocol")
|
||||
}
|
||||
if !SupportHttpProtocol("HTTP") {
|
||||
t.Errorf("HTTP is HTTP protocol")
|
||||
}
|
||||
if !SupportHttpProtocol("HTTP2") {
|
||||
t.Errorf("HTTP2 is HTTP protocol")
|
||||
}
|
||||
if SupportHttpProtocol("Mysql") {
|
||||
t.Errorf("mysql is not HTTP protocol")
|
||||
}
|
||||
if SupportHttpProtocol("udp") {
|
||||
t.Errorf("UDP is not HTTP protocol")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user