Skip to content

Commit e64a2fb

Browse files
authored
Merge pull request #96 from arnaud-dfns/fix/invalid-instance
2 parents e6bd543 + 23b8ee7 commit e64a2fb

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

docs/data-sources/kubernetes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ resource "postgresql_database" "my_db" {
5858

5959
Optional:
6060

61-
- `client_certificate` (String) PEM-encoded client certificate for TLS authentication.
62-
- `client_key` (String) PEM-encoded client certificate key for TLS authentication.
63-
- `cluster_ca_certificate` (String) PEM-encoded root certificates bundle for TLS authentication.
61+
- `client_certificate` (String, Sensitive) PEM-encoded client certificate for TLS authentication.
62+
- `client_key` (String, Sensitive) PEM-encoded client certificate key for TLS authentication.
63+
- `cluster_ca_certificate` (String, Sensitive) PEM-encoded root certificates bundle for TLS authentication.
6464
- `config_context` (String) Context to choose from the config file. Can be sourced from KUBE_CTX.
6565
- `config_context_auth_info` (String) Authentication info context of the kube config (name of the kubeconfig user, --user flag in kubectl). Can be sourced from KUBE_CTX_AUTH_INFO.
6666
- `config_context_cluster` (String) Cluster context of the kube config (name of the kubeconfig cluster, --cluster flag in kubectl). Can be sourced from KUBE_CTX_CLUSTER.
@@ -69,10 +69,10 @@ Optional:
6969
- `exec` (Attributes) Exec configuration for Kubernetes authentication (see [below for nested schema](#nestedatt--kubernetes--exec))
7070
- `host` (String) The hostname (in form of URI) of kubernetes master
7171
- `insecure` (Boolean) Whether server should be accessed without verifying the TLS certificate.
72-
- `password` (String) The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.
72+
- `password` (String, Sensitive) The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.
7373
- `proxy_url` (String) URL to the proxy to be used for all API requests.
7474
- `tls_server_name` (String) Server name passed to the server for SNI and is used in the client to check server certificates against.
75-
- `token` (String) Token to authenticate a service account.
75+
- `token` (String, Sensitive) Token to authenticate a service account.
7676
- `username` (String) The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint
7777

7878
<a id="nestedatt--kubernetes--exec"></a>
@@ -85,5 +85,5 @@ Required:
8585

8686
Optional:
8787

88-
- `args` (List of String) Arguments for the exec plugin
89-
- `env` (Map of String) Environment variables for the exec plugin
88+
- `args` (List of String, Sensitive) Arguments for the exec plugin
89+
- `env` (Map of String, Sensitive) Environment variables for the exec plugin

docs/ephemeral-resources/kubernetes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ resource "postgresql_database" "my_db" {
5858

5959
Optional:
6060

61-
- `client_certificate` (String) PEM-encoded client certificate for TLS authentication.
62-
- `client_key` (String) PEM-encoded client certificate key for TLS authentication.
63-
- `cluster_ca_certificate` (String) PEM-encoded root certificates bundle for TLS authentication.
61+
- `client_certificate` (String, Sensitive) PEM-encoded client certificate for TLS authentication.
62+
- `client_key` (String, Sensitive) PEM-encoded client certificate key for TLS authentication.
63+
- `cluster_ca_certificate` (String, Sensitive) PEM-encoded root certificates bundle for TLS authentication.
6464
- `config_context` (String) Context to choose from the config file. Can be sourced from KUBE_CTX.
6565
- `config_context_auth_info` (String) Authentication info context of the kube config (name of the kubeconfig user, --user flag in kubectl). Can be sourced from KUBE_CTX_AUTH_INFO.
6666
- `config_context_cluster` (String) Cluster context of the kube config (name of the kubeconfig cluster, --cluster flag in kubectl). Can be sourced from KUBE_CTX_CLUSTER.
@@ -69,10 +69,10 @@ Optional:
6969
- `exec` (Attributes) Exec configuration for Kubernetes authentication (see [below for nested schema](#nestedatt--kubernetes--exec))
7070
- `host` (String) The hostname (in form of URI) of kubernetes master
7171
- `insecure` (Boolean) Whether server should be accessed without verifying the TLS certificate.
72-
- `password` (String) The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.
72+
- `password` (String, Sensitive) The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.
7373
- `proxy_url` (String) URL to the proxy to be used for all API requests.
7474
- `tls_server_name` (String) Server name passed to the server for SNI and is used in the client to check server certificates against.
75-
- `token` (String) Token to authenticate a service account.
75+
- `token` (String, Sensitive) Token to authenticate a service account.
7676
- `username` (String) The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint
7777

7878
<a id="nestedatt--kubernetes--exec"></a>
@@ -85,5 +85,5 @@ Required:
8585

8686
Optional:
8787

88-
- `args` (List of String) Arguments for the exec plugin
89-
- `env` (Map of String) Environment variables for the exec plugin
88+
- `args` (List of String, Sensitive) Arguments for the exec plugin
89+
- `env` (Map of String, Sensitive) Environment variables for the exec plugin

internal/provider/data_source_kubernetes.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func (d *KubernetesDataSource) Schema(ctx context.Context, req datasource.Schema
6161
},
6262
"kubernetes": schema.SingleNestedAttribute{
6363
Optional: true,
64-
Computed: true,
6564
Description: "Kubernetes Configuration",
6665
Attributes: map[string]schema.Attribute{
6766
"host": schema.StringAttribute{
@@ -74,6 +73,7 @@ func (d *KubernetesDataSource) Schema(ctx context.Context, req datasource.Schema
7473
},
7574
"password": schema.StringAttribute{
7675
Optional: true,
76+
Sensitive: true,
7777
Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
7878
},
7979
"insecure": schema.BoolAttribute{
@@ -86,14 +86,17 @@ func (d *KubernetesDataSource) Schema(ctx context.Context, req datasource.Schema
8686
},
8787
"client_certificate": schema.StringAttribute{
8888
Optional: true,
89+
Sensitive: true,
8990
Description: "PEM-encoded client certificate for TLS authentication.",
9091
},
9192
"client_key": schema.StringAttribute{
9293
Optional: true,
94+
Sensitive: true,
9395
Description: "PEM-encoded client certificate key for TLS authentication.",
9496
},
9597
"cluster_ca_certificate": schema.StringAttribute{
9698
Optional: true,
99+
Sensitive: true,
97100
Description: "PEM-encoded root certificates bundle for TLS authentication.",
98101
},
99102
"config_paths": schema.ListAttribute{
@@ -119,6 +122,7 @@ func (d *KubernetesDataSource) Schema(ctx context.Context, req datasource.Schema
119122
},
120123
"token": schema.StringAttribute{
121124
Optional: true,
125+
Sensitive: true,
122126
Description: "Token to authenticate a service account.",
123127
},
124128
"proxy_url": schema.StringAttribute{
@@ -139,11 +143,13 @@ func (d *KubernetesDataSource) Schema(ctx context.Context, req datasource.Schema
139143
},
140144
"env": schema.MapAttribute{
141145
Optional: true,
146+
Sensitive: true,
142147
ElementType: types.StringType,
143148
Description: "Environment variables for the exec plugin",
144149
},
145150
"args": schema.ListAttribute{
146151
Optional: true,
152+
Sensitive: true,
147153
ElementType: types.StringType,
148154
Description: "Arguments for the exec plugin",
149155
},
@@ -245,8 +251,5 @@ func (d *KubernetesDataSource) Read(ctx context.Context, req datasource.ReadRequ
245251
return
246252
}
247253

248-
// Clear the sensitive Kubernetes configuration from the state
249-
data.Kubernetes = nil
250-
251254
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
252255
}

internal/provider/ephemeral_kubernetes.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func (d *KubernetesEphemeral) Schema(ctx context.Context, req ephemeral.SchemaRe
8989
},
9090
"kubernetes": schema.SingleNestedAttribute{
9191
Optional: true,
92-
Computed: true,
9392
Description: "Kubernetes Configuration",
9493
Attributes: map[string]schema.Attribute{
9594
"host": schema.StringAttribute{
@@ -102,6 +101,7 @@ func (d *KubernetesEphemeral) Schema(ctx context.Context, req ephemeral.SchemaRe
102101
},
103102
"password": schema.StringAttribute{
104103
Optional: true,
104+
Sensitive: true,
105105
Description: "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint.",
106106
},
107107
"insecure": schema.BoolAttribute{
@@ -114,14 +114,17 @@ func (d *KubernetesEphemeral) Schema(ctx context.Context, req ephemeral.SchemaRe
114114
},
115115
"client_certificate": schema.StringAttribute{
116116
Optional: true,
117+
Sensitive: true,
117118
Description: "PEM-encoded client certificate for TLS authentication.",
118119
},
119120
"client_key": schema.StringAttribute{
120121
Optional: true,
122+
Sensitive: true,
121123
Description: "PEM-encoded client certificate key for TLS authentication.",
122124
},
123125
"cluster_ca_certificate": schema.StringAttribute{
124126
Optional: true,
127+
Sensitive: true,
125128
Description: "PEM-encoded root certificates bundle for TLS authentication.",
126129
},
127130
"config_paths": schema.ListAttribute{
@@ -147,6 +150,7 @@ func (d *KubernetesEphemeral) Schema(ctx context.Context, req ephemeral.SchemaRe
147150
},
148151
"token": schema.StringAttribute{
149152
Optional: true,
153+
Sensitive: true,
150154
Description: "Token to authenticate a service account.",
151155
},
152156
"proxy_url": schema.StringAttribute{
@@ -167,11 +171,13 @@ func (d *KubernetesEphemeral) Schema(ctx context.Context, req ephemeral.SchemaRe
167171
},
168172
"env": schema.MapAttribute{
169173
Optional: true,
174+
Sensitive: true,
170175
ElementType: types.StringType,
171176
Description: "Environment variables for the exec plugin",
172177
},
173178
"args": schema.ListAttribute{
174179
Optional: true,
180+
Sensitive: true,
175181
ElementType: types.StringType,
176182
Description: "Arguments for the exec plugin",
177183
},
@@ -273,9 +279,6 @@ func (d *KubernetesEphemeral) Open(ctx context.Context, req ephemeral.OpenReques
273279
return
274280
}
275281

276-
// Clear the sensitive Kubernetes configuration from the result
277-
data.Kubernetes = nil
278-
279282
resp.Diagnostics.Append(resp.Result.Set(ctx, &data)...)
280283
resp.Private.SetKey(ctx, "tunnel_pid", []byte(strconv.Itoa(cmd.Process.Pid)))
281284
}

0 commit comments

Comments
 (0)