tao12345666333 commented on code in PR #1500: URL: https://github.com/apache/apisix-ingress-controller/pull/1500#discussion_r1045901245
########## pkg/providers/utils/scheme.go: ########## @@ -0,0 +1,38 @@ +// 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 utils + +import ( + apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" +) + +var schemeToPortMaps = map[string]int{ + apisixv1.SchemeHTTP: 80, + apisixv1.SchemeHTTPS: 443, + apisixv1.SchemeGRPC: 80, + apisixv1.SchemeGRPCS: 443, +} + +// SchemeToPort scheme converts to the default port +// ref https://github.com/apache/apisix/blob/master/apisix/upstream.lua#L167-L172 Review Comment: ```suggestion // ref https://github.com/apache/apisix/blob/c5fc10d9355a0c177a7532f01c77745ff0639a7f/apisix/upstream.lua#L167-L172 ``` please use permalink ########## pkg/providers/apisix/translation/apisix_upstream.go: ########## @@ -57,35 +55,24 @@ func (t *translator) translateService(namespace, svcName, subset, svcResolveGran return ups, nil } -// TODO: Support Port field func (t *translator) TranslateApisixUpstreamExternalNodes(au *v2.ApisixUpstream) ([]apisixv1.UpstreamNode, error) { var nodes []apisixv1.UpstreamNode for i, node := range au.Spec.ExternalNodes { if node.Type == v2.ExternalTypeDomain { - arr := strings.Split(node.Name, ":") weight := translation.DefaultWeight if node.Weight != nil { weight = *node.Weight } n := apisixv1.UpstreamNode{ - Host: arr[0], + Host: node.Name, Review Comment: this means user only can use `domain`, right? I think we should add some logic to make sure it is correct and also add test case to cover it. For example, if the user fills in https://github.com , how should we handle it? ########## test/e2e/suite-chore/admin_api.go: ########## @@ -18,10 +18,10 @@ package chore import ( "context" + v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" - v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" Review Comment: ditto ########## test/e2e/suite-features/external-sd.go: ########## @@ -23,10 +23,10 @@ import ( "os" "time" + "github.com/apache/apisix-ingress-controller/pkg/config" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" - "github.com/apache/apisix-ingress-controller/pkg/config" Review Comment: this one don't need change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
