Skip to content

Conversation

s4kh
Copy link
Contributor

@s4kh s4kh commented Aug 20, 2025

Fixes #2312
Tested with dev instance on local using locally built provider.
resource.tf

terraform {
  required_providers {
    grafana = {
      source = "registry.terraform.io/grafana/grafana"
    }
  }
}
provider "grafana" {
  cloud_api_url             = "https://grafana-dev.com/api"
  cloud_access_policy_token = "dev token"
}
resource "grafana_cloud_plugin_installation" "test" {
  stack_slug = "skh3"
  slug       = "axiomhq-axiom-datasource"
}

@s4kh s4kh requested review from a team as code owners August 20, 2025 17:54
Copy link
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.

@s4kh s4kh marked this pull request as draft August 20, 2025 17:54
@s4kh
Copy link
Contributor Author

s4kh commented Aug 20, 2025

cloud acceptance tests

@s4kh s4kh force-pushed the feat-plugin-version-optional branch 3 times, most recently from a7cdceb to 1db87f0 Compare August 20, 2025 18:30
@s4kh s4kh self-assigned this Aug 20, 2025
@s4kh s4kh moved this from 📬 Triage to 🧑‍💻 In development in Plugins Platform / Grafana Community Aug 20, 2025
@s4kh s4kh force-pushed the feat-plugin-version-optional branch from 698ab00 to 14b8761 Compare August 21, 2025 16:32
@s4kh s4kh marked this pull request as ready for review August 21, 2025 16:50
@DanCech
Copy link
Contributor

DanCech commented Aug 21, 2025

I kind of wonder whether it would make sense to support latest as an explicit version vs making the attribute optional, then we could potentially check against the plugin catalog in Read whether the installed version is the latest, if so report latest so there's no drift but if not then report the actual installed version to trigger an update.

@s4kh
Copy link
Contributor Author

s4kh commented Aug 21, 2025

@DanCech yeah.
But do we need to auto update the plugin?
There is a following scenario:

  1. Plugin is installed without the version specified.
    a. We don't return installed version in the read context(current state) function - if we do, terraform will try to delete and create again due to installed version != "" (declared in the resource.tf) loop happens
  2. New plugin version is released
  3. We run terraform plan
    a. It will show nothing to apply - because we don't show version in the readContext function because of 1a.
  4. What do we want in this scenario?

If we prefer stability and don't want to auto update, current implementation is fine. But in order to install the latest after the release, user either has to define the version number in the resource.tf

@DanCech
Copy link
Contributor

DanCech commented Aug 21, 2025

yeah, I'm thinking that if the user asks for the latest we should keep it up to date, and if they want a specific version they should specify it. Hence the idea of using an explicit version: latest in the spec and having read return version: latest if the installed version is the latest, but version: <installed version> if it's not the latest, which would trigger it to update to latest.

@DanCech
Copy link
Contributor

DanCech commented Aug 21, 2025

vs asking for latest and getting whatever it happens to be at install time but then never updating.

@s4kh s4kh changed the title feat: make plugin version optional - installs latest version feat: add 'latest' for version field - installs latest version Aug 21, 2025
@s4kh s4kh force-pushed the feat-plugin-version-optional branch from 5e985a7 to 2610f7b Compare August 21, 2025 22:54
@s4kh s4kh changed the title feat: add 'latest' for version field - installs latest version feat: make plugin version optional - installs latest version Aug 21, 2025
@s4kh s4kh force-pushed the feat-plugin-version-optional branch from 2610f7b to 7f5f8c4 Compare August 21, 2025 23:00
@s4kh s4kh force-pushed the feat-plugin-version-optional branch from 7f5f8c4 to 20af507 Compare August 22, 2025 13:26
@s4kh s4kh requested a review from DanCech August 22, 2025 13:26
@@ -92,10 +95,11 @@ func listStackPlugins(ctx context.Context, client *gcom.APIClient, data *ListerD
func resourcePluginInstallationCreate(ctx context.Context, d *schema.ResourceData, client *gcom.APIClient) diag.Diagnostics {
stackSlug := d.Get("stack_slug").(string)
pluginSlug := d.Get("slug").(string)
version := d.Get("version").(string)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

defaults to latest

Copy link
Contributor

@DanCech DanCech left a comment

Choose a reason for hiding this comment

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

LGTM, I don't have particular religion about whether the version param is optional with latest as the default or required.

@github-project-automation github-project-automation bot moved this from 🧑‍💻 In development to 🔬 In review in Plugins Platform / Grafana Community Aug 22, 2025
@s4kh s4kh merged commit 20cddc2 into main Aug 22, 2025
31 checks passed
@s4kh s4kh deleted the feat-plugin-version-optional branch August 22, 2025 14:35
@github-project-automation github-project-automation bot moved this from 🔬 In review to 🚀 Shipped in Plugins Platform / Grafana Community Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Make plugin version optional for cloud_plugin_install
2 participants