Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add variant of CustomizeDiffFunc that returns diag.Diagnostics #1065

Open
gdavison opened this issue Sep 21, 2022 · 1 comment
Open
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@gdavison
Copy link
Contributor

Use-cases

There are times when a CustomizeDiffFunc would ideally return a warning message. The current option is to add a log message, but that is only visible to the practitioner if logging is enabled.

Proposal

Create a variant of CustomizeDiffFunc, e.g., CustomizeDiffFuncDiags, that returns a diag.Diagnostics instead of error.

@gdavison gdavison added the enhancement New feature or request label Sep 21, 2022
@arxeiss
Copy link

arxeiss commented Jan 20, 2023

Yes, please. I would like to see this improvement as well.

Our use case

User can create config in special syntax via Terraform attribute. Or in our Web Console, where they can use Drag 'n' Drop UI Tool.
But, if they do via Terraform, we cannot render diagram in UI tool.

So what can happen is, they use our UI tool to design it and then export that syntax to Terraform.
But after terraform apply the diagram data are lost.

I would like to show them Warning, that by applying changes, diagram will be discarded. But I cannot do that now because.
I have the code below, which shows that warning. But only after applying. So it is a bit late

// "was_configured_via_ui" is set as Computed

// ReadContext function
wasConfiguredViaUI := false
if resp.ConfigType == "ui_rich_json" {
    wasConfiguredViaUI = true
}
data.Set("was_configured_via_ui", wasConfiguredViaUI)

// UpdateContext 
if data.Get("was_configured_via_ui").(bool) {
	*d = append(*d, diag.Diagnostic{
		Severity:      diag.Warning,
		Summary:       "Config was managed by the Console UI. This change will discard UI Diagram.",
	})
}

@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework
Projects
None yet
Development

No branches or pull requests

3 participants