diff --git a/apstra/api_versions/versions.go b/apstra/api_versions/versions.go index fcf85adc..f84f4e8b 100644 --- a/apstra/api_versions/versions.go +++ b/apstra/api_versions/versions.go @@ -13,6 +13,5 @@ const ( Apstra422 = "4.2.2" Apstra500 = "5.0.0" - Le420 = "<=" + Apstra420 LtApstra500 = "<" + Apstra500 ) diff --git a/apstra/compatibility/constraints.go b/apstra/compatibility/constraints.go index 9b9446dd..8c21e650 100644 --- a/apstra/compatibility/constraints.go +++ b/apstra/compatibility/constraints.go @@ -6,7 +6,8 @@ import ( ) var ( - BpIbaDashboardOk = versionconstraints.New(apiversions.LtApstra500) - BpIbaProbeOk = versionconstraints.New(apiversions.LtApstra500) - BpIbaWidgetOk = versionconstraints.New(apiversions.LtApstra500) + BpIbaDashboardOk = versionconstraints.New(apiversions.LtApstra500) + BpIbaProbeOk = versionconstraints.New(apiversions.LtApstra500) + BpIbaWidgetOk = versionconstraints.New(apiversions.LtApstra500) + TemplateRequiresAntiAffinityPolicy = versionconstraints.New(apiversions.Apstra420) ) diff --git a/apstra/resource_template_collapsed.go b/apstra/resource_template_collapsed.go index c2cd260e..77dd3bd7 100644 --- a/apstra/resource_template_collapsed.go +++ b/apstra/resource_template_collapsed.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "github.com/Juniper/apstra-go-sdk/apstra" - apiversions "github.com/Juniper/terraform-provider-apstra/apstra/api_versions" + "github.com/Juniper/apstra-go-sdk/apstra/compatibility" "github.com/Juniper/terraform-provider-apstra/apstra/design" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/go-version" @@ -57,7 +57,7 @@ func (o *resourceTemplateCollapsed) Create(ctx context.Context, req resource.Cre } // Apstra <= 4.2.0 requires an anti-affinity policy in the request - if version.MustConstraints(version.NewConstraint(apiversions.Le420)).Check(apiVer) { + if compatibility.TemplateRequestRequiresAntiAffinityPolicy.Check(apiVer) { request.AntiAffinityPolicy = &apstra.AntiAffinityPolicy{ Algorithm: apstra.AlgorithmHeuristic, Mode: apstra.AntiAffinityModeDisabled, @@ -136,7 +136,7 @@ func (o *resourceTemplateCollapsed) Update(ctx context.Context, req resource.Upd } // Apstra <= 4.2.0 requires an anti-affinity policy in the request - if version.MustConstraints(version.NewConstraint(apiversions.Le420)).Check(apiVer) { + if compatibility.TemplateRequestRequiresAntiAffinityPolicy.Check(apiVer) { request.AntiAffinityPolicy = &apstra.AntiAffinityPolicy{ Algorithm: apstra.AlgorithmHeuristic, Mode: apstra.AntiAffinityModeDisabled,