Skip to content

Commit

Permalink
Merge pull request #53 from Juniper/issue-48-interface-map-order
Browse files Browse the repository at this point in the history
Issue 48 - interface map sort order
  • Loading branch information
chrismarget-j authored Apr 26, 2023
2 parents ef8ac8d + c1844c0 commit 7f1719d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apstra/resource_interface_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"regexp"
"sort"
"strconv"
"strings"
)
Expand Down Expand Up @@ -381,12 +382,14 @@ func (o *rInterfaceMap) validatePortSelections(ctx context.Context, ld *apstra.L
}

if len(bogusPortNames) > 0 {
sort.Strings(bogusPortNames)
diags.AddError(errInvalidConfig,
fmt.Sprintf("ports '%s' not defined by logical device '%s'",
strings.Join(bogusPortNames, ","), ld.Id))
}

if len(requiredPortNames) != 0 {
sort.Strings(requiredPortNames)
diags.AddError(errInvalidConfig,
fmt.Sprintf("ports '%s' required by logical device '%s' must be specified",
strings.Join(requiredPortNames, ","), ld.Id))
Expand Down Expand Up @@ -542,7 +545,7 @@ func (o *rInterfaceMap) iMapInterfaces(ctx context.Context, ld *apstra.LogicalDe
LDPort: ldPort,
},
ActiveState: transformInterface.State == "active",
Position: i + 1,
Position: portId,
Speed: transformInterface.Speed,
Setting: apstra.InterfaceMapInterfaceSetting{
Param: transformation.Interfaces[interfaceIdx].Setting,
Expand Down Expand Up @@ -851,7 +854,7 @@ func iMapUnallocaedInterfaces(allocatedPorts []apstra.InterfaceMapInterface, dp
LDPort: -1,
},
ActiveState: true, // unclear what this is, UI sets "active"
Position: allocatedPortCount + i + 1,
Position: dpPort.PortId,
Speed: transformation.Interfaces[0].Speed,
Setting: apstra.InterfaceMapInterfaceSetting{Param: transformation.Interfaces[0].Setting},
}
Expand Down

0 comments on commit 7f1719d

Please sign in to comment.