Skip to content

Commit

Permalink
Return if ip already matches
Browse files Browse the repository at this point in the history
  • Loading branch information
jhotmann committed Oct 9, 2023
1 parent 6768ac6 commit fa62a72
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/provider/providers/mikrotik/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,16 @@ func (p *Provider) Update(_ context.Context, _ *http.Client, ip netip.Addr) (new
return netip.Addr{}, fmt.Errorf("%w: unable to retrieve address list items", errors.ErrUnsuccessful)
}

if listItem.found() {
err = p.setListValue(listItem.ID, ip.String())
switch {
case !listItem.found():
err = p.addListValue(p.addressList, ip.String())
if err != nil {
return netip.Addr{}, err
}
} else {
err = p.addListValue(p.addressList, ip.String())
case listItem.Address == ip.String():
return ip, nil
default:
err = p.setListValue(listItem.ID, ip.String())
if err != nil {
return netip.Addr{}, err
}
Expand Down

0 comments on commit fa62a72

Please sign in to comment.