Skip to content

Commit 7a544ba

Browse files
author
Kate Osborn
committed
Add comments and change RecommendedVersion -> SupportedVersion
1 parent 1b34ab1 commit 7a544ba

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

internal/framework/gatewayclass/validate.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import (
1010
)
1111

1212
const (
13+
// BundleVersionAnnotation is the annotation on Gateway API CRDs that contains the installed version.
1314
BundleVersionAnnotation = "gateway.networking.k8s.io/bundle-version"
14-
RecommendedVersion = "v1.0.0"
15+
// SupportedVersion is the supported version of the Gateway API CRDs.
16+
SupportedVersion = "v1.0.0"
1517
)
1618

1719
var gatewayCRDs = map[string]apiVersion{
@@ -30,7 +32,7 @@ func ValidateCRDVersions(
3032
crdMetadata map[types.NamespacedName]*metav1.PartialObjectMetadata,
3133
) ([]conditions.Condition, bool) {
3234
installedAPIVersions := getBundleVersions(crdMetadata)
33-
supportedAPIVersion := parseVersionString(RecommendedVersion)
35+
supportedAPIVersion := parseVersionString(SupportedVersion)
3436

3537
var unsupported, bestEffort bool
3638

@@ -43,11 +45,11 @@ func ValidateCRDVersions(
4345
}
4446

4547
if unsupported {
46-
return conditions.NewGatewayClassUnsupportedVersion(RecommendedVersion), false
48+
return conditions.NewGatewayClassUnsupportedVersion(SupportedVersion), false
4749
}
4850

4951
if bestEffort {
50-
return conditions.NewGatewayClassSupportedVersionBestEffort(RecommendedVersion), true
52+
return conditions.NewGatewayClassSupportedVersionBestEffort(SupportedVersion), true
5153
}
5254

5355
return nil, true

internal/framework/gatewayclass/validate_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func TestValidateCRDVersions(t *testing.T) {
2323
}
2424
}
2525

26-
// Adding patch version to RecommendedVersion to try and avoid having to update these tests with every release.
27-
fields := strings.Split(gatewayclass.RecommendedVersion, ".")
26+
// Adding patch version to SupportedVersion to try and avoid having to update these tests with every release.
27+
fields := strings.Split(gatewayclass.SupportedVersion, ".")
2828
fields[2] = "99"
2929

3030
validVersionWithPatch := createCRDMetadata(strings.Join(fields, "."))
@@ -67,7 +67,7 @@ func TestValidateCRDVersions(t *testing.T) {
6767
{Name: "referencegrants.gateway.networking.k8s.io"}: bestEffortVersion,
6868
},
6969
valid: true,
70-
expConds: conditions.NewGatewayClassSupportedVersionBestEffort(gatewayclass.RecommendedVersion),
70+
expConds: conditions.NewGatewayClassSupportedVersionBestEffort(gatewayclass.SupportedVersion),
7171
},
7272
{
7373
name: "valid; mix of supported and best effort versions",
@@ -78,7 +78,7 @@ func TestValidateCRDVersions(t *testing.T) {
7878
{Name: "referencegrants.gateway.networking.k8s.io"}: validVersionWithPatch,
7979
},
8080
valid: true,
81-
expConds: conditions.NewGatewayClassSupportedVersionBestEffort(gatewayclass.RecommendedVersion),
81+
expConds: conditions.NewGatewayClassSupportedVersionBestEffort(gatewayclass.SupportedVersion),
8282
},
8383
{
8484
name: "invalid; all unsupported versions",
@@ -89,7 +89,7 @@ func TestValidateCRDVersions(t *testing.T) {
8989
{Name: "referencegrants.gateway.networking.k8s.io"}: unsupportedVersion,
9090
},
9191
valid: false,
92-
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.RecommendedVersion),
92+
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.SupportedVersion),
9393
},
9494
{
9595
name: "invalid; mix unsupported and best effort versions",
@@ -100,15 +100,15 @@ func TestValidateCRDVersions(t *testing.T) {
100100
{Name: "referencegrants.gateway.networking.k8s.io"}: bestEffortVersion,
101101
},
102102
valid: false,
103-
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.RecommendedVersion),
103+
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.SupportedVersion),
104104
},
105105
{
106106
name: "invalid; bad version string",
107107
crds: map[types.NamespacedName]*metav1.PartialObjectMetadata{
108108
{Name: "gatewayclasses.gateway.networking.k8s.io"}: createCRDMetadata("v"),
109109
},
110110
valid: false,
111-
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.RecommendedVersion),
111+
expConds: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.SupportedVersion),
112112
},
113113
}
114114

internal/mode/provisioner/handler_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var _ = Describe("handler", func() {
7777
ObjectMeta: metav1.ObjectMeta{
7878
Name: "gatewayclasses.gateway.networking.k8s.io",
7979
Annotations: map[string]string{
80-
gatewayclass.BundleVersionAnnotation: gatewayclass.RecommendedVersion,
80+
gatewayclass.BundleVersionAnnotation: gatewayclass.SupportedVersion,
8181
},
8282
},
8383
}
@@ -210,7 +210,7 @@ var _ = Describe("handler", func() {
210210
LastTransitionTime: fakeClockTime,
211211
Reason: string(gatewayv1.GatewayClassReasonUnsupportedVersion),
212212
Message: fmt.Sprintf("Gateway API CRD versions are not supported. "+
213-
"Please install version %s", gatewayclass.RecommendedVersion),
213+
"Please install version %s", gatewayclass.SupportedVersion),
214214
},
215215
{
216216
Type: string(gatewayv1.GatewayClassReasonSupportedVersion),
@@ -219,7 +219,7 @@ var _ = Describe("handler", func() {
219219
LastTransitionTime: fakeClockTime,
220220
Reason: string(gatewayv1.GatewayClassReasonUnsupportedVersion),
221221
Message: fmt.Sprintf("Gateway API CRD versions are not supported. "+
222-
"Please install version %s", gatewayclass.RecommendedVersion),
222+
"Please install version %s", gatewayclass.SupportedVersion),
223223
},
224224
}
225225
} else {
@@ -239,7 +239,7 @@ var _ = Describe("handler", func() {
239239
LastTransitionTime: fakeClockTime,
240240
Reason: string(gatewayv1.GatewayClassReasonUnsupportedVersion),
241241
Message: fmt.Sprintf("Gateway API CRD versions are not recommended. "+
242-
"Recommended version is %s", gatewayclass.RecommendedVersion),
242+
"Recommended version is %s", gatewayclass.SupportedVersion),
243243
},
244244
}
245245
}

internal/mode/static/state/change_processor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ var _ = Describe("ChangeProcessor", func() {
388388
ObjectMeta: metav1.ObjectMeta{
389389
Name: "gatewayclasses.gateway.networking.k8s.io",
390390
Annotations: map[string]string{
391-
gatewayclass.BundleVersionAnnotation: gatewayclass.RecommendedVersion,
391+
gatewayclass.BundleVersionAnnotation: gatewayclass.SupportedVersion,
392392
},
393393
},
394394
}
@@ -656,7 +656,7 @@ var _ = Describe("ChangeProcessor", func() {
656656
}
657657

658658
expGraph.GatewayClass.Conditions = conditions.NewGatewayClassSupportedVersionBestEffort(
659-
gatewayclass.RecommendedVersion,
659+
gatewayclass.SupportedVersion,
660660
)
661661

662662
changed, graphCfg := processor.Process()

internal/mode/static/state/graph/gatewayclass_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func TestBuildGatewayClass(t *testing.T) {
132132
{Name: "gateways.gateway.networking.k8s.io"}: {
133133
ObjectMeta: metav1.ObjectMeta{
134134
Annotations: map[string]string{
135-
gatewayclass.BundleVersionAnnotation: gatewayclass.RecommendedVersion,
135+
gatewayclass.BundleVersionAnnotation: gatewayclass.SupportedVersion,
136136
},
137137
},
138138
},
@@ -188,7 +188,7 @@ func TestBuildGatewayClass(t *testing.T) {
188188
expected: &GatewayClass{
189189
Source: validGC,
190190
Valid: false,
191-
Conditions: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.RecommendedVersion),
191+
Conditions: conditions.NewGatewayClassUnsupportedVersion(gatewayclass.SupportedVersion),
192192
},
193193
name: "invalid gatewayclass; unsupported version",
194194
},

0 commit comments

Comments
 (0)