Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datasource: kubernetes_secret: add binary_data attribute #1285

Merged
merged 4 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kubernetes/data_source_kubernetes_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kubernetes

import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -19,6 +20,12 @@ func dataSourceKubernetesSecret() *schema.Resource {
Computed: true,
Sensitive: true,
},
"base64_data" : {
Type: schema.TypeMap,
Description: "A map of the secret data with values encoded in base64 format",
Computed: true,
Sensitive: true,
},
"type": {
Type: schema.TypeString,
Description: "Type of secret",
Expand Down
8 changes: 8 additions & 0 deletions kubernetes/resource_kubernetes_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func resourceKubernetesSecret() *schema.Resource {
Sensitive: true,
Description: "A map of the secret data in base64 encoding. Use this for binary data.",
},
"base64_data": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Sensitive: true,
Description: "A map of the secret data with values in base64 encoding.",
},
"type": {
Type: schema.TypeString,
Description: "Type of secret",
Expand Down Expand Up @@ -138,6 +145,7 @@ func resourceKubernetesSecretRead(ctx context.Context, d *schema.ResourceData, m
delete(secret.Data, k)
}
d.Set("data", flattenByteMapToStringMap(secret.Data))
d.Set("base64_data", flattenByteMapToBase64Map(secret.Data))
d.Set("type", secret.Type)
return nil
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ The following arguments are supported:
## Attribute Reference

* `data` - A map of the secret data.
* `base64_data` - A map of the secret data with values encoded in base64 format.
* `type` - The secret type. Defaults to `Opaque`. For more info see [Kubernetes reference](https://github.com/kubernetes/community/blob/c7151dd8dd7e487e96e5ce34c6a416bb3b037609/contributors/design-proposals/auth/secrets.md#proposed-design)