repository
0.0.0-20231105143305-f6f2652a42fe
Repository: https://github.com/fhke/kube-test-utils.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
Test utilities for Kubernetes
This library contains an opinionated set of utilities for running go tests on an ephemeral Kubernetes cluster using kind.
Quickstart
To add a kind cluster to your go tests, create a file called main_test.go
in your test directory containing the following code:
import kindTesting "github.com/fhke/kube-test-utils/pkg/kind/testing"
var clientset = &kubernetes.Clientset{}
func TestMain(m *testing.M) {
os.Exit(
kindTesting.TestMain(
m,
kindTesting.WithClientset(clientset),
),
)
}
The clientset
struct will be set to an admin clientset for the newly created cluster. Once the tests have been run, the kind cluster will be deleted.
Options
n.b. none of these options are required
WithClientset
: Specify a pointer to an empty Kubernetes clientset that will be set for the clusterWithRestConfig
: Specify a pointer to an empty Kubernetes rest config that will be set for the clusterWithKubeconfig
: Specify a path to a file that will contain a kubeconfig for the clusterWithClusterInitFunc
: Specify a function to be run before the tests. This allows you to configure the environment before tests runWithNodeImage
: Specify an alternative kind node imageWithDeleteKubeConfig
: Delete the kubeconfig file after tests have run