Skip to content

Commit 6471682

Browse files
committed
wip
1 parent 6553424 commit 6471682

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

kubernetes/provider.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,47 @@ func Provider() *schema.Provider {
4343
Optional: true,
4444
DefaultFunc: schema.EnvDefaultFunc("KUBE_USER", nil),
4545
Description: "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
46-
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate"},
47-
RequiredWith: []string{"password"},
46+
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"},
47+
RequiredWith: []string{"password", "host"},
4848
},
4949
"password": {
5050
Type: schema.TypeString,
5151
Optional: true,
5252
DefaultFunc: schema.EnvDefaultFunc("KUBE_PASSWORD", nil),
5353
Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
54-
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate"},
55-
RequiredWith: []string{"username"},
54+
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"},
55+
RequiredWith: []string{"username", "host"},
5656
},
5757
"insecure": {
5858
Type: schema.TypeBool,
5959
Optional: true,
6060
DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil),
6161
Description: "Whether server should be accessed without verifying the TLS certificate.",
62+
ConflictsWith: []string{"cluster_ca_certificate", "client_key", "client_certificate", "exec"},
6263
},
6364
"client_certificate": {
6465
Type: schema.TypeString,
6566
Optional: true,
6667
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil),
6768
Description: "PEM-encoded client certificate for TLS authentication.",
68-
ConflictsWith: []string{"config_path", "config_paths", "username", "password"},
69-
RequiredWith: []string{"client_key"},
69+
ConflictsWith: []string{"config_path", "config_paths", "username", "password", "insecure"},
70+
RequiredWith: []string{"client_key", "cluster_ca_certificate", "host"},
7071
},
7172
"client_key": {
7273
Type: schema.TypeString,
7374
Optional: true,
7475
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil),
7576
Description: "PEM-encoded client certificate key for TLS authentication.",
7677
ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec", "insecure"},
77-
RequiredWith: []string{"client_certificate"},
78+
RequiredWith: []string{"client_certificate", "cluster_ca_certificate", "host"},
7879
},
7980
"cluster_ca_certificate": {
8081
Type: schema.TypeString,
8182
Optional: true,
8283
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", nil),
8384
Description: "PEM-encoded root certificates bundle for TLS authentication.",
8485
ConflictsWith: []string{"config_path", "config_paths", "insecure"},
86+
RequiredWith: []string{"host"},
8587
// TODO: enable this when AtLeastOneOf works with optional attributes.
8688
// https://github.com/hashicorp/terraform-plugin-sdk/issues/705
8789
// AtLeastOneOf: []string{"token", "exec", "client_certificate", "client_key"},
@@ -109,20 +111,26 @@ func Provider() *schema.Provider {
109111
DefaultFunc: schema.EnvDefaultFunc("KUBE_CTX", nil),
110112
Description: "Context to choose from the kube config file. ",
111113
ConflictsWith: []string{"exec", "token", "client_certificate", "client_key", "username", "password"},
114+
// TODO: enable this when AtLeastOneOf works with optional attributes.
115+
// AtLeastOneOf: []string{"config_path", "config_paths"},
112116
},
113117
"config_context_auth_info": {
114118
Type: schema.TypeString,
115119
Optional: true,
116120
DefaultFunc: schema.EnvDefaultFunc("KUBE_CTX_AUTH_INFO", nil),
117121
Description: "Authentication info context of the kube config (name of the kubeconfig user, --user flag in kubectl).",
118122
ConflictsWith: []string{"exec", "token", "client_certificate", "client_key", "username", "password"},
123+
// TODO: enable this when AtLeastOneOf works with optional attributes.
124+
// AtLeastOneOf: []string{"config_path", "config_paths"},
119125
},
120126
"config_context_cluster": {
121127
Type: schema.TypeString,
122128
Optional: true,
123129
DefaultFunc: schema.EnvDefaultFunc("KUBE_CTX_CLUSTER", nil),
124130
Description: "Cluster context of the kube config (name of the kubeconfig cluster, --cluster flag in kubectl).",
125131
ConflictsWith: []string{"exec", "token", "client_certificate", "client_key", "username", "password"},
132+
// TODO: enable this when AtLeastOneOf works with optional attributes.
133+
// AtLeastOneOf: []string{"config_path", "config_paths"},
126134
},
127135
"token": {
128136
Type: schema.TypeString,
@@ -159,8 +167,8 @@ func Provider() *schema.Provider {
159167
},
160168
},
161169
Description: "Configuration block to use an exec-based credential plugin, e.g. call an external command to receive user credentials.",
162-
ConflictsWith: []string{"config_path", "config_paths", "token", "client_certificate", "client_key", "username", "password"},
163-
RequiredWith: []string{"host"},
170+
ConflictsWith: []string{"config_path", "config_paths", "token", "client_certificate", "client_key", "username", "password", "insecure"},
171+
RequiredWith: []string{"host", "cluster_ca_certificate"},
164172
},
165173
},
166174

kubernetes/provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ func TestAccKubernetesProvider_host(t *testing.T) {
717717
),
718718
PlanOnly: true,
719719
ExpectNonEmptyPlan: true,
720-
// "host": all of `host,token` must be specified
720+
// Error: "host": all of `host,token` must be specified
721721
ExpectError: regexp.MustCompile("host,token"),
722722
},
723723
{
@@ -726,7 +726,7 @@ func TestAccKubernetesProvider_host(t *testing.T) {
726726
),
727727
PlanOnly: true,
728728
ExpectNonEmptyPlan: true,
729-
// "exec": all of `host,exec` must be specified
729+
// Error: "exec": all of `host,exec` must be specified
730730
ExpectError: regexp.MustCompile("exec,host"),
731731
},
732732
},

0 commit comments

Comments
 (0)