Skip to content

Commit ce89cf4

Browse files
committed
wip
1 parent 30d81df commit ce89cf4

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

kubernetes/provider.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
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"
1011
"github.com/mitchellh/go-homedir"
1112
apimachineryschema "k8s.io/apimachinery/pkg/runtime/schema"
1213
"k8s.io/client-go/discovery"
@@ -27,13 +28,15 @@ func Provider() *schema.Provider {
2728
p := &schema.Provider{
2829
Schema: map[string]*schema.Schema{
2930
"host": {
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"},
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+
// https://github.com/hashicorp/terraform-plugin-sdk/issues/705
39+
// AtLeastOneOf: []string{"token", "exec", "username", "password", "client_certificate", "client_key"},
3740
},
3841
"username": {
3942
Type: schema.TypeString,
@@ -80,23 +83,24 @@ func Provider() *schema.Provider {
8083
Description: "PEM-encoded root certificates bundle for TLS authentication.",
8184
ConflictsWith: []string{"config_path", "config_paths", "insecure"},
8285
// TODO: enable this when AtLeastOneOf works with optional attributes.
83-
//AtLeastOneOf: []string{"token", "exec", "client_certificate", "client_key"},
86+
// https://github.com/hashicorp/terraform-plugin-sdk/issues/705
87+
// AtLeastOneOf: []string{"token", "exec", "client_certificate", "client_key"},
8488
},
8589
"config_paths": {
8690
Type: schema.TypeList,
8791
Elem: &schema.Schema{Type: schema.TypeString},
8892
DefaultFunc: configPathsEnv,
8993
Optional: true,
9094
Description: "A list of paths to kube config files. Can be set with KUBE_CONFIG_PATHS environment variable.",
91-
// This should conflict with every attribute except for "insecure", since all of these options will be read from the kubeconfig.
95+
// config_paths conflicts with every attribute except for "insecure", since all of these options will be read from the kubeconfig.
9296
ConflictsWith: []string{"config_path", "exec", "token", "host", "client_certificate", "client_key", "cluster_ca_certificate", "username", "password"},
9397
},
9498
"config_path": {
9599
Type: schema.TypeString,
96100
Optional: true,
97101
DefaultFunc: schema.EnvDefaultFunc("KUBE_CONFIG_PATH", nil),
98102
Description: "Path to the kube config file. Can be set with KUBE_CONFIG_PATH.",
99-
// This should conflict with every attribute except for "insecure", since all of these options will be read from the kubeconfig.
103+
// config_path conflicts with every attribute except for "insecure", since all of these options will be read from the kubeconfig.
100104
ConflictsWith: []string{"config_paths", "exec", "token", "host", "client_certificate", "client_key", "cluster_ca_certificate", "username", "password"},
101105
},
102106
"config_context": {

0 commit comments

Comments
 (0)