Documentation
¶
Overview ¶
Package cutest is the envtest harness for pkg/credentialuse's tests. It is used only by tests, so it may depend on controller-runtime's envtest; the credentialuse package itself must not (§7.1).
envtest is kube-apiserver and etcd only: there is no namespace controller and no garbage collector (§2). Tests play those parts with the helpers here.
Index ¶
Constants ¶
const Group = "credentialuse.test.krateo.io"
Group is the API group of the test CRDs.
Variables ¶
var ( // WidgetGVK is a namespaced test kind, the holder of the tests. WidgetGVK = schema.GroupVersionKind{Group: Group, Version: "v1", Kind: "Widget"} // WidgetGVR is its resource. WidgetGVR = schema.GroupVersionResource{Group: Group, Version: "v1", Resource: "widgets"} // TargetGVK is a namespaced test kind that is protected, like core-provider's // KubernetesTarget (§9). TargetGVK = schema.GroupVersionKind{Group: Group, Version: "v1", Kind: "Target"} // TargetGVR is its resource. TargetGVR = schema.GroupVersionResource{Group: Group, Version: "v1", Resource: "targets"} // SecretGVR is the core Secret resource. SecretGVR = schema.GroupVersionResource{Version: "v1", Resource: "secrets"} )
var ErrNotYet = errors.New("not yet")
ErrNotYet is a convenience for Eventually's f.
Functions ¶
func CRD ¶
func CRD(kind, plural string) *apiextensionsv1.CustomResourceDefinition
CRD builds a namespaced CRD in Group, served and stored at v1, whose objects take any fields.
func Eventually ¶
Eventually calls f until it returns nil or timeout passes, and then fails t with f's last error.
Types ¶
type Env ¶
type Env struct {
Config *rest.Config
Scheme *runtime.Scheme
Client client.Client
Kube kubernetes.Interface
Metadata metadata.Interface
Dynamic dynamic.Interface
// contains filtered or unexported fields
}
An Env is a running envtest API server and admin clients for it.
func Start ¶
Start starts envtest with the Widget and Target CRDs. It returns a nil Env and no error when KUBEBUILDER_ASSETS is unset, so that a test binary runs its other tests; Require then fails or skips the tests that need it.
func (*Env) As ¶
As returns a copy of the admin config that impersonates user, with groups. Every authenticated user is also in system:authenticated.
func (*Env) AsServiceAccount ¶
AsServiceAccount impersonates the service account namespace/name, with the groups the API server gives it.
func (*Env) FinalizeNamespace ¶
FinalizeNamespace plays the namespace controller's last step: it empties the namespace's spec.finalizers through the finalize subresource, then deletes it again so that the API server removes it. The caller has already deleted, or chosen to leave, its content.