referencegrant

package
v2.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func AsVersion(gv schema.GroupVersion, objs []client.Object) []client.Object

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL