Skip to content

Commit

Permalink
fix: unassign IPs correctly for Equinix Metal
Browse files Browse the repository at this point in the history
IP assignment href returned from the API looks like:

```
/metal/v1/ips/97972920-f00b-453f-be1e-31eb53c19e38
```

It should be cleaned up to contain ID only, removing `/ips/` leads to
broken requests like:

```
2021/04/15 12:03:41 [DEBUG] DELETE https://api.equinix.com/metal/v1/ips//metal/v197972920-f00b-453f-be1e-31eb53c19e38
```

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira committed Apr 15, 2021
1 parent 5a32bd5 commit 7c4d919
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/packet/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package packet

import (
"fmt"
"strings"
"path"

"github.com/packethost/packngo"
"github.com/plunder-app/kube-vip/pkg/kubevip"
Expand All @@ -26,7 +26,7 @@ func AttachEIP(c *packngo.Client, k *kubevip.Config, hostname string) error {
log.Infof("Found EIP ->%s ID -> %s\n", ip.Address, ip.ID)
// If attachements already exist then remove them
if len(ip.Assignments) != 0 {
hrefID := strings.Replace(ip.Assignments[0].Href, "/ips/", "", -1)
hrefID := path.Base(ip.Assignments[0].Href)
c.DeviceIPs.Unassign(hrefID)
}
}
Expand Down

0 comments on commit 7c4d919

Please sign in to comment.