@@ -4,13 +4,7 @@ import (
44 "bytes"
55 "context"
66 "fmt"
7- "log"
8- "net/http"
9- "os"
10- "path/filepath"
11-
127 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
13-
148 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
159 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1610 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -20,6 +14,10 @@ import (
2014 "k8s.io/client-go/kubernetes"
2115 _ "k8s.io/client-go/plugin/pkg/client/auth"
2216 restclient "k8s.io/client-go/rest"
17+ "log"
18+ "net/http"
19+ "os"
20+ "path/filepath"
2321
2422 "k8s.io/client-go/tools/clientcmd"
2523 clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
@@ -90,6 +88,7 @@ func Provider() *schema.Provider {
9088 "config_paths" : {
9189 Type : schema .TypeList ,
9290 Elem : & schema.Schema {Type : schema .TypeString },
91+ DefaultFunc : configPathsEnv ,
9392 Optional : true ,
9493 Description : "A list of paths to kube config files. Can be set with KUBE_CONFIG_PATHS environment variable." ,
9594 // This should conflict with every attribute except for "insecure", since all of these options will be read from the kubeconfig.
@@ -221,6 +220,21 @@ func Provider() *schema.Provider {
221220 return p
222221}
223222
223+ // configPathsEnv fetches the value of the environment variable KUBE_CONFIG_PATHS, if defined.
224+ func configPathsEnv () (interface {}, error ) {
225+ value , exists := os .LookupEnv ("KUBE_CONFIG_PATHS" )
226+ if exists {
227+ log .Print ("[DEBUG] using environment variable KUBE_CONFIG_PATHS to define config_paths" )
228+ log .Printf ("[DEBUG] value of KUBE_CONFIG_PATHS: %v" , value )
229+ }
230+ pathList := filepath .SplitList (value )
231+ configPaths := new ([]interface {})
232+ for _ , p := range pathList {
233+ * configPaths = append (* configPaths , p )
234+ }
235+ return * configPaths , nil
236+ }
237+
224238type KubeClientsets interface {
225239 MainClientset () (* kubernetes.Clientset , error )
226240 AggregatorClientset () (* aggregator.Clientset , error )
0 commit comments