fake

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fake provides a kubernetesx.Client backed by controller-runtime's fake client for unit tests. It is the pure-Go test surface described in design §4.8: no API server, no envtest, no Kind. Real SSA field-conflict semantics require envtest and live in a follow-up PR.

Use NewClient to build a Client with pre-seeded objects and configurable ServerVersion / Discover / Probe stubs. CRUD and Apply delegate to the underlying controller-runtime fake client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(opts ...Option) kubernetesx.Client

NewClient builds a kubernetesx.Client backed by controller-runtime's fake client. CRUD and Apply run against the in-memory fake; ServerVersion, Discover, and Probe return the configured stubs (or a canned reachable result when unset).

Types

type Option

type Option func(*builder)

Option configures the fake Client.

func WithDiscoverError

func WithDiscoverError(err error) Option

WithDiscoverError makes Discover return err.

func WithDiscoverResult

func WithDiscoverResult(c kubernetesx.Capabilities) Option

WithDiscoverResult sets the canned Capabilities returned by Discover().

func WithDiscoveryClient

func WithDiscoveryClient(d discovery.DiscoveryInterface) Option

WithDiscoveryClient sets the discovery client returned by Discovery().

func WithDynamicClient

func WithDynamicClient(d dynamic.Interface) Option

WithDynamicClient sets the dynamic.Interface returned by Dynamic().

func WithFieldManager

func WithFieldManager(fm string) Option

WithFieldManager sets the default SSA field manager used by Apply.

func WithObjects

func WithObjects(objs ...ctrlclient.Object) Option

WithObjects seeds the fake client with typed objects.

func WithProbeError

func WithProbeError(err error) Option

WithProbeError makes Probe return err instead of the canned result.

func WithProbeResult

func WithProbeResult(r kubernetesx.ProbeResult) Option

WithProbeResult sets the canned ProbeResult returned by Probe(). When WithProbeError is also set, the error wins.

func WithRESTConfig

func WithRESTConfig(cfg *rest.Config) Option

WithRESTConfig sets the *rest.Config returned by RESTConfig(). Tests only.

func WithRuntimeObjects

func WithRuntimeObjects(objs ...runtime.Object) Option

WithRuntimeObjects seeds the fake client with runtime.Object values (useful for objects whose type is not a client.Object at compile time).

func WithScheme

func WithScheme(s *runtime.Scheme) Option

WithScheme sets the runtime.Scheme used by the fake client. Defaults to kubernetesx.DefaultScheme().

func WithServerVersion

func WithServerVersion(v kubernetesx.VersionInfo) Option

WithServerVersion sets the canned VersionInfo returned by ServerVersion().

func WithServerVersionError

func WithServerVersionError(err error) Option

WithServerVersionError makes ServerVersion return err.

Jump to

Keyboard shortcuts

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