From 4a556d7bb23c7525ae9d08e187bfe116e82143ee Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 21 Apr 2023 14:07:37 -0700 Subject: [PATCH 1/8] add conflictsWith to provider schema --- kubernetes/provider.go | 68 +++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 8e0c7a3e72..7f0f2315f3 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -40,46 +40,58 @@ func Provider() *schema.Provider { p := &schema.Provider{ Schema: map[string]*schema.Schema{ "host": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_HOST", ""), - Description: "The hostname (in form of URI) of Kubernetes master.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_HOST", nil), + Description: "The hostname (in form of URI) of Kubernetes master.", + ConflictsWith: []string{"config_path", "config_paths"}, }, "username": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_USER", ""), - Description: "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_USER", nil), + Description: "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint.", + ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"}, + RequiredWith: []string{"password", "host"}, }, "password": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_PASSWORD", ""), - Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_PASSWORD", nil), + Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.", + ConflictsWith: []string{"config_path", "config_paths", "exec", "token", "client_certificate", "client_key"}, + RequiredWith: []string{"username", "host"}, }, "insecure": { - Type: schema.TypeBool, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", false), - Description: "Whether server should be accessed without verifying the TLS certificate.", + Type: schema.TypeBool, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil), + Description: "Whether server should be accessed without verifying the TLS certificate.", + ConflictsWith: []string{"cluster_ca_certificate", "client_key", "client_certificate", "exec"}, }, "client_certificate": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", ""), - Description: "PEM-encoded client certificate for TLS authentication.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil), + Description: "PEM-encoded client certificate for TLS authentication.", + ConflictsWith: []string{"config_path", "config_paths", "username", "password", "insecure"}, + RequiredWith: []string{"client_key", "cluster_ca_certificate", "host"}, }, "client_key": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", ""), - Description: "PEM-encoded client certificate key for TLS authentication.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil), + Description: "PEM-encoded client certificate key for TLS authentication.", + ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec", "insecure"}, + RequiredWith: []string{"client_certificate", "cluster_ca_certificate", "host"}, }, "cluster_ca_certificate": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", ""), - Description: "PEM-encoded root certificates bundle for TLS authentication.", + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", nil), + Description: "PEM-encoded root certificates bundle for TLS authentication.", + ConflictsWith: []string{"config_path", "config_paths", "insecure"}, + RequiredWith: []string{"host"}, }, "config_paths": { Type: schema.TypeList, From 9b2e9ea2fa9977d17e1fb6628535b6616d8c300a Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 3 May 2023 10:32:05 -0700 Subject: [PATCH 2/8] remove cluster_ca_certificate requirement of other attributes --- kubernetes/provider.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 7f0f2315f3..0522c497cc 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -67,7 +67,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil), Description: "Whether server should be accessed without verifying the TLS certificate.", - ConflictsWith: []string{"cluster_ca_certificate", "client_key", "client_certificate", "exec"}, + ConflictsWith: []string{"client_key", "client_certificate", "exec"}, }, "client_certificate": { Type: schema.TypeString, @@ -75,7 +75,7 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil), Description: "PEM-encoded client certificate for TLS authentication.", ConflictsWith: []string{"config_path", "config_paths", "username", "password", "insecure"}, - RequiredWith: []string{"client_key", "cluster_ca_certificate", "host"}, + RequiredWith: []string{"client_key", "host"}, }, "client_key": { Type: schema.TypeString, @@ -83,7 +83,7 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil), Description: "PEM-encoded client certificate key for TLS authentication.", ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec", "insecure"}, - RequiredWith: []string{"client_certificate", "cluster_ca_certificate", "host"}, + RequiredWith: []string{"client_certificate", "host"}, }, "cluster_ca_certificate": { Type: schema.TypeString, @@ -91,7 +91,6 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", nil), Description: "PEM-encoded root certificates bundle for TLS authentication.", ConflictsWith: []string{"config_path", "config_paths", "insecure"}, - RequiredWith: []string{"host"}, }, "config_paths": { Type: schema.TypeList, From 51d0b430796f87ae82801960d711236b1ad83e7b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 3 May 2023 11:11:36 -0700 Subject: [PATCH 3/8] add changelog-entry --- .changelog/2084.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2084.txt diff --git a/.changelog/2084.txt b/.changelog/2084.txt new file mode 100644 index 0000000000..0c23381e47 --- /dev/null +++ b/.changelog/2084.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +`kubernetes/provider.go`: add `conflictsWith` to provider schema +``` From 6cb019674123f50435e1639e6ddbff7201bc2907 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 4 May 2023 09:17:44 -0700 Subject: [PATCH 4/8] provider updates --- kubernetes/provider.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 0522c497cc..473bb2e60c 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -74,7 +74,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil), Description: "PEM-encoded client certificate for TLS authentication.", - ConflictsWith: []string{"config_path", "config_paths", "username", "password", "insecure"}, + ConflictsWith: []string{"config_path", "config_paths", "username", "password"}, RequiredWith: []string{"client_key", "host"}, }, "client_key": { @@ -82,7 +82,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil), Description: "PEM-encoded client certificate key for TLS authentication.", - ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec", "insecure"}, + ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec"}, RequiredWith: []string{"client_certificate", "host"}, }, "cluster_ca_certificate": { From cbfea00bb99b285f94e9e22522e61f2abd57516d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 5 May 2023 08:07:44 -0700 Subject: [PATCH 5/8] update conflictsWith on insecure attribute --- kubernetes/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 473bb2e60c..5b5dd5fbba 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -67,7 +67,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil), Description: "Whether server should be accessed without verifying the TLS certificate.", - ConflictsWith: []string{"client_key", "client_certificate", "exec"}, + ConflictsWith: []string{"client_ca_certificate"}, }, "client_certificate": { Type: schema.TypeString, From 6072658151ec4313d343c2ba09a346d691c10bfc Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 5 May 2023 08:20:59 -0700 Subject: [PATCH 6/8] update conflictsWith for cluster_ca_certificate --- kubernetes/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 3d072866fa..ee85d0151f 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -90,7 +90,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_CLUSTER_CA_CERT_DATA", nil), Description: "PEM-encoded root certificates bundle for TLS authentication.", - ConflictsWith: []string{"config_path", "config_paths", "insecure"}, + ConflictsWith: []string{"insecure"}, }, "config_paths": { Type: schema.TypeList, From 8ab9ada5aeffd5738faa6fa2a75471e5771d9eb0 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 5 May 2023 08:33:30 -0700 Subject: [PATCH 7/8] fix typo --- kubernetes/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index ee85d0151f..37b8cb855d 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -67,7 +67,7 @@ func Provider() *schema.Provider { Optional: true, DefaultFunc: schema.EnvDefaultFunc("KUBE_INSECURE", nil), Description: "Whether server should be accessed without verifying the TLS certificate.", - ConflictsWith: []string{"client_ca_certificate"}, + ConflictsWith: []string{"cluster_ca_certificate"}, }, "client_certificate": { Type: schema.TypeString, From bb520896597d8bba2be97a7c5411d2a0f8279f14 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 12 May 2023 12:58:44 -0700 Subject: [PATCH 8/8] remove Required host from client certificate/key --- kubernetes/provider.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 37b8cb855d..88bc7faaa6 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -75,7 +75,7 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_CERT_DATA", nil), Description: "PEM-encoded client certificate for TLS authentication.", ConflictsWith: []string{"config_path", "config_paths", "username", "password"}, - RequiredWith: []string{"client_key", "host"}, + RequiredWith: []string{"client_key"}, }, "client_key": { Type: schema.TypeString, @@ -83,7 +83,7 @@ func Provider() *schema.Provider { DefaultFunc: schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil), Description: "PEM-encoded client certificate key for TLS authentication.", ConflictsWith: []string{"config_path", "config_paths", "username", "password", "exec"}, - RequiredWith: []string{"client_certificate", "host"}, + RequiredWith: []string{"client_certificate"}, }, "cluster_ca_certificate": { Type: schema.TypeString,