Skip to content

Commit 63d27af

Browse files
author
Kate Osborn
committed
Move routeKeyForKind
1 parent 3b69f06 commit 63d27af

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,3 @@ func markConflictedPolicies(policies map[PolicyKey]*Policy, validator validation
283283
}
284284
}
285285
}
286-
287-
func routeKeyForKind(kind v1.Kind, nsname types.NamespacedName) RouteKey {
288-
key := RouteKey{NamespacedName: nsname}
289-
switch kind {
290-
case kinds.HTTPRoute:
291-
key.RouteType = RouteTypeHTTP
292-
case kinds.GRPCRoute:
293-
key.RouteType = RouteTypeGRPC
294-
default:
295-
panic(fmt.Sprintf("unsupported route kind: %s", kind))
296-
}
297-
298-
return key
299-
}

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -805,24 +805,6 @@ func TestMarkConflictedPolicies(t *testing.T) {
805805
}
806806
}
807807

808-
func TestRouteKeyForKind(t *testing.T) {
809-
nsname := types.NamespacedName{Namespace: testNs, Name: "route"}
810-
811-
g := NewWithT(t)
812-
813-
key := routeKeyForKind(kinds.HTTPRoute, nsname)
814-
g.Expect(key).To(Equal(RouteKey{RouteType: RouteTypeHTTP, NamespacedName: nsname}))
815-
816-
key = routeKeyForKind(kinds.GRPCRoute, nsname)
817-
g.Expect(key).To(Equal(RouteKey{RouteType: RouteTypeGRPC, NamespacedName: nsname}))
818-
819-
rk := func() {
820-
_ = routeKeyForKind(kinds.Gateway, nsname)
821-
}
822-
823-
g.Expect(rk).To(Panic())
824-
}
825-
826808
func createPolicyWithAncestors(numAncestors int) policies.Policy {
827809
policy := &policiesfakes.FakePolicy{}
828810

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,3 +576,17 @@ func validateHeaderMatch(
576576

577577
return allErrs
578578
}
579+
580+
func routeKeyForKind(kind v1.Kind, nsname types.NamespacedName) RouteKey {
581+
key := RouteKey{NamespacedName: nsname}
582+
switch kind {
583+
case kinds.HTTPRoute:
584+
key.RouteType = RouteTypeHTTP
585+
case kinds.GRPCRoute:
586+
key.RouteType = RouteTypeGRPC
587+
default:
588+
panic(fmt.Sprintf("unsupported route kind: %s", kind))
589+
}
590+
591+
return key
592+
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,3 +1243,21 @@ func TestValidateHostnames(t *testing.T) {
12431243
})
12441244
}
12451245
}
1246+
1247+
func TestRouteKeyForKind(t *testing.T) {
1248+
nsname := types.NamespacedName{Namespace: testNs, Name: "route"}
1249+
1250+
g := NewWithT(t)
1251+
1252+
key := routeKeyForKind(kinds.HTTPRoute, nsname)
1253+
g.Expect(key).To(Equal(RouteKey{RouteType: RouteTypeHTTP, NamespacedName: nsname}))
1254+
1255+
key = routeKeyForKind(kinds.GRPCRoute, nsname)
1256+
g.Expect(key).To(Equal(RouteKey{RouteType: RouteTypeGRPC, NamespacedName: nsname}))
1257+
1258+
rk := func() {
1259+
_ = routeKeyForKind(kinds.Gateway, nsname)
1260+
}
1261+
1262+
g.Expect(rk).To(Panic())
1263+
}

0 commit comments

Comments
 (0)