kube-test-harness icon indicating copy to clipboard operation
kube-test-harness copied to clipboard

Unable to set custom kubeconfig

Open gandro opened this issue 4 years ago • 0 comments

Setting a custom kubeconfig path is broken. The following code does not pick up the the value of Options.Kubeconfig and falls back on the default instead:

kubeHarness := harness.New(harness.Options{
	Kubeconfig: "my-kubeconfig",
})

os.Exit(kubeHarness.Run(m))

I expected the above code to use "my-kubeconfig", but it ends up ignoring the option and falls back on the value of defaultKubeconfigPath() intsead.

It this seems to be caused by following unconditional call to SetKubeconfig which resets the options field to use the value of defaultKubeconfigPath(): https://github.com/dlespiau/kube-test-harness/blob/254907d8dca3f76f2f181864d70d86f01f648a3a/harness.go#L108-L112

gandro avatar Sep 03 '20 12:09 gandro