treewide: cleanup function receiver names
Change-Id: I0575175ea249a2bd39b4b7769e49a9995fae6f6d
Reviewed-on: https://review.monogon.dev/c/monogon/+/2959
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/cloud/equinix/wrapngo/wrapn.go b/cloud/equinix/wrapngo/wrapn.go
index d249439..4ef7b9b 100644
--- a/cloud/equinix/wrapngo/wrapn.go
+++ b/cloud/equinix/wrapngo/wrapn.go
@@ -228,8 +228,8 @@
ErrNoReservationProvided = errors.New("hardware reservation must be set")
)
-func (e *client) PowerOffDevice(ctx context.Context, pid string) error {
- _, err := wrap(ctx, e, func(p *packngo.Client) (*packngo.Response, error) {
+func (c *client) PowerOffDevice(ctx context.Context, pid string) error {
+ _, err := wrap(ctx, c, func(p *packngo.Client) (*packngo.Response, error) {
r, err := p.Devices.PowerOff(pid)
if err != nil {
return nil, fmt.Errorf("Devices.PowerOff: %w", err)
@@ -239,8 +239,8 @@
return err
}
-func (e *client) PowerOnDevice(ctx context.Context, pid string) error {
- _, err := wrap(ctx, e, func(p *packngo.Client) (*packngo.Response, error) {
+func (c *client) PowerOnDevice(ctx context.Context, pid string) error {
+ _, err := wrap(ctx, c, func(p *packngo.Client) (*packngo.Response, error) {
r, err := p.Devices.PowerOn(pid)
if err != nil {
return nil, fmt.Errorf("Devices.PowerOn: %w", err)
@@ -250,8 +250,8 @@
return err
}
-func (e *client) DeleteDevice(ctx context.Context, id string) error {
- _, err := wrap(ctx, e, func(p *packngo.Client) (*packngo.Response, error) {
+func (c *client) DeleteDevice(ctx context.Context, id string) error {
+ _, err := wrap(ctx, c, func(p *packngo.Client) (*packngo.Response, error) {
r, err := p.Devices.Delete(id, false)
if err != nil {
return nil, fmt.Errorf("Devices.Delete: %w", err)
@@ -261,7 +261,7 @@
return err
}
-func (e *client) CreateDevice(ctx context.Context, r *packngo.DeviceCreateRequest) (*packngo.Device, error) {
+func (c *client) CreateDevice(ctx context.Context, r *packngo.DeviceCreateRequest) (*packngo.Device, error) {
if r.HardwareReservationID == "" {
return nil, ErrNoReservationProvided
}
@@ -270,7 +270,7 @@
witnessTag := fmt.Sprintf("wrapngo-idempotency-%s", uuid.New().String())
r.Tags = append(r.Tags, witnessTag)
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.Device, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.Device, error) {
//Does the device already exist?
res, _, err := cl.HardwareReservations.Get(r.HardwareReservationID, nil)
if err != nil {
@@ -303,31 +303,31 @@
})
}
-func (e *client) UpdateDevice(ctx context.Context, id string, r *packngo.DeviceUpdateRequest) (*packngo.Device, error) {
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.Device, error) {
+func (c *client) UpdateDevice(ctx context.Context, id string, r *packngo.DeviceUpdateRequest) (*packngo.Device, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.Device, error) {
dev, _, err := cl.Devices.Update(id, r)
return dev, err
})
}
-func (e *client) ListDevices(ctx context.Context, pid string) ([]packngo.Device, error) {
- return wrap(ctx, e, func(cl *packngo.Client) ([]packngo.Device, error) {
+func (c *client) ListDevices(ctx context.Context, pid string) ([]packngo.Device, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) ([]packngo.Device, error) {
// to increase the chances of a stable pagination, we sort the devices by hostname
res, _, err := cl.Devices.List(pid, &packngo.GetOptions{SortBy: "hostname"})
return res, err
})
}
-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) {
+func (c *client) GetDevice(ctx context.Context, pid, did string, opts *packngo.ListOptions) (*packngo.Device, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.Device, error) {
d, _, err := cl.Devices.Get(did, opts)
return d, err
})
}
// Currently unexported, only used in tests.
-func (e *client) deleteDevice(ctx context.Context, did string) error {
- _, err := wrap(ctx, e, func(cl *packngo.Client) (*struct{}, error) {
+func (c *client) deleteDevice(ctx context.Context, did string) error {
+ _, err := wrap(ctx, c, func(cl *packngo.Client) (*struct{}, error) {
_, err := cl.Devices.Delete(did, false)
if httpStatusCode(err) == http.StatusNotFound {
// 404s may pop up as an after effect of running the back-off
@@ -339,15 +339,15 @@
return err
}
-func (e *client) ListReservations(ctx context.Context, pid string) ([]packngo.HardwareReservation, error) {
- return wrap(ctx, e, func(cl *packngo.Client) ([]packngo.HardwareReservation, error) {
+func (c *client) ListReservations(ctx context.Context, pid string) ([]packngo.HardwareReservation, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) ([]packngo.HardwareReservation, error) {
res, _, err := cl.HardwareReservations.List(pid, &packngo.ListOptions{Includes: []string{"facility", "device"}})
return res, err
})
}
-func (e *client) MoveReservation(ctx context.Context, hardwareReservationDID, projectID string) (*packngo.HardwareReservation, error) {
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.HardwareReservation, error) {
+func (c *client) MoveReservation(ctx context.Context, hardwareReservationDID, projectID string) (*packngo.HardwareReservation, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.HardwareReservation, error) {
hr, _, err := cl.HardwareReservations.Move(hardwareReservationDID, projectID)
if err != nil {
return nil, fmt.Errorf("HardwareReservations.Move: %w", err)
@@ -356,8 +356,8 @@
})
}
-func (e *client) CreateSSHKey(ctx context.Context, r *packngo.SSHKeyCreateRequest) (*packngo.SSHKey, error) {
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.SSHKey, error) {
+func (c *client) CreateSSHKey(ctx context.Context, r *packngo.SSHKeyCreateRequest) (*packngo.SSHKey, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.SSHKey, error) {
// Does the key already exist?
ks, _, err := cl.SSHKeys.List()
if err != nil {
@@ -381,8 +381,8 @@
})
}
-func (e *client) UpdateSSHKey(ctx context.Context, id string, r *packngo.SSHKeyUpdateRequest) (*packngo.SSHKey, error) {
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.SSHKey, error) {
+func (c *client) UpdateSSHKey(ctx context.Context, id string, r *packngo.SSHKeyUpdateRequest) (*packngo.SSHKey, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.SSHKey, error) {
k, _, err := cl.SSHKeys.Update(id, r)
if err != nil {
return nil, fmt.Errorf("SSHKeys.Update: %w", err)
@@ -392,8 +392,8 @@
}
// Currently unexported, only used in tests.
-func (e *client) deleteSSHKey(ctx context.Context, id string) error {
- _, err := wrap(ctx, e, func(cl *packngo.Client) (struct{}, error) {
+func (c *client) deleteSSHKey(ctx context.Context, id string) error {
+ _, err := wrap(ctx, c, func(cl *packngo.Client) (struct{}, error) {
_, err := cl.SSHKeys.Delete(id)
if err != nil {
return struct{}{}, fmt.Errorf("SSHKeys.Delete: %w", err)
@@ -403,8 +403,8 @@
return err
}
-func (e *client) ListSSHKeys(ctx context.Context) ([]packngo.SSHKey, error) {
- return wrap(ctx, e, func(cl *packngo.Client) ([]packngo.SSHKey, error) {
+func (c *client) ListSSHKeys(ctx context.Context) ([]packngo.SSHKey, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) ([]packngo.SSHKey, error) {
ks, _, err := cl.SSHKeys.List()
if err != nil {
return nil, fmt.Errorf("SSHKeys.List: %w", err)
@@ -414,8 +414,8 @@
}
// Currently unexported, only used in tests.
-func (e *client) getSSHKey(ctx context.Context, id string) (*packngo.SSHKey, error) {
- return wrap(ctx, e, func(cl *packngo.Client) (*packngo.SSHKey, error) {
+func (c *client) getSSHKey(ctx context.Context, id string) (*packngo.SSHKey, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) (*packngo.SSHKey, error) {
k, _, err := cl.SSHKeys.Get(id, nil)
if err != nil {
return nil, fmt.Errorf("SSHKeys.Get: %w", err)
@@ -424,8 +424,8 @@
})
}
-func (e *client) RebootDevice(ctx context.Context, did string) error {
- _, err := wrap(ctx, e, func(cl *packngo.Client) (struct{}, error) {
+func (c *client) RebootDevice(ctx context.Context, did string) error {
+ _, err := wrap(ctx, c, func(cl *packngo.Client) (struct{}, error) {
_, err := cl.Devices.Reboot(did)
return struct{}{}, err
})
diff --git a/cloud/lib/component/crdb.go b/cloud/lib/component/crdb.go
index aae1f77..0bdbb4d 100644
--- a/cloud/lib/component/crdb.go
+++ b/cloud/lib/component/crdb.go
@@ -126,18 +126,18 @@
// Connect returns a working *sql.DB handle to the database described by this
// CockroachConfig.
-func (d *CockroachConfig) Connect() (*sql.DB, error) {
- dsn := d.buildDSN("postgres")
+func (c *CockroachConfig) Connect() (*sql.DB, error) {
+ dsn := c.buildDSN("postgres")
klog.Infof("Connecting to %s...", dsn)
- return sql.Open("postgres", d.buildDSN("postgres"))
+ return sql.Open("postgres", c.buildDSN("postgres"))
}
// MigrateUp performs all possible migrations upwards for the database described
// by this CockroachConfig.
-func (d *CockroachConfig) MigrateUp() error {
- dsn := d.buildDSN("cockroachdb")
+func (c *CockroachConfig) MigrateUp() error {
+ dsn := c.buildDSN("cockroachdb")
klog.Infof("Running migrations up...")
- m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
+ m, err := migrate.NewWithSourceInstance("iofs", c.Migrations, dsn)
if err != nil {
return err
}
@@ -152,10 +152,10 @@
}
}
-func (d *CockroachConfig) MigrateUpToIncluding(ver uint) error {
- dsn := d.buildDSN("cockroachdb")
+func (c *CockroachConfig) MigrateUpToIncluding(ver uint) error {
+ dsn := c.buildDSN("cockroachdb")
klog.Infof("Running migrations up to %d...", ver)
- m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
+ m, err := migrate.NewWithSourceInstance("iofs", c.Migrations, dsn)
if err != nil {
return err
}
@@ -171,18 +171,18 @@
// Obviously, this is a dangerous method. Thus, to prevent accidental nuking of
// production data, we currently only allow this to be performed on InMemory
// databases.
-func (d *CockroachConfig) MigrateDownDangerDanger() error {
- if !d.InMemory {
+func (c *CockroachConfig) MigrateDownDangerDanger() error {
+ if !c.InMemory {
return fmt.Errorf("refusing to migrate down a non-in-memory database")
}
// Sneaky extra check to make sure the caller didn't just set InMemory after
// connecting to an external database. We really need to be safe here.
- if d.inMemoryInstance == nil {
+ if c.inMemoryInstance == nil {
return fmt.Errorf("no really, this cannot be run on non-in-memory databases")
}
- dsn := d.buildDSN("cockroachdb")
+ dsn := c.buildDSN("cockroachdb")
klog.Infof("Running migrations down...")
- m, err := migrate.NewWithSourceInstance("iofs", d.Migrations, dsn)
+ m, err := migrate.NewWithSourceInstance("iofs", c.Migrations, dsn)
if err != nil {
return err
}
@@ -192,7 +192,7 @@
if err != nil {
return fmt.Errorf("could not retrieve remote version: %w", err)
}
- if v2, err := d.Migrations.Next(v); !os.IsNotExist(err) {
+ if v2, err := c.Migrations.Next(v); !os.IsNotExist(err) {
return fmt.Errorf("remote running version %d, but we know %d which is newer", v, v2)
}
return m.Down()
diff --git a/cloud/shepherd/provider/equinix/updater.go b/cloud/shepherd/provider/equinix/updater.go
index 56d78c1..15b218b 100644
--- a/cloud/shepherd/provider/equinix/updater.go
+++ b/cloud/shepherd/provider/equinix/updater.go
@@ -41,9 +41,9 @@
cl ecl.Client
}
-func (c *UpdaterConfig) New(cl ecl.Client) (*Updater, error) {
+func (u *UpdaterConfig) New(cl ecl.Client) (*Updater, error) {
return &Updater{
- config: c,
+ config: u,
cl: cl,
}, nil
}