Update to gateway-api v0.2.0

Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
Jean-Baptiste Doumenjou 2021-03-15 09:44:03 +01:00 committed by GitHub
parent 49b46a9a3f
commit 08e6ae07af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1188 additions and 1272 deletions

View file

@ -25,7 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"sigs.k8s.io/service-apis/apis/v1alpha1"
"sigs.k8s.io/gateway-api/apis/v1alpha1"
)
const providerName = "kubernetesgateway"
@ -787,12 +787,12 @@ func loadServices(client Client, namespace string, targets []v1alpha1.HTTPRouteF
return nil, nil, errors.New("service not found")
}
if len(service.Spec.Ports) > 1 && forwardTo.Port == 0 {
if len(service.Spec.Ports) > 1 && forwardTo.Port == nil {
// If the port is unspecified and the backend is a Service
// object consisting of multiple port definitions, the route
// must be dropped from the Gateway. The controller should
// raise the "ResolvedRefs" condition on the Gateway with the
// "DroppedRoutes" reason. The gateway status for this route
// "DroppedRoutes" reason. The gateway status for this route
// should be updated with a condition that describes the error
// more specifically.
log.WithoutContext().Errorf("A multiple ports Kubernetes Service cannot be used if unspecified forwardTo.Port")
@ -804,7 +804,7 @@ func loadServices(client Client, namespace string, targets []v1alpha1.HTTPRouteF
var match bool
for _, p := range service.Spec.Ports {
if forwardTo.Port == 0 || p.Port == int32(forwardTo.Port) {
if forwardTo.Port == nil || p.Port == int32(*forwardTo.Port) {
portName = p.Name
portSpec = p
match = true