Documentation
¶
Overview ¶
Package kcp provides a testcontainers-go module running a kcp server.
Index ¶
- Constants
- type ShardedInstance
- func (in *ShardedInstance) Client(ctx context.Context, path string, opts client.Options) (client.Client, error)
- func (in *ShardedInstance) CreateWorkspace(ctx context.Context, path string, opts ...WorkspaceOption) (string, error)
- func (kcp *ShardedInstance) ExternalURL(ctx context.Context, inNetwork string) (string, error)
- func (in *ShardedInstance) Kubeconfig(_ context.Context) ([]byte, error)
- func (in *ShardedInstance) RESTConfig(ctx context.Context, path string) (*rest.Config, error)
- func (kcp *ShardedInstance) Terminate(ctx context.Context, opts ...testcontainers.TerminateOption) error
- type ShardedOption
- type SingleInstance
- func (in *SingleInstance) Client(ctx context.Context, path string, opts client.Options) (client.Client, error)
- func (in *SingleInstance) CreateWorkspace(ctx context.Context, path string, opts ...WorkspaceOption) (string, error)
- func (in *SingleInstance) Kubeconfig(_ context.Context) ([]byte, error)
- func (in *SingleInstance) RESTConfig(ctx context.Context, path string) (*rest.Config, error)
- type WorkspaceOption
Constants ¶
const ( AliasCache = "cache" AliasShard0 = "root" // TODO(ntnn): rename to kcp-0 once root shard is no longer a thing AliasShard1 = "kcp-1" AliasFrontProxy = "front-proxy" )
Network aliases of the sharded topology components.
const DefaultImage = "ghcr.io/kcp-dev/kcp:v0.32.3"
DefaultImage is the image kcp-testcontainer uses when an empty string is passed.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShardedInstance ¶
type ShardedInstance struct {
FrontProxy testcontainers.Container
Shard0 testcontainers.Container
Shard1 testcontainers.Container
Cache testcontainers.Container
// contains filtered or unexported fields
}
ShardedInstance is a full kcp instance with front-proxy, two shards and a cache-server.
func Sharded ¶
func Sharded(ctx context.Context, img string, opts ...ShardedOption) (*ShardedInstance, error)
Sharded starts a sharded kcp instance: cache-server, root shard, shard-1 and front-proxy, all from img on a dedicated network.
func ShardedOnce ¶
func ShardedOnce(ctx context.Context, img string, opts ...ShardedOption) (*ShardedInstance, error)
ShardedOnce is like Sharded but always returns the same ShardedInstance.
func (*ShardedInstance) Client ¶
func (in *ShardedInstance) Client(ctx context.Context, path string, opts client.Options) (client.Client, error)
Client returns a controller-runtime client for the workspace at path.
func (*ShardedInstance) CreateWorkspace ¶
func (in *ShardedInstance) CreateWorkspace(ctx context.Context, path string, opts ...WorkspaceOption) (string, 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 (*ShardedInstance) ExternalURL ¶
ExternalURL rewrites an in-network URL (e.g. a virtual workspace URL https://kcp-1:6444/services/...) to the host-mapped endpoint.
func (*ShardedInstance) Kubeconfig ¶
Kubeconfig returns the admin kubeconfig. The current context is the root workspace.
func (*ShardedInstance) RESTConfig ¶
RESTConfig returns an admin rest.Config for the workspace at path.
func (*ShardedInstance) Terminate ¶
func (kcp *ShardedInstance) Terminate(ctx context.Context, opts ...testcontainers.TerminateOption) error
Terminate tears down all containers and the network.
type ShardedOption ¶
type ShardedOption func(*shardedConfig) error
ShardedOption configures the kcp components.
func WithCacheCustomizers ¶
func WithCacheCustomizers(opts ...testcontainers.ContainerCustomizer) ShardedOption
WithCacheCustomizers applies customizers to the cache-server container.
func WithFrontProxyCustomizers ¶
func WithFrontProxyCustomizers(opts ...testcontainers.ContainerCustomizer) ShardedOption
WithFrontProxyCustomizers applies customizers to the front-proxy container request.
func WithShardCustomizers ¶
func WithShardCustomizers(shard string, opts ...testcontainers.ContainerCustomizer) ShardedOption
WithShardCustomizers applies customizers to the shard container request.
type SingleInstance ¶
type SingleInstance struct {
testcontainers.Container
// contains filtered or unexported fields
}
SingleInstance is a running a single kcp root shard.
func Single ¶
func Single(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*SingleInstance, error)
Single starts a single root-shard kcp container.
func SingleOnce ¶
func SingleOnce(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*SingleInstance, error)
SingleOnce is like Single but always returns the same SingleInstance.
func (*SingleInstance) Client ¶
func (in *SingleInstance) Client(ctx context.Context, path string, opts client.Options) (client.Client, error)
Client returns a controller-runtime client for the workspace at path.
func (*SingleInstance) CreateWorkspace ¶
func (in *SingleInstance) CreateWorkspace(ctx context.Context, path string, opts ...WorkspaceOption) (string, 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 (*SingleInstance) Kubeconfig ¶
Kubeconfig returns the admin kubeconfig. The current context is the root workspace.
type WorkspaceOption ¶
type WorkspaceOption func(ws *tenancyv1alpha1.Workspace)
WorkspaceOption mutates a workspace before creation.
func WithLocation ¶
func WithLocation(w tenancyv1alpha1.WorkspaceLocation) WorkspaceOption
WithLocation sets the location of the workspace.
func WithShard ¶
func WithShard(name string) WorkspaceOption
WithShard schedules the workspace on the given shard.