77 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
88 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
99 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1110 "github.com/mitchellh/go-homedir"
1211 apimachineryschema "k8s.io/apimachinery/pkg/runtime/schema"
1312 "k8s.io/client-go/discovery"
@@ -28,15 +27,13 @@ func Provider() *schema.Provider {
2827 p := & schema.Provider {
2928 Schema : map [string ]* schema.Schema {
3029 "host" : {
31- Type : schema .TypeString ,
32- Optional : true ,
33- DefaultFunc : schema .EnvDefaultFunc ("KUBE_HOST" , nil ),
34- Description : "The hostname (in form of URI) of Kubernetes master." ,
35- ConflictsWith : []string {"config_path" , "config_paths" },
36- ValidateDiagFunc : validation .ToDiagFunc (validation .IsURLWithHTTPorHTTPS ),
37- // TODO: enable this when AtLeastOneOf works with optional attributes.
38- // Currently, it will require at least one of the following keys to be set, even if 'host' isn't set.
39- // AtLeastOneOf: []string{"token", "exec", "username", "password", "client_certificate", "client_key"},
30+ Type : schema .TypeString ,
31+ Optional : true ,
32+ //DefaultFunc: schema.EnvDefaultFunc("KUBE_HOST", nil),
33+ Description : "The hostname (in form of URI) of Kubernetes master." ,
34+ //ConflictsWith: []string{"config_path", "config_paths"},
35+ //ValidateDiagFunc: validation.ToDiagFunc(validation.IsURLWithHTTPorHTTPS),
36+ AtLeastOneOf : []string {"token" , "exec" , "username" , "password" , "client_certificate" , "client_key" },
4037 },
4138 "username" : {
4239 Type : schema .TypeString ,
@@ -226,13 +223,14 @@ func configPathsEnv() (interface{}, error) {
226223 if exists {
227224 log .Print ("[DEBUG] using environment variable KUBE_CONFIG_PATHS to define config_paths" )
228225 log .Printf ("[DEBUG] value of KUBE_CONFIG_PATHS: %v" , value )
226+ pathList := filepath .SplitList (value )
227+ configPaths := new ([]interface {})
228+ for _ , p := range pathList {
229+ * configPaths = append (* configPaths , p )
230+ }
231+ return * configPaths , nil
229232 }
230- pathList := filepath .SplitList (value )
231- configPaths := new ([]interface {})
232- for _ , p := range pathList {
233- * configPaths = append (* configPaths , p )
234- }
235- return * configPaths , nil
233+ return nil , nil
236234}
237235
238236type KubeClientsets interface {
@@ -373,10 +371,6 @@ func initializeConfiguration(d *schema.ResourceData) (*restclient.Config, error)
373371 for _ , p := range v {
374372 configPaths = append (configPaths , p .(string ))
375373 }
376- } else if v := os .Getenv ("KUBE_CONFIG_PATHS" ); v != "" {
377- // NOTE we have to do this here because the schema
378- // does not yet allow you to set a default for a TypeList
379- configPaths = filepath .SplitList (v )
380374 }
381375
382376 if len (configPaths ) > 0 {
0 commit comments