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

feat: add support for secret description and tags #123

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 17 additions & 2 deletions internal/provider/resource_namespace_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,32 @@ func resourceNamespaceSecret() *schema.Resource {
ForceNew: true,
},
"secret_key": {
Description: "The namespace secrey key.",
Description: "The namespace secret key.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"secret_value": {
Description: "The namespace secrey value.",
Description: "The namespace secret value.",
Type: schema.TypeString,
Required: true,
Sensitive: true,
},
"secret_description": {
Description: "The namespace secret description.",
Type: schema.TypeString,
Optional: true,
Sensitive: false,
},
"secret_tags": {
Description: "The namespace secret description.",
Type: schema.TypeMap,
Optional: true,
Sensitive: false,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}
Expand Down
18 changes: 15 additions & 3 deletions internal/provider/utils_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,20 @@ func namespaceApiToSchema(r map[string]interface{}, d *schema.ResourceData, c *C
}

func namespaceSecretSchemaToApi(d *schema.ResourceData) (map[string]interface{}, error) {
body := make(map[string]interface{}, 0)
body[d.Get("secret_key").(string)] = d.Get("secret_value").(string)
secret := make(map[string]interface{}, 0)
secret["key"] = d.Get("secret_key").(string)
secret["value"] = d.Get("secret_value").(string)
secret["description"] = d.Get("secret_description").(string)

tagsByKey := d.Get("secret_tags").(map[string]interface{})
tags := make([]interface{}, 0, len(tagsByKey))
for key, value := range tagsByKey {
tag := make(map[string]interface{}, 0)
tag["key"] = key
tag["value"] = value
tags = append(tags, tag)
}
secret["tags"] = tags

return body, nil
return secret, nil
}
Loading