Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(mods ...KindFixtureModifier) api.Fixture
New returns a fixture that exposes Kubernetes configuration/context information about a KinD cluster. If no such KinD cluster exists, one will be created. If the KinD cluster is created, it is destroyed at the end of the fixture's scope (when Fixture.Stop() is called). The returned fixture exposes some state keys:
- "kube.config" returns the path of the kubeconfig file to use with this KinD cluster
- "kube.context" returns the kubecontext to use with this KinD cluster
Types ¶
type KindFixture ¶
type KindFixture struct {
// ClusterName is the name of the KinD cluster. If not specified, gdt will
// use the default cluster name that KinD uses, which is just "kind"
ClusterName string
// Context is the name of the kubecontext to use. If not specified, gdt
// will use the default KinD context, which is "kind-{cluster_name}"
// See https://github.com/kubernetes-sigs/kind/blob/3610f606516ccaa88aa098465d8c13af70937050/pkg/cluster/internal/kubeconfig/internal/kubeconfig/helpers.go#L23-L26
Context string
// ConfigPath is a path to the v1alpha4 KinD configuration CR
ConfigPath string
// contains filtered or unexported fields
}
KindFixture implements `api.Fixture` and exposes connection/config information about a running KinD cluster.
func (*KindFixture) HasState ¶
func (f *KindFixture) HasState(key string) bool
func (*KindFixture) State ¶
func (f *KindFixture) State(key string) any
func (*KindFixture) Stop ¶
func (f *KindFixture) Stop(ctx context.Context)
type KindFixtureModifier ¶
type KindFixtureModifier func(*KindFixture)
func WithClusterName ¶
func WithClusterName(name string) KindFixtureModifier
WithClusterName modifies the KindFixture's cluster name
func WithConfigPath ¶ added in v1.4.0
func WithConfigPath(path string) KindFixtureModifier
WithConfigPath configures a path to a KinD configuration CR to use
func WithContext ¶
func WithContext(name string) KindFixtureModifier
WithContext modifies the KindFixture's kubecontext
func WithDeleteOnStop ¶ added in v1.4.0
func WithDeleteOnStop() KindFixtureModifier
WithDeleteOnStop instructs gdt-kube to always delete the KinD cluster when the fixture stops. Fixtures are stopped when test scenarios utilizing the fixture have executed all their test steps.
By default, KinD clusters that were already running when the fixture was started are not deleted. This is to prevent the deletion of KinD clusters that were in use outside of a gdt-kube execution. To override this behaviour and always delete the KinD cluster on stop, use the WithDeleteOnStop() modifier.
func WithRetainOnStop ¶ added in v1.4.0
func WithRetainOnStop() KindFixtureModifier
WithRetainOnStop instructs gdt-kube that the KinD cluster should *not* be deleted when the fixture is stopped. Fixtures are stopped when test scenarios utilizing the fixture have executed all their test steps.
By default, KinD clusters that were *not* already running when the fixture was started are deleted when the fixture stops. This is to clean up KinD clusters that were created and used by the gdt-kube execution. To override this behaviour and always retain the KinD cluster on stop, use the WithRetainOnStop() modifier.