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

Allow optional data to be set externally when provided #1171

Closed
Closed
Changes from all 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
17 changes: 13 additions & 4 deletions kubernetes/resource_kubernetes_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ func resourceKubernetesSecretCreate(ctx context.Context, d *schema.ResourceData,
}

metadata := expandMetadata(d.Get("metadata").([]interface{}))
secret := api.Secret{
ObjectMeta: metadata,
Data: expandStringMapToByteMap(d.Get("data").(map[string]interface{})),
var secret api.Secret
if data, ok := d.GetOk("data"); ok {
secret = api.Secret{
ObjectMeta: metadata,
Data: expandStringMapToByteMap(data.(map[string]interface{})),
}
} else {
secret = api.Secret{
ObjectMeta: metadata,
}
}

if v, ok := d.GetOk("type"); ok {
Expand Down Expand Up @@ -101,7 +108,9 @@ func resourceKubernetesSecretRead(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}

d.Set("data", flattenByteMapToStringMap(secret.Data))
if _, ok := d.GetOk("data"); ok {
d.Set("data", flattenByteMapToStringMap(secret.Data))
}
d.Set("type", secret.Type)

return nil
Expand Down