Skip to content

Commit

Permalink
Merge pull request #149 from Juniper/bug/146
Browse files Browse the repository at this point in the history
bug #146: Print warning about terraform 1.5.0 go-cty issue
  • Loading branch information
chrismarget-j authored Jun 16, 2023
2 parents 94fe1e3 + f6d0edd commit 7ef0184
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apstra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -151,6 +152,8 @@ type providerConfig struct {
}

func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
terraformVersionWarnings(ctx, req.TerraformVersion, &resp.Diagnostics)

// Retrieve provider data from configuration
var config providerConfig
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
Expand Down Expand Up @@ -352,3 +355,17 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource {
func() resource.Resource { return &resourceVniPool{} },
}
}

func terraformVersionWarnings(ctx context.Context, version string, diags *diag.Diagnostics) {
const tf150warning = "" +
"You're using Terraform %s. Terraform 1.5.0 has a known issue calculating " +
"plans in certain situations. More info at: https://github.com/hashicorp/terraform/issues/33371"

warnings := map[string]string{
"1.5.0": tf150warning,
}

if w, ok := warnings[version]; ok {
diags.AddWarning("known compatibility issue", fmt.Sprintf(w, version))
}
}

0 comments on commit 7ef0184

Please sign in to comment.