cloud/shepherd/equinix/wrapngo: allow specifying options when getting device
Change-Id: Ib1f4a88d1a45d9c0da1c56bd8ee21bf18302d9f8
Reviewed-on: https://review.monogon.dev/c/monogon/+/1576
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/cloud/shepherd/equinix/wrapngo/wrapn.go b/cloud/shepherd/equinix/wrapngo/wrapn.go
index dc54340..4bdc314 100644
--- a/cloud/shepherd/equinix/wrapngo/wrapn.go
+++ b/cloud/shepherd/equinix/wrapngo/wrapn.go
@@ -86,7 +86,9 @@
// is provided to allow for dependency injection of a fake equinix API for tests.
type Client interface {
// GetDevice wraps packngo's cl.Devices.Get.
- GetDevice(ctx context.Context, pid, did string) (*packngo.Device, error)
+ //
+ // TODO(q3k): remove unused pid parameter.
+ GetDevice(ctx context.Context, pid, did string, opts *packngo.ListOptions) (*packngo.Device, error)
// ListDevices wraps packngo's cl.Device.List.
ListDevices(ctx context.Context, pid string) ([]packngo.Device, error)
// CreateDevice attempts to create a new device according to the provided
@@ -220,9 +222,9 @@
})
}
-func (e *client) GetDevice(ctx context.Context, pid, did string) (*packngo.Device, error) {
+func (e *client) GetDevice(ctx context.Context, pid, did string, opts *packngo.ListOptions) (*packngo.Device, error) {
return wrap(ctx, e, func(cl *packngo.Client) (*packngo.Device, error) {
- d, _, err := cl.Devices.Get(did, nil)
+ d, _, err := cl.Devices.Get(did, opts)
return d, err
})
}
diff --git a/cloud/shepherd/equinix/wrapngo/wrapngo_live_test.go b/cloud/shepherd/equinix/wrapngo/wrapngo_live_test.go
index 5a8d194..549071a 100644
--- a/cloud/shepherd/equinix/wrapngo/wrapngo_live_test.go
+++ b/cloud/shepherd/equinix/wrapngo/wrapngo_live_test.go
@@ -70,7 +70,7 @@
t.Helper()
for {
- d, err := l.cl.GetDevice(l.ctx, l.apipid, id)
+ d, err := l.cl.GetDevice(l.ctx, l.apipid, id, nil)
if err != nil {
if errors.Is(err, os.ErrDeadlineExceeded) {
continue
@@ -277,7 +277,7 @@
t.Skip("the test device couldn't have been created - skipping...")
}
- d, err := cl.GetDevice(ctx, ltc.apipid, testDevice.ID)
+ d, err := cl.GetDevice(ctx, ltc.apipid, testDevice.ID, nil)
if err != nil {
t.Fatalf("while fetching device info: %v", err)
}
@@ -315,7 +315,7 @@
if err := cl.deleteDevice(ctx, testDevice.ID); err != nil {
t.Fatalf("while deleting a device: %v", err)
}
- d, err := cl.GetDevice(ctx, ltc.apipid, testDevice.ID)
+ d, err := cl.GetDevice(ctx, ltc.apipid, testDevice.ID, nil)
if err != nil && !IsNotFound(err) {
t.Fatalf("while fetching device info: %v", err)
}