Skip to content

Commit 550f2c1

Browse files
authored
add conflictsWith to provider schema (#2084)
* add conflictsWith to provider schema * remove cluster_ca_certificate requirement of other attributes * add changelog-entry * provider updates * update conflictsWith on insecure attribute * update conflictsWith for cluster_ca_certificate * fix typo * remove Required host from client certificate/key
1 parent 80e8520 commit 550f2c1

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

.changelog/2084.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
`kubernetes/provider.go`: add `conflictsWith` to provider schema
3+
```

kubernetes/provider.go

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,57 @@ func Provider() *schema.Provider {
4040
p := &schema.Provider{
4141
Schema: map[string]*schema.Schema{
4242
"host": {
43-
Type: schema.TypeString,
44-
Optional: true,
45-
DefaultFunc: schema.EnvDefaultFunc("KUBE_HOST", ""),
46-
Description: "The hostname (in form of URI) of Kubernetes master.",
43+
Type: schema.TypeString,
44+
Optional: true,
45+
DefaultFunc: schema.EnvDefaultFunc("KUBE_HOST", nil),
46+
Description: "The hostname (in form of URI) of Kubernetes master.",
47+
ConflictsWith: []string{"config_path", "config_paths"},
4748
},
4849
"username": {
49-
Type: schema.TypeString,
50-
Optional: true,
51-
DefaultFunc: schema.EnvDefaultFunc("KUBE_USER", ""),
52-
Description: "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
50+
Type: schema.TypeString,
51+
Optional: true,
52+
DefaultFunc: schema.EnvDefaultFunc("KUBE_USER", nil),
53+
Description: "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
54+
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"},
55+
RequiredWith: []string{"password", "host"},
5356
},
5457
"password": {
55-
Type: schema.TypeString,
56-
Optional: true,
57-
DefaultFunc: schema.EnvDefaultFunc("KUBE_PASSWORD", ""),
58-
Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
58+
Type: schema.TypeString,
59+
Optional: true,
60+
DefaultFunc: schema.EnvDefaultFunc("KUBE_PASSWORD", nil),
61+
Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
62+
ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"},
63+
RequiredWith: []string{"username", "host"},
5964
},
6065
"insecure": {
61-
Type: schema.TypeBool,
62-
Optional: true,
63-
DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", false),
64-
Description: "Whether server should be accessed without verifying the TLS certificate.",
66+
Type: schema.TypeBool,
67+
Optional: true,
68+
DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil),
69+
Description: "Whether server should be accessed without verifying the TLS certificate.",
70+
ConflictsWith: []string{"cluster_ca_certificate"},
6571
},
6672
"client_certificate": {
67-
Type: schema.TypeString,
68-
Optional: true,
69-
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", ""),
70-
Description: "PEM-encoded client certificate for TLS authentication.",
73+
Type: schema.TypeString,
74+
Optional: true,
75+
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil),
76+
Description: "PEM-encoded client certificate for TLS authentication.",
77+
ConflictsWith: []string{"config_path", "config_paths", "username", "password"},
78+
RequiredWith: []string{"client_key"},
7179
},
7280
"client_key": {
73-
Type: schema.TypeString,
74-
Optional: true,
75-
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", ""),
76-
Description: "PEM-encoded client certificate key for TLS authentication.",
81+
Type: schema.TypeString,
82+
Optional: true,
83+
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil),
84+
Description: "PEM-encoded client certificate key for TLS authentication.",
85+
ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec"},
86+
RequiredWith: []string{"client_certificate"},
7787
},
7888
"cluster_ca_certificate": {
79-
Type: schema.TypeString,
80-
Optional: true,
81-
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", ""),
82-
Description: "PEM-encoded root certificates bundle for TLS authentication.",
89+
Type: schema.TypeString,
90+
Optional: true,
91+
DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", nil),
92+
Description: "PEM-encoded root certificates bundle for TLS authentication.",
93+
ConflictsWith: []string{"insecure"},
8394
},
8495
"config_paths": {
8596
Type: schema.TypeList,

0 commit comments

Comments
 (0)