Skip to content

Commit

Permalink
Merge pull request #885 from Juniper/866-remove-references-to-le420
Browse files Browse the repository at this point in the history
add constraint and adjust checks
  • Loading branch information
bwJuniper authored Oct 1, 2024
2 parents 0cf8ec5 + be03cea commit 34fc0b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion apstra/api_versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ const (
Apstra422 = "4.2.2"
Apstra500 = "5.0.0"

Le420 = "<=" + Apstra420
LtApstra500 = "<" + Apstra500
)
7 changes: 4 additions & 3 deletions apstra/compatibility/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
6 changes: 3 additions & 3 deletions apstra/resource_template_collapsed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 34fc0b7

Please sign in to comment.