Skip to content

Commit

Permalink
Merge pull request #350 from Juniper/feat/343-more-generic-system-lin…
Browse files Browse the repository at this point in the history
…k-validation

Add generic system validation: `lag_mode` required with multiple links
  • Loading branch information
chrismarget-j authored Sep 7, 2023
2 parents e4d2d2e + c229080 commit 893b266
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions apstra/blueprint/datacenter_generic_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,24 @@ func (o genericSystemLinkSetValidator) ValidateSet(ctx context.Context, req vali

lagMode := link.LagMode.ValueString()
groupLabel := link.GroupLabel.ValueString()
if m, ok := groupModes[groupLabel]; ok {
if m != lagMode {
if groupMode, ok := groupModes[groupLabel]; ok {
// we have seen this group label before

if link.LagMode.IsNull() {
resp.Diagnostics.Append(
validatordiag.InvalidAttributeCombinationDiagnostic(
req.Path,
fmt.Sprintf("because multiple interfaces share group label %q, lag_mode must be set",
groupLabel)))
return
}

if groupMode != lagMode {
resp.Diagnostics.Append(
validatordiag.InvalidAttributeCombinationDiagnostic(
req.Path,
fmt.Sprintf("interfaces with group label %q have mismatched 'lag_mode': %q and %q",
groupLabel, m, lagMode),
),
)
groupLabel, groupMode, lagMode)))
return
}
} else {
Expand Down

0 comments on commit 893b266

Please sign in to comment.