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 ¶
- func NewClient(opts ...Option) kubernetesx.Client
- type Option
- func WithDiscoverError(err error) Option
- func WithDiscoverResult(c kubernetesx.Capabilities) Option
- func WithDiscoveryClient(d discovery.DiscoveryInterface) Option
- func WithDynamicClient(d dynamic.Interface) Option
- func WithFieldManager(fm string) Option
- func WithObjects(objs ...ctrlclient.Object) Option
- func WithProbeError(err error) Option
- func WithProbeResult(r kubernetesx.ProbeResult) Option
- func WithRESTConfig(cfg *rest.Config) Option
- func WithRuntimeObjects(objs ...runtime.Object) Option
- func WithScheme(s *runtime.Scheme) Option
- func WithServerVersion(v kubernetesx.VersionInfo) Option
- func WithServerVersionError(err error) Option
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 ¶
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 ¶
WithDynamicClient sets the dynamic.Interface returned by Dynamic().
func WithFieldManager ¶
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 ¶
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 ¶
WithRESTConfig sets the *rest.Config returned by RESTConfig(). Tests only.
func WithRuntimeObjects ¶
WithRuntimeObjects seeds the fake client with runtime.Object values (useful for objects whose type is not a client.Object at compile time).
func WithScheme ¶
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 ¶
WithServerVersionError makes ServerVersion return err.