Skip to content

Commit ecc2dd8

Browse files
committed
fix: CR Resolution 2
1 parent c1a20ac commit ecc2dd8

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

conformance/tests/gateway-optional-address-value.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"testing"
2222

2323
"github.com/stretchr/testify/require"
24-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2524
"k8s.io/apimachinery/pkg/types"
2625

2726
v1 "sigs.k8s.io/gateway-api/apis/v1"
@@ -65,9 +64,7 @@ var GatewayOptionalAddressValue = suite.ConformanceTest{
6564
err := s.Client.Get(ctx, gwNN, currentGW)
6665
require.NoError(t, err, "error getting Gateway: %v", err)
6766
t.Logf("verifying that the Gateway %s/%s is accepted", gwNN.Namespace, gwNN.Name)
68-
kubernetes.GatewayMustHaveCondition(t, s.Client, s.TimeoutConfig, gwNN, metav1.Condition{
69-
Type: string(v1.GatewayConditionAccepted),
70-
Status: metav1.ConditionTrue,
71-
})
67+
_, err = kubernetes.WaitForGatewayAddress(t, s.Client, s.TimeoutConfig, kubernetes.NewGatewayRef(gwNN, "http"))
68+
require.NoError(t, err, "timed out waiting for Gateway address to be assigned")
7269
},
7370
}

conformance/utils/kubernetes/apply.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,20 @@ func (a Applier) prepareGateway(t *testing.T, uObj *unstructured.Unstructured) {
142142

143143
// This is being done in order to support the injection of implementation-specific address types
144144
// into the test suite
145-
if len(gwspec.Addresses) > 0 && *gwspec.Addresses[0].Type == "PLACEHOLDER_ADDRESS_TYPE" {
146-
addrs := map[string]interface{}{
147-
"type": a.AddressType,
145+
var addresses []interface{}
146+
for _, add := range gwspec.Addresses {
147+
if *add.Type == "PLACEHOLDER_ADDRESS_TYPE" {
148+
addresses = append(addresses, map[string]interface{}{
149+
"type": a.AddressType,
150+
},
151+
)
152+
} else {
153+
addresses = append(addresses, add)
148154
}
149-
err = unstructured.SetNestedSlice(uObj.Object, []interface{}{addrs}, "spec", "addresses")
150-
require.NoError(t, err, "could not overlay address type on Gateway %s/%s", ns, name)
151155
}
156+
err = unstructured.SetNestedSlice(uObj.Object, addresses, "spec", "addresses")
157+
fmt.Println(uObj.Object)
158+
require.NoError(t, err, "could not overlay address type on Gateway %s/%s", ns, name)
152159
}
153160

154161
// prepareGatewayClass adjust the spec.controllerName on the resource

conformance/utils/kubernetes/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con
444444
port = strconv.FormatInt(int64(listener.Port), 10)
445445

446446
for _, address := range gw.Status.Addresses {
447-
if address.Type != nil && (*address.Type == gatewayv1.IPAddressType || *address.Type == v1alpha2.HostnameAddressType) {
447+
if address.Type != nil {
448448
ipAddr = address.Value
449449
return true, nil
450450
}

0 commit comments

Comments
 (0)