Skip to content

Commit

Permalink
feat: add support for secret description and tags (kestra-io#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois authored and anna-geller committed Aug 5, 2024
1 parent 49df9b7 commit e6823ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
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
}

0 comments on commit e6823ea

Please sign in to comment.