Documentation
¶
Overview ¶
Package fake provides in-memory implementations of the control-plane seams (controlplane.Clock, Kubernetes, Registry, Database) for tests. They are deterministic and controllable: time is explicit, state is inspectable, and errors can be injected per operation so engine logic can be exercised against absence and failure without a real cluster, registry, or database (ADR-0010).
The fakes are concurrency-safe so later fault-injection tests can drive them from multiple goroutines under the race detector. This package is licensed Apache-2.0 (see LICENSING.md and ADR-0033); it lives under controlplane/internal so it is importable only by the control plane it supports.
Index ¶
- func URLFor(app string) string
- type Clock
- type ClusterProber
- type Credentials
- func (c *Credentials) Get(key string) (string, bool)
- func (c *Credentials) Set(key, token string)
- func (c *Credentials) SetError(op Op, err error)
- func (c *Credentials) SetToken(ctx context.Context, key, value string) error
- func (c *Credentials) Token(ctx context.Context, key string) (string, error)
- type DNSFactory
- func (f *DNSFactory) DNS(t controlplane.ProviderType, token string) (controlplane.DNSProvider, error)
- func (f *DNSFactory) LastToken() (string, int)
- func (f *DNSFactory) Provider() *DNSProvider
- func (f *DNSFactory) SetDeleteError(err error)
- func (f *DNSFactory) SetEnsureError(err error)
- func (f *DNSFactory) SetFactoryError(err error)
- func (f *DNSFactory) SetVerifyError(err error)
- type DNSProvider
- func (p *DNSProvider) Calls() (ensure, delete int)
- func (p *DNSProvider) DeleteRecord(ctx context.Context, host string) error
- func (p *DNSProvider) EnsureRecord(ctx context.Context, r controlplane.DNSRecord) error
- func (p *DNSProvider) Record(name string) (controlplane.DNSRecord, bool)
- func (p *DNSProvider) VerifyAccess(ctx context.Context) error
- type Database
- func (d *Database) Addon(ctx context.Context, name string) (controlplane.AddonInfo, error)
- func (d *Database) Addons(ctx context.Context) ([]controlplane.AddonInfo, error)
- func (d *Database) AppEnv(ctx context.Context, app string) (map[string]string, error)
- func (d *Database) AppendAudit(ctx context.Context, e controlplane.AuditEntry) error
- func (d *Database) Audit(ctx context.Context, filter controlplane.AuditFilter) ([]controlplane.AuditEntry, error)
- func (d *Database) AuditRows() []controlplane.AuditEntry
- func (d *Database) CreateEnvironment(ctx context.Context, name, namespace string) error
- func (d *Database) DeleteAddon(ctx context.Context, name string) error
- func (d *Database) DeleteReleases(ctx context.Context, app string) error
- func (d *Database) GetBackup(ctx context.Context, id string) (controlplane.Backup, error)
- func (d *Database) GetEnvironment(ctx context.Context, name string) (controlplane.Environment, error)
- func (d *Database) LatestRelease(ctx context.Context, app string) (controlplane.Release, error)
- func (d *Database) ListBackups(ctx context.Context, app string) ([]controlplane.Backup, error)
- func (d *Database) ListEnvironments(ctx context.Context) ([]controlplane.Environment, error)
- func (d *Database) Policy(ctx context.Context) (controlplane.Policy, error)
- func (d *Database) Provider(ctx context.Context, name string) (controlplane.Provider, error)
- func (d *Database) Providers(ctx context.Context) ([]controlplane.Provider, error)
- func (d *Database) RecordBackup(ctx context.Context, b controlplane.Backup) error
- func (d *Database) Release(ctx context.Context, id string) (controlplane.Release, error)
- func (d *Database) Releases(ctx context.Context, app string) ([]controlplane.Release, error)
- func (d *Database) SaveAddon(ctx context.Context, a controlplane.AddonInfo) error
- func (d *Database) SaveProvider(ctx context.Context, p controlplane.Provider) error
- func (d *Database) SaveRelease(ctx context.Context, r controlplane.Release) error
- func (d *Database) SetAppEnv(ctx context.Context, app, key, value string) error
- func (d *Database) SetBackupStatus(ctx context.Context, id string, status controlplane.BackupStatus, ...) error
- func (d *Database) SetError(op Op, err error)
- func (d *Database) SetGuardrail(ctx context.Context, code controlplane.GuardrailCode, ...) error
- func (d *Database) SetPolicy(p controlplane.Policy)
- func (d *Database) UnsetAppEnv(ctx context.Context, app, key string) error
- type IDs
- type Kubernetes
- func (k *Kubernetes) AddonReady(ctx context.Context, name string) (bool, error)
- func (k *Kubernetes) ApplyAutoscaler(ctx context.Context, app string, spec controlplane.AutoscaleSpec) error
- func (k *Kubernetes) ApplyWorkload(ctx context.Context, spec controlplane.WorkloadSpec) error
- func (k *Kubernetes) Autoscaler(app string) (controlplane.AutoscaleSpec, bool)
- func (k *Kubernetes) AutoscalerActive(ctx context.Context, app string) (bool, error)
- func (k *Kubernetes) BackupJobs() []backupCall
- func (k *Kubernetes) DeleteAddon(ctx context.Context, name string) error
- func (k *Kubernetes) DeleteAutoscaler(ctx context.Context, app string) error
- func (k *Kubernetes) DeleteWorkload(ctx context.Context, app string) error
- func (k *Kubernetes) DeployAddon(ctx context.Context, spec controlplane.AddonSpec) (controlplane.AddonInfo, error)
- func (k *Kubernetes) Expose(ctx context.Context, spec controlplane.ExposeSpec) error
- func (k *Kubernetes) Exposure(app string) (controlplane.ExposeSpec, bool)
- func (k *Kubernetes) ExposureStatus(ctx context.Context, app string) (controlplane.ExposureStatus, error)
- func (k *Kubernetes) ListWorkloads(ctx context.Context) ([]controlplane.WorkloadStatus, error)
- func (k *Kubernetes) Logs(ctx context.Context, app string, opts controlplane.LogOptions) ([]controlplane.LogLine, error)
- func (k *Kubernetes) MetricsAPIAvailable(ctx context.Context) (bool, error)
- func (k *Kubernetes) RestartWorkload(ctx context.Context, app string, at time.Time) error
- func (k *Kubernetes) RestartedAt(app string) (time.Time, bool)
- func (k *Kubernetes) RestoreJobs() []backupCall
- func (k *Kubernetes) RunBackupJob(ctx context.Context, app, backupID string) (int64, error)
- func (k *Kubernetes) RunJob(ctx context.Context, spec controlplane.RunSpec) (controlplane.RunResult, error)
- func (k *Kubernetes) RunJobs() []runCall
- func (k *Kubernetes) RunRestoreJob(ctx context.Context, app, backupID string) error
- func (k *Kubernetes) ScaleWorkload(ctx context.Context, app string, replicas int32) error
- func (k *Kubernetes) SecretKeys(ctx context.Context, app string) ([]string, error)
- func (k *Kubernetes) SecretValue(app, key string) (string, bool)
- func (k *Kubernetes) SecretValueInNamespace(ns, app, key string) (string, bool)
- func (k *Kubernetes) SetAutoscalerActive(app string, active bool)
- func (k *Kubernetes) SetBackupSize(n int64)
- func (k *Kubernetes) SetCertReady(app string, ready bool)
- func (k *Kubernetes) SetError(op Op, err error)
- func (k *Kubernetes) SetImagePullFailure(app, reason string)
- func (k *Kubernetes) SetImagePullFailureMessage(app, reason, message string)
- func (k *Kubernetes) SetIngressAddress(app, addr string)
- func (k *Kubernetes) SetLogs(app string, lines []controlplane.LogLine)
- func (k *Kubernetes) SetMetricsAvailable(available bool)
- func (k *Kubernetes) SetReady(app string, ready int32)
- func (k *Kubernetes) SetRunResult(res controlplane.RunResult)
- func (k *Kubernetes) SetSecret(app, key, value string)
- func (k *Kubernetes) SetSecretValue(ctx context.Context, app, key, value string) error
- func (k *Kubernetes) Spec(app string) (controlplane.WorkloadSpec, bool)
- func (k *Kubernetes) SpecInNamespace(ns, app string) (controlplane.WorkloadSpec, bool)
- func (k *Kubernetes) Unexpose(ctx context.Context, app string) error
- func (k *Kubernetes) UnsetSecretKey(ctx context.Context, app, key string) error
- func (k *Kubernetes) WithNamespace(ns string) controlplane.Kubernetes
- func (k *Kubernetes) WorkloadStatus(ctx context.Context, app string) (controlplane.WorkloadStatus, error)
- type Op
- type Provisioner
- func (p *Provisioner) DropAppDatabase(_ context.Context, app string) error
- func (p *Provisioner) Dropped() []string
- func (p *Provisioner) EnsureAppDatabase(_ context.Context, app string) (string, error)
- func (p *Provisioner) Ensured() []string
- func (p *Provisioner) SetDropError(err error)
- func (p *Provisioner) SetEnsureError(err error)
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock is a controllable controlplane.Clock. It does not advance on its own; tests move it with Advance or Set, so every time-dependent result is deterministic.
type ClusterProber ¶
type ClusterProber struct {
Caps controlplane.ClusterCapabilities
Err error
}
ClusterProber is an in-memory controlplane.ClusterProber: it returns a canned capability report (ADR-0034) so engine tests can drive ClusterCapabilities without a cluster. The cluster-derived fields are seeded; the engine fills the DNS field from the providers registry. An error can be injected to exercise the failure path.
func NewClusterProber ¶
func NewClusterProber(caps controlplane.ClusterCapabilities) *ClusterProber
NewClusterProber returns a prober reporting caps.
func (*ClusterProber) DetectCapabilities ¶
func (p *ClusterProber) DetectCapabilities(_ context.Context) (controlplane.ClusterCapabilities, error)
DetectCapabilities returns the seeded report (or the injected error).
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
Credentials is an in-memory controlplane.Credentials. Tests seed tokens with Set, read what SetToken wrote with Get, and inject failure with SetError (OpToken, OpSetToken).
func NewCredentials ¶
func NewCredentials() *Credentials
NewCredentials returns an empty fake credential store.
func (*Credentials) Get ¶
func (c *Credentials) Get(key string) (string, bool)
Get returns the token stored under key and whether it is present, so a test can assert what SetToken wrote into the credential store.
func (*Credentials) Set ¶
func (c *Credentials) Set(key, token string)
Set records that key holds token, seeding the store directly (e.g. a token a prior set wrote).
func (*Credentials) SetError ¶
func (c *Credentials) SetError(op Op, err error)
SetError makes the Token op return err until cleared with SetError(OpToken, nil).
func (*Credentials) SetToken ¶
func (c *Credentials) SetToken(ctx context.Context, key, value string) error
SetToken upserts key=value into the in-memory store, modelling burrowd writing the token it received over the control-plane API into burrow-credentials (ADR-0030). An OpSetToken error can be injected to exercise the failure path.
type DNSFactory ¶
type DNSFactory struct {
// contains filtered or unexported fields
}
DNSFactory is an in-memory controlplane.DNSFactory. Every DNS(...) returns the same shared provider (so a test can configure and inspect it), unless SetFactoryError makes DNS(...) itself fail. It records the (type, token) pairs it was asked for, so a test can assert the engine read and passed the right token.
func NewDNSFactory ¶
func NewDNSFactory() *DNSFactory
NewDNSFactory returns a factory whose shared provider accepts any token.
func (*DNSFactory) DNS ¶
func (f *DNSFactory) DNS(t controlplane.ProviderType, token string) (controlplane.DNSProvider, error)
func (*DNSFactory) LastToken ¶
func (f *DNSFactory) LastToken() (string, int)
LastToken returns the token most recently passed to DNS, and how many times DNS was called.
func (*DNSFactory) Provider ¶
func (f *DNSFactory) Provider() *DNSProvider
Provider returns the shared provider the factory hands out, for configuration and inspection.
func (*DNSFactory) SetDeleteError ¶
func (f *DNSFactory) SetDeleteError(err error)
SetDeleteError makes the shared provider fail DeleteRecord with err.
func (*DNSFactory) SetEnsureError ¶
func (f *DNSFactory) SetEnsureError(err error)
SetEnsureError makes the shared provider fail EnsureRecord with err.
func (*DNSFactory) SetFactoryError ¶
func (f *DNSFactory) SetFactoryError(err error)
SetFactoryError makes DNS(...) return err without handing out a provider.
func (*DNSFactory) SetVerifyError ¶
func (f *DNSFactory) SetVerifyError(err error)
SetVerifyError makes the shared provider reject VerifyAccess with err.
type DNSProvider ¶
type DNSProvider struct {
// contains filtered or unexported fields
}
DNSProvider is an in-memory controlplane.DNSProvider. VerifyAccess and the record operations return their configured error (nil = success); successful EnsureRecord/ DeleteRecord update an inspectable in-memory record set.
func (*DNSProvider) Calls ¶
func (p *DNSProvider) Calls() (ensure, delete int)
Calls returns how many times EnsureRecord and DeleteRecord were invoked.
func (*DNSProvider) DeleteRecord ¶
func (p *DNSProvider) DeleteRecord(ctx context.Context, host string) error
func (*DNSProvider) EnsureRecord ¶
func (p *DNSProvider) EnsureRecord(ctx context.Context, r controlplane.DNSRecord) error
func (*DNSProvider) Record ¶
func (p *DNSProvider) Record(name string) (controlplane.DNSRecord, bool)
Record returns the record currently held for name, and whether one exists.
func (*DNSProvider) VerifyAccess ¶
func (p *DNSProvider) VerifyAccess(ctx context.Context) error
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an in-memory controlplane.Database. It stores releases by ID and tracks per-app save order so LatestRelease and Releases are deterministic. Records are deep copied in and out, so callers never share Env/Command memory with the store — the same isolation a real database gives. Errors can be injected per operation.
func NewDatabase ¶
func NewDatabase() *Database
NewDatabase returns an empty fake database with the default guardrail policy.
func (*Database) AppEnv ¶
AppEnv returns a copy of the non-secret env store for app. An app with no env yields an empty map and no error.
func (*Database) AppendAudit ¶
func (d *Database) AppendAudit(ctx context.Context, e controlplane.AuditEntry) error
AppendAudit appends one audit row in append order (the append-only log). It deep-copies the args map so the store never aliases the caller's map, matching a real database.
func (*Database) Audit ¶
func (d *Database) Audit(ctx context.Context, filter controlplane.AuditFilter) ([]controlplane.AuditEntry, error)
Audit returns the rows matching filter, newest first, capped by filter.Limit (a default when unset). The filter clauses are ANDed.
func (*Database) AuditRows ¶
func (d *Database) AuditRows() []controlplane.AuditEntry
AuditRows returns a copy of every appended audit row in append order, for tests asserting on what the engine recorded.
func (*Database) CreateEnvironment ¶ added in v0.7.0
CreateEnvironment registers a named environment, rejecting a duplicate name with an ErrInvalid-wrapped error (the name is the primary key), matching the store.
func (*Database) DeleteAddon ¶
func (*Database) DeleteReleases ¶
DeleteReleases removes every release record for app, including its save-order tracking. Deleting the releases of an app that has none is a no-op, not an error.
func (*Database) GetEnvironment ¶ added in v0.7.0
func (d *Database) GetEnvironment(ctx context.Context, name string) (controlplane.Environment, error)
GetEnvironment returns the registered environment with the given name, or ErrNotFound.
func (*Database) LatestRelease ¶
func (*Database) ListBackups ¶
ListBackups returns recorded backups newest first (reverse record order). An empty app lists all.
func (*Database) ListEnvironments ¶ added in v0.7.0
func (d *Database) ListEnvironments(ctx context.Context) ([]controlplane.Environment, error)
ListEnvironments returns the registered environments ordered by name. The synthesized `default` environment is not stored here; the engine prepends it.
func (*Database) RecordBackup ¶
RecordBackup persists a new backup row, tracking record order for deterministic listing. An existing row with the same ID is overwritten in place.
func (*Database) SaveAddon ¶
SaveAddon upserts an add-on by name. It stores only the non-secret registry entry; Ready is a live property and is not persisted here.
func (*Database) SaveProvider ¶
SaveProvider upserts a provider by name. It stores only the non-secret registry entry.
func (*Database) SaveRelease ¶
func (*Database) SetBackupStatus ¶
func (d *Database) SetBackupStatus(ctx context.Context, id string, status controlplane.BackupStatus, sizeBytes int64) error
SetBackupStatus updates a recorded backup's status and size. An unknown id is ErrNotFound.
func (*Database) SetGuardrail ¶
func (d *Database) SetGuardrail(ctx context.Context, code controlplane.GuardrailCode, disp controlplane.Disposition) error
SetGuardrail persists one guardrail's disposition, overlaying it on the current policy.
func (*Database) SetPolicy ¶
func (d *Database) SetPolicy(p controlplane.Policy)
SetPolicy replaces the whole guardrail policy. It is a test helper for arranging a specific policy before exercising the engine.
type IDs ¶
type IDs struct {
// contains filtered or unexported fields
}
IDs is a deterministic controlplane.IDSource that hands out "r1", "r2", ... so tests can predict release identifiers.
type Kubernetes ¶
type Kubernetes struct {
// contains filtered or unexported fields
}
Kubernetes is an in-memory controlplane.Kubernetes. Applied workloads are stored and inspectable; by default a workload is healthy (ready == desired) immediately, and tests can override readiness (SetReady) and seed logs (SetLogs) to model partial or failed rollouts. Errors can be injected per operation with SetError.
Per-app resources (workloads, exposures, per-app Secrets) are keyed by namespace so the fake can model namespace-per-environment (ADR-0035 phase 2): WithNamespace returns a view whose app operations land under a different namespace, sharing the same backing maps and lock. The introspection helpers (Spec, SecretValue, …) read the receiver view's namespace; the namespace-qualified variants (SpecInNamespace, SecretValueInNamespace) read a named one.
func NewKubernetes ¶
func NewKubernetes() *Kubernetes
NewKubernetes returns an empty fake cluster. metrics-server is reported present by default (the common case, where an applied HPA scales); a test models a cluster without it via SetMetricsAvailable(false).
func (*Kubernetes) AddonReady ¶
AddonReady reports whether the named add-on was deployed (and thus ready) in this fake cluster. A deployed add-on is ready by default; an unknown one is not ready.
func (*Kubernetes) ApplyAutoscaler ¶ added in v0.8.0
func (k *Kubernetes) ApplyAutoscaler(ctx context.Context, app string, spec controlplane.AutoscaleSpec) error
func (*Kubernetes) ApplyWorkload ¶
func (k *Kubernetes) ApplyWorkload(ctx context.Context, spec controlplane.WorkloadSpec) error
func (*Kubernetes) Autoscaler ¶ added in v0.8.0
func (k *Kubernetes) Autoscaler(app string) (controlplane.AutoscaleSpec, bool)
Autoscaler returns the applied HPA spec for app in this view's namespace and whether one exists — test-only introspection of ApplyAutoscaler/DeleteAutoscaler.
func (*Kubernetes) AutoscalerActive ¶ added in v0.8.0
AutoscalerActive reports whether app has an applied HPA in this view's namespace — an entry set by ApplyAutoscaler or SetAutoscalerActive and not since deleted. A missing HPA is inactive (false, nil), mirroring the real adapter.
func (*Kubernetes) BackupJobs ¶
func (k *Kubernetes) BackupJobs() []backupCall
BackupJobs returns the (app, backupID) pairs RunBackupJob was called with, in order.
func (*Kubernetes) DeleteAddon ¶
func (k *Kubernetes) DeleteAddon(ctx context.Context, name string) error
func (*Kubernetes) DeleteAutoscaler ¶ added in v0.8.0
func (k *Kubernetes) DeleteAutoscaler(ctx context.Context, app string) error
func (*Kubernetes) DeleteWorkload ¶
func (k *Kubernetes) DeleteWorkload(ctx context.Context, app string) error
func (*Kubernetes) DeployAddon ¶
func (k *Kubernetes) DeployAddon(ctx context.Context, spec controlplane.AddonSpec) (controlplane.AddonInfo, error)
func (*Kubernetes) Expose ¶
func (k *Kubernetes) Expose(ctx context.Context, spec controlplane.ExposeSpec) error
func (*Kubernetes) Exposure ¶
func (k *Kubernetes) Exposure(app string) (controlplane.ExposeSpec, bool)
Exposure returns the recorded exposure for app and whether one exists.
func (*Kubernetes) ExposureStatus ¶
func (k *Kubernetes) ExposureStatus(ctx context.Context, app string) (controlplane.ExposureStatus, error)
func (*Kubernetes) ListWorkloads ¶
func (k *Kubernetes) ListWorkloads(ctx context.Context) ([]controlplane.WorkloadStatus, error)
func (*Kubernetes) Logs ¶
func (k *Kubernetes) Logs(ctx context.Context, app string, opts controlplane.LogOptions) ([]controlplane.LogLine, error)
func (*Kubernetes) MetricsAPIAvailable ¶ added in v0.8.0
func (k *Kubernetes) MetricsAPIAvailable(ctx context.Context) (bool, error)
func (*Kubernetes) RestartWorkload ¶
func (*Kubernetes) RestartedAt ¶
func (k *Kubernetes) RestartedAt(app string) (time.Time, bool)
RestartedAt returns the last RestartWorkload timestamp for app and whether the workload was ever rolled by a restart bump.
func (*Kubernetes) RestoreJobs ¶
func (k *Kubernetes) RestoreJobs() []backupCall
RestoreJobs returns the (app, backupID) pairs RunRestoreJob was called with, in order.
func (*Kubernetes) RunBackupJob ¶
func (*Kubernetes) RunJob ¶ added in v0.12.0
func (k *Kubernetes) RunJob(ctx context.Context, spec controlplane.RunSpec) (controlplane.RunResult, error)
func (*Kubernetes) RunJobs ¶ added in v0.12.0
func (k *Kubernetes) RunJobs() []runCall
RunJobs returns the recorded RunJob invocations, in order, so a test can assert the engine drove the one-off command Job with the app's current image, command, TTL, and target namespace.
func (*Kubernetes) RunRestoreJob ¶
func (k *Kubernetes) RunRestoreJob(ctx context.Context, app, backupID string) error
func (*Kubernetes) ScaleWorkload ¶
func (*Kubernetes) SecretKeys ¶
func (*Kubernetes) SecretValue ¶
func (k *Kubernetes) SecretValue(app, key string) (string, bool)
SecretValue returns the stored value under key for app in this view's namespace and whether it is present — test-only introspection (the real seam never exposes values).
func (*Kubernetes) SecretValueInNamespace ¶ added in v0.7.0
func (k *Kubernetes) SecretValueInNamespace(ns, app, key string) (string, bool)
SecretValueInNamespace is SecretValue scoped to a named namespace, so a test can assert a per-env secret landed in the environment's namespace (ADR-0035 phase 2).
func (*Kubernetes) SetAutoscalerActive ¶ added in v0.8.0
func (k *Kubernetes) SetAutoscalerActive(app string, active bool)
SetAutoscalerActive seeds (or clears) an active HorizontalPodAutoscaler for app in this view's namespace, so a test can model an app the autoscaler owns without applying a full AutoscaleSpec through the engine. It shares the backing store with ApplyAutoscaler/DeleteAutoscaler, so both paths agree on what AutoscalerActive reports.
func (*Kubernetes) SetBackupSize ¶
func (k *Kubernetes) SetBackupSize(n int64)
SetBackupSize sets the byte size RunBackupJob reports, modelling the dump container reporting it.
func (*Kubernetes) SetCertReady ¶
func (k *Kubernetes) SetCertReady(app string, ready bool)
SetCertReady sets whether the requested TLS certificate reported for app's exposure has been issued, modelling cert-manager having populated the certificate Secret.
func (*Kubernetes) SetError ¶
func (k *Kubernetes) SetError(op Op, err error)
SetError makes op return err until cleared with SetError(op, nil).
func (*Kubernetes) SetImagePullFailure ¶ added in v0.8.0
func (k *Kubernetes) SetImagePullFailure(app, reason string)
SetImagePullFailure models a workload whose pod cannot pull its image: it drops ready to 0 (so the workload is not Available) and records reason as the blocking pod waiting reason, so WorkloadStatus/ListWorkloads report the same actionable Issue the real adapter attaches on a genuine ImagePullBackOff. Pass a non-image-pull reason (or "") to clear it. It is a no-op if app has no workload.
func (*Kubernetes) SetImagePullFailureMessage ¶ added in v0.8.0
func (k *Kubernetes) SetImagePullFailureMessage(app, reason, message string)
SetImagePullFailureMessage is SetImagePullFailure with the kubelet's waiting message attached, so a test can drive the not-found vs unauthorized Issue distinction (ADR-0040).
func (*Kubernetes) SetIngressAddress ¶
func (k *Kubernetes) SetIngressAddress(app, addr string)
SetIngressAddress sets the controller-assigned external address reported for app's exposure, modelling the ingress controller having processed the Ingress.
func (*Kubernetes) SetLogs ¶
func (k *Kubernetes) SetLogs(app string, lines []controlplane.LogLine)
SetLogs replaces the stored log lines for app.
func (*Kubernetes) SetMetricsAvailable ¶ added in v0.8.0
func (k *Kubernetes) SetMetricsAvailable(available bool)
SetMetricsAvailable sets whether MetricsAPIAvailable reports metrics-server present, modelling a cluster with or without it. It shares the flag across namespace views (like the other pointer state), so a test sets it once on the base fake.
func (*Kubernetes) SetReady ¶
func (k *Kubernetes) SetReady(app string, ready int32)
SetReady overrides the ready replica count for app, modelling a partial rollout. It is a no-op if app has no workload.
func (*Kubernetes) SetRunResult ¶ added in v0.12.0
func (k *Kubernetes) SetRunResult(res controlplane.RunResult)
SetRunResult sets the canned RunResult the next RunJob calls return, modelling a command's captured output and exit code (ADR-0048). A test seeds a non-zero ExitCode to assert it surfaces as a structured result rather than a transport error.
func (*Kubernetes) SetSecret ¶
func (k *Kubernetes) SetSecret(app, key, value string)
SetSecret seeds app's per-app Secret with key=value, modelling a `secret set` done over the kubeconfig path (which never goes through this engine seam). Tests use it to set up list/unset.
func (*Kubernetes) SetSecretValue ¶
func (k *Kubernetes) SetSecretValue(ctx context.Context, app, key, value string) error
SetSecretValue upserts key=value into app's per-app Secret map (ADR-0029), modelling burrowd writing the value it received over the control-plane API. SecretKeys/SecretValue read the same map. An OpSetSecretValue error can be injected to exercise the failure path.
func (*Kubernetes) Spec ¶
func (k *Kubernetes) Spec(app string) (controlplane.WorkloadSpec, bool)
Spec returns the currently applied spec for app in this view's namespace and whether a workload exists.
func (*Kubernetes) SpecInNamespace ¶ added in v0.7.0
func (k *Kubernetes) SpecInNamespace(ns, app string) (controlplane.WorkloadSpec, bool)
SpecInNamespace is Spec scoped to a named namespace, so a test can assert a deploy routed to an environment's namespace (ADR-0035 phase 2).
func (*Kubernetes) UnsetSecretKey ¶
func (k *Kubernetes) UnsetSecretKey(ctx context.Context, app, key string) error
func (*Kubernetes) WithNamespace ¶ added in v0.7.0
func (k *Kubernetes) WithNamespace(ns string) controlplane.Kubernetes
WithNamespace returns a view of the fake whose per-app operations act in ns, sharing the same backing state and lock (ADR-0035 phase 2). Add-on operations are unaffected.
func (*Kubernetes) WorkloadStatus ¶
func (k *Kubernetes) WorkloadStatus(ctx context.Context, app string) (controlplane.WorkloadStatus, error)
type Op ¶
type Op string
Op names a seam method for error injection. Pass one to a fake's SetError to make that method return the given error until it is cleared (SetError(op, nil)).
const ( OpApply Op = "ApplyWorkload" OpStatus Op = "WorkloadStatus" OpScale Op = "ScaleWorkload" OpLogs Op = "Logs" OpDelete Op = "DeleteWorkload" OpExpose Op = "Expose" OpUnexpose Op = "Unexpose" OpExposureStatus Op = "ExposureStatus" OpSecretKeys Op = "SecretKeys" OpSetSecretValue Op = "SetSecretValue" OpUnsetSecretKey Op = "UnsetSecretKey" OpRestartWorkload Op = "RestartWorkload" OpApplyAutoscaler Op = "ApplyAutoscaler" OpDeleteAutoscaler Op = "DeleteAutoscaler" OpAutoscalerActive Op = "AutoscalerActive" OpMetricsAPIAvailable Op = "MetricsAPIAvailable" OpAddonReady Op = "AddonReady" OpSaveAddon Op = "SaveAddon" OpAddon Op = "Addon" OpAddons Op = "Addons" OpDeleteAddon Op = "DeleteAddon" OpSaveRelease Op = "SaveRelease" OpRelease Op = "Release" OpLatestRelease Op = "LatestRelease" OpReleases Op = "Releases" OpDeleteReleases Op = "DeleteReleases" OpAppEnv Op = "AppEnv" OpSetAppEnv Op = "SetAppEnv" OpUnsetAppEnv Op = "UnsetAppEnv" OpPolicy Op = "Policy" OpSetGuardrail Op = "SetGuardrail" OpSaveProvider Op = "SaveProvider" OpProvider Op = "Provider" OpProviders Op = "Providers" OpToken Op = "Token" OpSetToken Op = "SetToken" OpDNS Op = "DNS" OpVerifyAccess Op = "VerifyAccess" OpAppendAudit Op = "AppendAudit" OpAudit Op = "Audit" OpRecordBackup Op = "RecordBackup" OpSetBackupStatus Op = "SetBackupStatus" OpListBackups Op = "ListBackups" OpGetBackup Op = "GetBackup" OpRunBackupJob Op = "RunBackupJob" OpRunRestoreJob Op = "RunRestoreJob" OpRunJob Op = "RunJob" OpCreateEnvironment Op = "CreateEnvironment" OpListEnvironments Op = "ListEnvironments" OpGetEnvironment Op = "GetEnvironment" )
type Provisioner ¶
type Provisioner struct {
// contains filtered or unexported fields
}
Provisioner is an in-memory controlplane.DatabaseProvisioner. It records the apps it provisioned and returns a deterministic connection string per app, so an attach test can assert the engine called EnsureAppDatabase and threaded the URL into the secret path without standing up Postgres. Errors can be injected to exercise the failure path.
func NewProvisioner ¶
func NewProvisioner() *Provisioner
NewProvisioner returns an empty fake provisioner.
func (*Provisioner) DropAppDatabase ¶
func (p *Provisioner) DropAppDatabase(_ context.Context, app string) error
func (*Provisioner) Dropped ¶
func (p *Provisioner) Dropped() []string
Dropped returns the apps DropAppDatabase was called with, in order.
func (*Provisioner) EnsureAppDatabase ¶
func (*Provisioner) Ensured ¶
func (p *Provisioner) Ensured() []string
Ensured returns the apps EnsureAppDatabase was called with, in order.
func (*Provisioner) SetDropError ¶
func (p *Provisioner) SetDropError(err error)
SetDropError makes DropAppDatabase return err (nil clears it).
func (*Provisioner) SetEnsureError ¶
func (p *Provisioner) SetEnsureError(err error)
SetEnsureError makes EnsureAppDatabase return err (nil clears it).
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is an in-memory controlplane.Resolver. Seed what a host resolves to with Set; an unseeded host returns an error, modelling NXDOMAIN.