Skip to content

Migrate grafana_playlist to use Framework SDK#2573

Merged
suntala merged 6 commits intomainfrom
suntala/migrate-grafana_playlist
Mar 27, 2026
Merged

Migrate grafana_playlist to use Framework SDK#2573
suntala merged 6 commits intomainfrom
suntala/migrate-grafana_playlist

Conversation

@suntala
Copy link
Copy Markdown
Contributor

@suntala suntala commented Mar 10, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@suntala suntala closed this Mar 12, 2026
@suntala suntala force-pushed the suntala/migrate-grafana_playlist branch from 155a33e to c1d1c33 Compare March 12, 2026 10:08
@suntala suntala reopened this Mar 12, 2026
@suntala suntala force-pushed the suntala/migrate-grafana_playlist branch from baf428f to 0643a3d Compare March 12, 2026 12:38
@github-actions
Copy link
Copy Markdown
Contributor

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@suntala suntala force-pushed the suntala/migrate-grafana_playlist branch from c54f341 to 6775b58 Compare March 13, 2026 13:11
@suntala suntala marked this pull request as ready for review March 17, 2026 13:48
@suntala suntala requested a review from a team as a code owner March 17, 2026 13:48
@suntala suntala marked this pull request as draft March 17, 2026 13:50
@suntala suntala force-pushed the suntala/migrate-grafana_playlist branch from d641729 to b6460b5 Compare March 20, 2026 15:23

### Optional

- `item` (Block Set) (see [below for nested schema](#nestedblock--item))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A validator on item (see) ensures that it has at least one item.

@suntala suntala marked this pull request as ready for review March 20, 2026 17:37

id := createResp.Payload.UID
if id == "" {
id = strconv.FormatInt(createResp.Payload.ID, 10)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are trying to convert empty id here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are doing the same in Update, ReadPlaylist and ImportState. Couldn't be better extract this check into a function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense to reduce repetition. Change made in 9b4beef

@suntala suntala force-pushed the suntala/migrate-grafana_playlist branch from 0888085 to 67228f2 Compare March 27, 2026 12:05
@suntala suntala requested a review from spinillos March 27, 2026 13:04
@suntala suntala merged commit 51a9b92 into main Mar 27, 2026
43 checks passed
@suntala suntala deleted the suntala/migrate-grafana_playlist branch March 27, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants