Documentation
¶
Index ¶
- Constants
- type Instance
- func (in *Instance) Client(path string, opts client.Options) (client.Client, error)
- func (in *Instance) Config() *rest.Config
- func (in *Instance) CreateWorkspace(ctx context.Context, path string, ...) (logicalcluster.Path, error)
- func (in *Instance) ExternalURL(ctx context.Context, inNetwork string) (string, error)
- func (in *Instance) RESTConfig(path string) *rest.Config
- func (in *Instance) ShardConfig(ctx context.Context, name string) (*rest.Config, error)
- func (in *Instance) ShardNames() []string
- type Options
Constants ¶
const ( // DefaultVersion is the default kcp version deployed by kcp-testcontainers. DefaultVersion = "v0.33.6" // DefaultImage is the default image deployed by kcp-testcontainers. DefaultImage = "ghcr.io/kcp-dev/kcp" // DefaultTag is the default image tag deployed by kcp-testcontainers. DefaultTag = DefaultImage + ":" + DefaultVersion // DefaultStartupTimeout bounds waiting for the whole topology to become ready. DefaultStartupTimeout = 2 * time.Minute )
const ( AliasCache = "cache" AliasFrontProxy = "front-proxy" ShardA = "root" ShardB = "shard-b" )
Network aliases of the components.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
Cache testcontainers.Container
FrontProxy testcontainers.Container
ShardA testcontainers.Container
ShardB testcontainers.Container
// contains filtered or unexported fields
}
Instance is a running sharded kcp: cache-server, two shards and a front-proxy.
func Shared ¶
Shared starts a shared kcp instance. Within a go test run instances are shared across processes via the name.
If the passed options differ then the first process to create the instance wins. There is no drift check.
func (*Instance) Client ¶
Client returns a controller-runtime client for the workspace at path. A nil opts.Scheme defaults to the Kubernetes types plus kcp's tenancy, core and apis groups.
func (*Instance) Config ¶
Config returns an admin rest.Config for the root workspace through the front-proxy.
func (*Instance) CreateWorkspace ¶
func (in *Instance) CreateWorkspace(ctx context.Context, path string, opts ...kcptesting.UnprivilegedWorkspaceOption) (logicalcluster.Path, error)
CreateWorkspace creates the workspace at path, including missing parents. A path segment ending in "-" is used as a GenerateName prefix. The full path with generated names is returned. Options apply only to the last workspace in the path.
func (*Instance) ExternalURL ¶
ExternalURL rewrites an in-network URL, e.g. a virtual workspace URL https://shard-b:6444/services/..., to the host-mapped endpoint.
func (*Instance) RESTConfig ¶
RESTConfig returns an admin rest.Config for the workspace at path through the front-proxy.
func (*Instance) ShardConfig ¶
ShardConfig returns a system:masters rest.Config talking to shard name directly, bypassing the front-proxy.
func (*Instance) ShardNames ¶
ShardNames returns the names of the shards.
type Options ¶
type Options struct {
// Image is the kcp image including tag.
// Defaults to [DefaultTag].
Image string
// StartupTimeout bounds waiting for all components to become ready.
// Defaults to [DefaultStartupTimeout].
StartupTimeout time.Duration
// FeatureGates that should be enabled in the instance.
// Format is <gate>=<bool>, e.g. `CacheAPIs=true`.
FeatureGates []string
// FrontProxy is [testcontainers.ContainerCustomizer] applied to the front-proxy container after settings derived from the other options.
FrontProxy []testcontainers.ContainerCustomizer
// ShardA is [testcontainers.ContainerCustomizer] applied to the first shard container after settings derived from the other options.
ShardA []testcontainers.ContainerCustomizer
// ShardB is [testcontainers.ContainerCustomizer] applied to the second shard container after settings derived from the other options.
ShardB []testcontainers.ContainerCustomizer
// Cache is [testcontainers.ContainerCustomizer] applied to the cache-server container after settings derived from the other options.
Cache []testcontainers.ContainerCustomizer
}
Options configures the kcp topology. Customizers apply to the container request of the named component.
Directories
¶
| Path | Synopsis |
|---|---|
|
tests
|
|
|
e2e/framework
Package framework provides the kcp instances shared by the e2e tests.
|
Package framework provides the kcp instances shared by the e2e tests. |