Skip to content

Commit

Permalink
extend helm_release.metadata with new computed fields
Browse files Browse the repository at this point in the history
- last_deployed to implement hashicorp#1374
- first_deployed and notes to extend functionality further
  • Loading branch information
danielskowronski authored and appilon committed Jun 11, 2024
1 parent c46979c commit 115a53f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
5 changes: 4 additions & 1 deletion docs/resources/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ Read-Only:
- `chart` (String)
- `name` (String)
- `namespace` (String)
- `revision` (Number)
- `first_deployed` (Number) timestamp when the release was first deployed
- `last_deployed` (Number) timestamp when the release was last deployed
- `revision` (Number) version of the release last deployed
- `notes` (String) rendered templates/NOTES.txt if available
- `values` (String)
- `version` (String)

Expand Down
32 changes: 25 additions & 7 deletions helm/resource_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ func resourceRelease() *schema.Resource {
Computed: true,
Description: "The version number of the application being deployed.",
},
"first_deployed": {
Type: schema.TypeInt,
Computed: true,
Description: "FirstDeployed is an int32 which represents timestamp when the release was first deployed.",
},
"last_deployed": {
Type: schema.TypeInt,
Computed: true,
Description: "LastDeployed is an int32 which represents timestamp when the release was last deployed.",
},
"notes": {
Type: schema.TypeString,
Computed: true,
Description: "Contains the rendered templates/NOTES.txt if available",
},
"values": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1081,13 +1096,16 @@ func setReleaseAttributes(d *schema.ResourceData, r *release.Release, meta inter
}

return d.Set("metadata", []map[string]interface{}{{
"name": r.Name,
"revision": r.Version,
"namespace": r.Namespace,
"chart": r.Chart.Metadata.Name,
"version": r.Chart.Metadata.Version,
"app_version": r.Chart.Metadata.AppVersion,
"values": values,
"name": r.Name,
"revision": r.Version,
"namespace": r.Namespace,
"chart": r.Chart.Metadata.Name,
"version": r.Chart.Metadata.Version,
"app_version": r.Chart.Metadata.AppVersion,
"first_deployed": r.Info.FirstDeployed.Time.Unix(),
"last_deployed": r.Info.LastDeployed.Time.Unix(),
"notes": r.Info.Notes,
"values": values,
}})
}

Expand Down

0 comments on commit 115a53f

Please sign in to comment.