storage/kubernetes: don't guess the kubeconfig location and change test env

Using the default KUBECONFIG environment variable to indicate that
the Kubernetes tests should be run lead to cases where developers
accidentally ran the tests. This has now been changed to
"DEX_KUBECONFIG" and documentation hsa been added detailing how to
run these tests.

Additionally, no other storage reads environment variables for its
normal configuration (outside of tests) so the Kubernetes storage
no longer does.

Overall, be less surprising.
This commit is contained in:
Eric Chiang
2016-10-23 07:58:28 -07:00
parent ba9f6c6cd6
commit bc16de0b58
5 changed files with 34 additions and 35 deletions

View File

@@ -8,15 +8,19 @@ import (
"github.com/coreos/dex/storage/conformance"
)
const testKubeConfigEnv = "DEX_KUBECONFIG"
func TestLoadClient(t *testing.T) {
loadClient(t)
}
func loadClient(t *testing.T) *client {
if os.Getenv("KUBECONFIG") == "" {
t.Skip()
config := Config{
KubeConfigFile: os.Getenv(testKubeConfigEnv),
}
if config.KubeConfigFile == "" {
t.Skipf("test environment variable %q not set, skipping", testKubeConfigEnv)
}
var config Config
s, err := config.open()
if err != nil {
t.Fatal(err)