Documentation
¶
Overview ¶
Package referencegrant provides test helpers for exercising code against both ReferenceGrant API versions.
ReferenceGrant was promoted from v1beta1 to v1 in Gateway API v1.5.0, and the operator supports clusters serving either. Tests that read ReferenceGrants should therefore run against both versions, seeding their fixtures as the version under test.
This package deliberately does not import pkg/utils/kubernetes: that package's own tests use these helpers, and importing it here would be an import cycle.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsVersion ¶
AsVersion re-types every ReferenceGrant in objs into gv's Go type, leaving every other object untouched so that mixed fixture slices can be passed through as-is.
This matters because the fake client stores objects under the GVK of their Go type: a fixture left as v1 is invisible to a v1beta1 List, so a test that forgets to convert silently exercises an empty grant list and passes for the wrong reason.
The conversion is a plain cast in both directions because v1beta1.ReferenceGrant is declared as `type ReferenceGrant v1.ReferenceGrant` - an identical underlying type under a distinct name. It panics on any other GroupVersion, since that can only be a mistake in the test.
func IsList ¶
func IsList(list client.ObjectList) bool
IsList reports whether list is a ReferenceGrantList of either served version, for interceptors that fail the ReferenceGrant List specifically.
func V1 ¶
func V1() schema.GroupVersion
V1 is the ReferenceGrant API version for tests that are not sensitive to which version the cluster serves, so it just returns v1.
func Versions ¶
func Versions() []schema.GroupVersion
Versions is the set of ReferenceGrant API versions to run a test against. Range over it and pass each version to AsVersion and to the code under test.
Types ¶
This section is empty.