Migrate grafana_playlist to use Framework SDK#2573
Conversation
|
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
155a33e to
c1d1c33
Compare
baf428f to
0643a3d
Compare
|
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
c54f341 to
6775b58
Compare
d641729 to
b6460b5
Compare
|
|
||
| ### Optional | ||
|
|
||
| - `item` (Block Set) (see [below for nested schema](#nestedblock--item)) |
There was a problem hiding this comment.
A validator on item (see) ensures that it has at least one item.
|
|
||
| id := createResp.Payload.UID | ||
| if id == "" { | ||
| id = strconv.FormatInt(createResp.Payload.ID, 10) |
There was a problem hiding this comment.
You are trying to convert empty id here.
There was a problem hiding this comment.
Thanks for the review.
Seems to me that this matched legacy behavior. See legacy code: https://github.com/grafana/terraform-provider-grafana/pull/2573/changes#diff-f398641dc1c6eeee65d0fb0b4865c3acd1345bd0bc466690d65916bb1718c3bcL110-L114
However, I did go ahead and tighten up the logic to only use the numeric id when it's non-zero: 9b4beef#diff-f398641dc1c6eeee65d0fb0b4865c3acd1345bd0bc466690d65916bb1718c3bcR181-R187
| return | ||
| } | ||
|
|
||
| client, _, split, parseErr := r.clientFromExistingOrgResource(resourcePlaylistID, plan.ID.ValueString()) |
There was a problem hiding this comment.
You are doing the same in Update, ReadPlaylist and ImportState. Couldn't be better extract this check into a function?
There was a problem hiding this comment.
Yes, makes sense to reduce repetition. Change made in 9b4beef
0888085 to
67228f2
Compare
For https://github.com/grafana/deployment_tools/issues/507742
Migrates the grafana_playlist resource from the legacy Terraform Plugin SDKv2 to the Plugin Framework. The resource now uses Framework types and CRUD, keeps org-scoped IDs (org_id/uid), and uses the existing lister. Playlist items are represented as a set of objects (id, order, type, value). No API or Terraform config changes; only the provider implementation is updated.
More details can be found in the issue and parent issue. Platform Monitoring is migrating resources to use Framework SDK instead of Terraform Plugin SDKv2 since support for SDKv2 is ending.
Thread