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
 }
diff --git a/metropolis/node/build/mkerofs/main.go b/metropolis/node/build/mkerofs/main.go
index 9cacc59..ac0042a 100644
--- a/metropolis/node/build/mkerofs/main.go
+++ b/metropolis/node/build/mkerofs/main.go
@@ -128,7 +128,7 @@
 
 // pathRef gets the entrySpec at the leaf of the given path, inferring
 // directories if necessary
-func (s *entrySpec) pathRef(p string) *entrySpec {
+func (spec *entrySpec) pathRef(p string) *entrySpec {
 	// This block gets a path array starting at the root of the filesystem. The
 	// root folder is the zero-length array.
 	pathParts := strings.Split(path.Clean("./"+p), "/")
@@ -136,7 +136,7 @@
 		pathParts = pathParts[1:]
 	}
 
-	entryRef := s
+	entryRef := spec
 	for _, part := range pathParts {
 		childRef, ok := entryRef.children[part]
 		if !ok {
diff --git a/metropolis/node/core/rpc/resolver/watcher.go b/metropolis/node/core/rpc/resolver/watcher.go
index 121d731..d2715b6 100644
--- a/metropolis/node/core/rpc/resolver/watcher.go
+++ b/metropolis/node/core/rpc/resolver/watcher.go
@@ -109,16 +109,16 @@
 	}
 }
 
-func (r *clientWatcher) ResolveNow(_ resolver.ResolveNowOptions) {
+func (w *clientWatcher) ResolveNow(_ resolver.ResolveNowOptions) {
 	// No-op. The clientWatcher's watcher runs as fast as possible.
 }
 
-func (r *clientWatcher) Close() {
+func (w *clientWatcher) Close() {
 	select {
-	case <-r.resolver.ctx.Done():
-	case r.resolver.reqC <- &request{
+	case <-w.resolver.ctx.Done():
+	case w.resolver.reqC <- &request{
 		unsub: &requestUnsubscribe{
-			id: r.subscription.id,
+			id: w.subscription.id,
 		},
 	}:
 	}
diff --git a/metropolis/pkg/gpt/gpt.go b/metropolis/pkg/gpt/gpt.go
index fb011c6..58c0527 100644
--- a/metropolis/pkg/gpt/gpt.go
+++ b/metropolis/pkg/gpt/gpt.go
@@ -201,8 +201,8 @@
 // It writes the placement information (FirstBlock, LastBlock) back to p.
 // By default, AddPartition aligns FirstBlock to 1MiB boundaries, but this can
 // be overridden using WithAlignment.
-func (g *Table) AddPartition(p *Partition, size int64, options ...AddOption) error {
-	blockSize := g.b.BlockSize()
+func (gpt *Table) AddPartition(p *Partition, size int64, options ...AddOption) error {
+	blockSize := gpt.b.BlockSize()
 	var opts addOptions
 	// Align to 1MiB or the block size, whichever is bigger
 	opts.alignment = 1 * 1024 * 1024
@@ -219,7 +219,7 @@
 		p.ID = uuid.New()
 	}
 
-	fs, _, err := g.GetFreeSpaces()
+	fs, _, err := gpt.GetFreeSpaces()
 	if err != nil {
 		return fmt.Errorf("unable to determine free space: %v", err)
 	}
@@ -247,7 +247,7 @@
 		end := freeInt[1]
 		freeBlocks := end - start
 		// Align start properly
-		alignTo := (opts.alignment / blockSize)
+		alignTo := opts.alignment / blockSize
 		// Go doesn't implement the euclidean modulus, thus this construction
 		// is necessary.
 		paddingBlocks := ((alignTo - start) % alignTo) % alignTo
@@ -269,7 +269,7 @@
 			}
 			newPartPos := -1
 			if !opts.keepEmptyEntries {
-				for i, part := range g.Partitions {
+				for i, part := range gpt.Partitions {
 					if part.IsUnused() {
 						newPartPos = i
 						break
@@ -277,11 +277,11 @@
 				}
 			}
 			if newPartPos == -1 {
-				g.Partitions = append(g.Partitions, p)
+				gpt.Partitions = append(gpt.Partitions, p)
 			} else {
-				g.Partitions[newPartPos] = p
+				gpt.Partitions[newPartPos] = p
 			}
-			p.Section = blockdev.NewSection(g.b, int64(p.FirstBlock), int64(p.LastBlock)+1)
+			p.Section = blockdev.NewSection(gpt.b, int64(p.FirstBlock), int64(p.LastBlock)+1)
 			return nil
 		}
 	}
@@ -291,18 +291,18 @@
 
 // FirstUsableBlock returns the first usable (i.e. a partition can start there)
 // block.
-func (g *Table) FirstUsableBlock() int64 {
-	blockSize := g.b.BlockSize()
+func (gpt *Table) FirstUsableBlock() int64 {
+	blockSize := gpt.b.BlockSize()
 	partitionEntryBlocks := (16384 + blockSize - 1) / blockSize
 	return 2 + partitionEntryBlocks
 }
 
 // LastUsableBlock returns the last usable (i.e. a partition can end there)
 // block. This block is inclusive.
-func (g *Table) LastUsableBlock() int64 {
-	blockSize := g.b.BlockSize()
+func (gpt *Table) LastUsableBlock() int64 {
+	blockSize := gpt.b.BlockSize()
 	partitionEntryBlocks := (16384 + blockSize - 1) / blockSize
-	return g.b.BlockCount() - (2 + partitionEntryBlocks)
+	return gpt.b.BlockCount() - (2 + partitionEntryBlocks)
 }
 
 // GetFreeSpaces returns a slice of tuples, each containing a half-closed
@@ -315,7 +315,7 @@
 //
 // Note that the most common use cases for this function are covered by
 // AddPartition, you're encouraged to use it instead.
-func (g *Table) GetFreeSpaces() ([][2]int64, bool, error) {
+func (gpt *Table) GetFreeSpaces() ([][2]int64, bool, error) {
 	// This implements an efficient algorithm for finding free intervals given
 	// a set of potentially overlapping occupying intervals. It uses O(n*log n)
 	// time for n being the amount of intervals, i.e. partitions. It uses O(n)
@@ -324,7 +324,7 @@
 	// of its cyclomatic complexity and O(n*log n) is tiny for even very big
 	// partition tables.
 
-	blockCount := g.b.BlockCount()
+	blockCount := gpt.b.BlockCount()
 
 	// startBlocks contains the start blocks (inclusive) of all occupied
 	// intervals.
@@ -335,13 +335,13 @@
 
 	// Reserve the primary GPT interval including the protective MBR.
 	startBlocks = append(startBlocks, 0)
-	endBlocks = append(endBlocks, g.FirstUsableBlock())
+	endBlocks = append(endBlocks, gpt.FirstUsableBlock())
 
 	// Reserve the alternate GPT interval (needs +1 for exclusive interval)
-	startBlocks = append(startBlocks, g.LastUsableBlock()+1)
+	startBlocks = append(startBlocks, gpt.LastUsableBlock()+1)
 	endBlocks = append(endBlocks, blockCount)
 
-	for i, part := range g.Partitions {
+	for i, part := range gpt.Partitions {
 		if part.IsUnused() {
 			continue
 		}
diff --git a/metropolis/pkg/scsi/scsi.go b/metropolis/pkg/scsi/scsi.go
index e2d236e..f09bf44 100644
--- a/metropolis/pkg/scsi/scsi.go
+++ b/metropolis/pkg/scsi/scsi.go
@@ -220,11 +220,11 @@
 }
 
 // String returns the textual representation of this ASK
-func (s AdditionalSenseCode) String() string {
-	if str, ok := additionalSenseCodeDesc[s]; ok {
+func (a AdditionalSenseCode) String() string {
+	if str, ok := additionalSenseCodeDesc[a]; ok {
 		return str
 	}
-	return fmt.Sprintf("unknown additional sense code %xh %xh", s.ASK(), s.ASKQ())
+	return fmt.Sprintf("unknown additional sense code %xh %xh", a.ASK(), a.ASKQ())
 }
 
 // FixedError is one type of error returned by a SCSI CHECK_CONDITION.