Skip to content

Commit 82c818b

Browse files
committed
incusd: Remove unused parameters or rename unused parameters to _
Signed-off-by: karo <[email protected]>
1 parent 102bca1 commit 82c818b

24 files changed

+79
-86
lines changed

cmd/incusd/api_cluster_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestCluster_Bootstrap(t *testing.T) {
3737
// request is issued to set both core.https_address and
3838
// cluster.https_address to the same value.
3939
f := clusterFixture{t: t}
40-
f.EnableNetworkingWithClusterAddress(daemon, "")
40+
f.EnableNetworkingWithClusterAddress(daemon)
4141

4242
client := f.ClientUnix(daemon)
4343

@@ -74,7 +74,7 @@ func TestCluster_RenameNode(t *testing.T) {
7474
defer cleanup()
7575

7676
f := clusterFixture{t: t}
77-
f.EnableNetworking(daemon, "")
77+
f.EnableNetworking(daemon)
7878

7979
client := f.ClientUnix(daemon)
8080

@@ -101,7 +101,7 @@ type clusterFixture struct {
101101

102102
// Enable networking in the given daemon. The password is optional and can be
103103
// an empty string.
104-
func (f *clusterFixture) EnableNetworking(daemon *Daemon, password string) {
104+
func (f *clusterFixture) EnableNetworking(daemon *Daemon) {
105105
port, err := allocatePort()
106106
require.NoError(f.t, err)
107107

@@ -119,7 +119,7 @@ func (f *clusterFixture) EnableNetworking(daemon *Daemon, password string) {
119119
// Enable networking in the given daemon, and set cluster.https_address to the
120120
// same value as core.https address. The password is optional and can be an
121121
// empty string.
122-
func (f *clusterFixture) EnableNetworkingWithClusterAddress(daemon *Daemon, password string) {
122+
func (f *clusterFixture) EnableNetworkingWithClusterAddress(daemon *Daemon) {
123123
port, err := allocatePort()
124124
require.NoError(f.t, err)
125125

cmd/incusd/api_internal.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func internalOptimizeImage(d *Daemon, r *http.Request) response.Response {
264264
return response.EmptySyncResponse
265265
}
266266

267-
func internalRefreshImage(d *Daemon, r *http.Request) response.Response {
267+
func internalRefreshImage(d *Daemon, _ *http.Request) response.Response {
268268
s := d.State()
269269

270270
err := autoUpdateImages(s.ShutdownCtx, s)
@@ -275,7 +275,7 @@ func internalRefreshImage(d *Daemon, r *http.Request) response.Response {
275275
return response.EmptySyncResponse
276276
}
277277

278-
func internalWaitReady(d *Daemon, r *http.Request) response.Response {
278+
func internalWaitReady(d *Daemon, _ *http.Request) response.Response {
279279
// Check that we're not shutting down.
280280
isClosing := d.State().ShutdownCtx.Err() != nil
281281
if isClosing {
@@ -1089,7 +1089,7 @@ func internalImportRootDevicePopulate(instancePoolName string, localDevices map[
10891089
}
10901090
}
10911091

1092-
func internalGC(d *Daemon, r *http.Request) response.Response {
1092+
func internalGC(_ *Daemon, _ *http.Request) response.Response {
10931093
logger.Infof("Started forced garbage collection run")
10941094
runtime.GC()
10951095
runtimeDebug.FreeOSMemory()
@@ -1106,19 +1106,19 @@ func internalGC(d *Daemon, r *http.Request) response.Response {
11061106
return response.EmptySyncResponse
11071107
}
11081108

1109-
func internalRAFTSnapshot(d *Daemon, r *http.Request) response.Response {
1109+
func internalRAFTSnapshot(_ *Daemon, _ *http.Request) response.Response {
11101110
logger.Warn("Forced RAFT snapshot not supported")
11111111

11121112
return response.InternalError(fmt.Errorf("Not supported"))
11131113
}
11141114

1115-
func internalBGPState(d *Daemon, r *http.Request) response.Response {
1115+
func internalBGPState(d *Daemon, _ *http.Request) response.Response {
11161116
s := d.State()
11171117

11181118
return response.SyncResponse(true, s.BGP.Debug())
11191119
}
11201120

1121-
func internalRebalanceLoad(d *Daemon, r *http.Request) response.Response {
1121+
func internalRebalanceLoad(d *Daemon, _ *http.Request) response.Response {
11221122
err := autoRebalanceCluster(context.TODO(), d)
11231123
if err != nil {
11241124
return response.SmartError(err)

cmd/incusd/api_os.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var apiOS = APIEndpoint{
2222
Head: APIEndpointAction{Handler: apiOSProxy, AccessHandler: allowPermission(auth.ObjectTypeServer, auth.EntitlementCanEdit)},
2323
}
2424

25-
func apiOSProxy(d *Daemon, r *http.Request) response.Response {
25+
func apiOSProxy(_ *Daemon, r *http.Request) response.Response {
2626
// Check if this is an Incus OS system.
2727
if !util.PathExists("/run/incus-os/unix.socket") {
2828
return response.BadRequest(errors.New("System isn't running Incus OS"))

cmd/incusd/backup.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func volumeBackupCreate(s *state.State, args db.StoragePoolVolumeBackup, project
497497

498498
// Write index file.
499499
l.Debug("Adding backup index file")
500-
err = volumeBackupWriteIndex(s, projectName, volumeName, pool, backupRow.OptimizedStorage, !backupRow.VolumeOnly, tarWriter)
500+
err = volumeBackupWriteIndex(projectName, volumeName, pool, backupRow.OptimizedStorage, !backupRow.VolumeOnly, tarWriter)
501501

502502
// Check compression errors.
503503
if compressErr != nil {
@@ -541,7 +541,7 @@ func volumeBackupCreate(s *state.State, args db.StoragePoolVolumeBackup, project
541541
}
542542

543543
// volumeBackupWriteIndex generates an index.yaml file and then writes it to the root of the backup tarball.
544-
func volumeBackupWriteIndex(s *state.State, projectName string, volumeName string, pool storagePools.Pool, optimized bool, snapshots bool, tarWriter *instancewriter.InstanceTarWriter) error {
544+
func volumeBackupWriteIndex(projectName string, volumeName string, pool storagePools.Pool, optimized bool, snapshots bool, tarWriter *instancewriter.InstanceTarWriter) error {
545545
// Indicate whether the driver will include a driver-specific optimized header.
546546
poolDriverOptimizedHeader := false
547547
if optimized {
@@ -743,7 +743,7 @@ func bucketBackupCreate(s *state.State, args db.StoragePoolBucketBackup, project
743743

744744
// Write index file.
745745
l.Debug("Adding backup index file")
746-
err = bucketBackupWriteIndex(s, projectName, bucketName, pool, tarWriter)
746+
err = bucketBackupWriteIndex(projectName, bucketName, pool, tarWriter)
747747

748748
// Check compression errors.
749749
if compressErr != nil {
@@ -787,7 +787,7 @@ func bucketBackupCreate(s *state.State, args db.StoragePoolBucketBackup, project
787787
}
788788

789789
// bucketBackupWriteIndex generates an index.yaml file and then writes it to the root of the backup tarball.
790-
func bucketBackupWriteIndex(s *state.State, projectName string, bucketName string, pool storagePools.Pool, tarWriter *instancewriter.InstanceTarWriter) error {
790+
func bucketBackupWriteIndex(projectName string, bucketName string, pool storagePools.Pool, tarWriter *instancewriter.InstanceTarWriter) error {
791791
config, err := pool.GenerateBucketBackupConfig(projectName, bucketName, nil)
792792
if err != nil {
793793
return fmt.Errorf("Failed generating storage backup config: %w", err)

cmd/incusd/daemon.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ func (d *Daemon) init() error {
13601360

13611361
// Mount the storage pools.
13621362
logger.Infof("Initializing storage pools")
1363-
err = storageStartup(d.State(), false)
1363+
err = storageStartup(d.State())
13641364
if err != nil {
13651365
return err
13661366
}
@@ -1830,7 +1830,7 @@ func (d *Daemon) Stop(ctx context.Context, sig os.Signal) error {
18301830

18311831
// Full shutdown requested.
18321832
if sig == unix.SIGPWR {
1833-
instancesShutdown(s, instances)
1833+
instancesShutdown(instances)
18341834

18351835
logger.Info("Stopping networks")
18361836
networkShutdown(s)
@@ -2336,7 +2336,7 @@ func (d *Daemon) hasMemberStateChanged(heartbeatData *cluster.APIHeartbeat) bool
23362336
}
23372337

23382338
// heartbeatHandler handles heartbeat requests from other cluster members.
2339-
func (d *Daemon) heartbeatHandler(w http.ResponseWriter, r *http.Request, isLeader bool, hbData *cluster.APIHeartbeat) {
2339+
func (d *Daemon) heartbeatHandler(w http.ResponseWriter, _ *http.Request, isLeader bool, hbData *cluster.APIHeartbeat) {
23402340
s := d.State()
23412341

23422342
var err error

cmd/incusd/dev_incus_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type DevIncusDialer struct {
2323
Path string
2424
}
2525

26-
func (d DevIncusDialer) DevIncusDial(ctx context.Context, network, path string) (net.Conn, error) {
26+
func (d DevIncusDialer) DevIncusDial(context.Context, string, string) (net.Conn, error) {
2727
addr, err := net.ResolveUnixAddr("unix", d.Path)
2828
if err != nil {
2929
return nil, err

cmd/incusd/instance.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func instanceImageTransfer(s *state.State, r *http.Request, projectName string,
9090
return nil
9191
}
9292

93-
func ensureImageIsLocallyAvailable(ctx context.Context, s *state.State, r *http.Request, img *api.Image, projectName string, instanceType instancetype.Type) error {
93+
func ensureImageIsLocallyAvailable(ctx context.Context, s *state.State, r *http.Request, img *api.Image, projectName string) error {
9494
// Check if the image is available locally or it's on another member.
9595
// Ensure we are the only ones operating on this image. Otherwise another instance created at the same
9696
// time may also arrive at the conclusion that the image doesn't exist on this cluster member and then
@@ -134,7 +134,7 @@ func ensureImageIsLocallyAvailable(ctx context.Context, s *state.State, r *http.
134134
}
135135

136136
// instanceCreateFromImage creates an instance from a rootfs image.
137-
func instanceCreateFromImage(ctx context.Context, s *state.State, r *http.Request, img *api.Image, args db.InstanceArgs, op *operations.Operation) error {
137+
func instanceCreateFromImage(ctx context.Context, s *state.State, img *api.Image, args db.InstanceArgs, op *operations.Operation) error {
138138
reverter := revert.New()
139139
defer reverter.Fail()
140140

@@ -289,7 +289,7 @@ func instanceRebuildFromImage(ctx context.Context, s *state.State, r *http.Reque
289289
return fmt.Errorf("Requested image's type %q doesn't match instance type %q", imgType, inst.Type())
290290
}
291291

292-
err = ensureImageIsLocallyAvailable(ctx, s, r, img, inst.Project().Name, inst.Type())
292+
err = ensureImageIsLocallyAvailable(ctx, s, r, img, inst.Project().Name)
293293
if err != nil {
294294
return err
295295
}
@@ -302,7 +302,7 @@ func instanceRebuildFromImage(ctx context.Context, s *state.State, r *http.Reque
302302
return nil
303303
}
304304

305-
func instanceRebuildFromEmpty(s *state.State, inst instance.Instance, op *operations.Operation) error {
305+
func instanceRebuildFromEmpty(inst instance.Instance, op *operations.Operation) error {
306306
err := inst.Rebuild(nil, op) // Rebuild as empty.
307307
if err != nil {
308308
return fmt.Errorf("Failed rebuilding as an empty instance: %w", err)
@@ -588,7 +588,7 @@ func autoCreateInstanceSnapshots(ctx context.Context, s *state.State, instances
588588

589589
var instSnapshotsPruneRunning = sync.Map{}
590590

591-
func pruneExpiredInstanceSnapshots(ctx context.Context, s *state.State, snapshots []instance.Instance) error {
591+
func pruneExpiredInstanceSnapshots(ctx context.Context, snapshots []instance.Instance) error {
592592
// Find snapshots to delete
593593
for _, snapshot := range snapshots {
594594
err := ctx.Err()
@@ -736,7 +736,7 @@ func pruneExpiredAndAutoCreateInstanceSnapshotsTask(d *Daemon) (task.Func, task.
736736
// disk space.
737737
if len(expiredSnapshotInstances) > 0 {
738738
opRun := func(op *operations.Operation) error {
739-
return pruneExpiredInstanceSnapshots(ctx, s, expiredSnapshotInstances)
739+
return pruneExpiredInstanceSnapshots(ctx, expiredSnapshotInstances)
740740
}
741741

742742
op, err := operations.OperationCreate(s, "", operations.OperationClassTask, operationtype.SnapshotsExpire, nil, nil, opRun, nil, nil, nil)

cmd/incusd/instance_console.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ func (s *consoleWs) Metadata() any {
8383
return jmap.Map{"fds": fds}
8484
}
8585

86-
func (s *consoleWs) Connect(op *operations.Operation, r *http.Request, w http.ResponseWriter) error {
86+
func (s *consoleWs) Connect(_ *operations.Operation, r *http.Request, w http.ResponseWriter) error {
8787
switch s.protocol {
8888
case instance.ConsoleTypeConsole:
89-
return s.connectConsole(op, r, w)
89+
return s.connectConsole(r, w)
9090
case instance.ConsoleTypeVGA:
91-
return s.connectVGA(op, r, w)
91+
return s.connectVGA(r, w)
9292
default:
9393
return fmt.Errorf("Unknown protocol %q", s.protocol)
9494
}
9595
}
9696

97-
func (s *consoleWs) connectConsole(op *operations.Operation, r *http.Request, w http.ResponseWriter) error {
97+
func (s *consoleWs) connectConsole(r *http.Request, w http.ResponseWriter) error {
9898
secret := r.FormValue("secret")
9999
if secret == "" {
100100
return fmt.Errorf("missing secret")
@@ -135,7 +135,7 @@ func (s *consoleWs) connectConsole(op *operations.Operation, r *http.Request, w
135135
return os.ErrPermission
136136
}
137137

138-
func (s *consoleWs) connectVGA(op *operations.Operation, r *http.Request, w http.ResponseWriter) error {
138+
func (s *consoleWs) connectVGA(r *http.Request, w http.ResponseWriter) error {
139139
secret := r.FormValue("secret")
140140
if secret == "" {
141141
return fmt.Errorf("missing secret")
@@ -201,15 +201,15 @@ func (s *consoleWs) Do(op *operations.Operation) error {
201201

202202
switch s.protocol {
203203
case instance.ConsoleTypeConsole:
204-
return s.doConsole(op)
204+
return s.doConsole()
205205
case instance.ConsoleTypeVGA:
206-
return s.doVGA(op)
206+
return s.doVGA()
207207
default:
208208
return fmt.Errorf("Unknown protocol %q", s.protocol)
209209
}
210210
}
211211

212-
func (s *consoleWs) doConsole(op *operations.Operation) error {
212+
func (s *consoleWs) doConsole() error {
213213
defer logger.Debug("Console websocket finished")
214214
<-s.allConnected
215215

@@ -342,7 +342,7 @@ func (s *consoleWs) doConsole(op *operations.Operation) error {
342342
return nil
343343
}
344344

345-
func (s *consoleWs) doVGA(op *operations.Operation) error {
345+
func (s *consoleWs) doVGA() error {
346346
defer logger.Debug("VGA websocket finished")
347347

348348
consoleDoneCh := make(chan struct{})
@@ -389,7 +389,7 @@ func (s *consoleWs) doVGA(op *operations.Operation) error {
389389
}
390390

391391
// Cancel is responsible for closing websocket connections.
392-
func (s *consoleWs) Cancel(op *operations.Operation) error {
392+
func (s *consoleWs) Cancel(*operations.Operation) error {
393393
s.connsLock.Lock()
394394
conn := s.conns[-1]
395395
s.connsLock.Unlock()

cmd/incusd/instance_exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (s *execWs) Metadata() any {
7979
}
8080
}
8181

82-
func (s *execWs) Connect(op *operations.Operation, r *http.Request, w http.ResponseWriter) error {
82+
func (s *execWs) Connect(_ *operations.Operation, r *http.Request, w http.ResponseWriter) error {
8383
secret := r.FormValue("secret")
8484
if secret == "" {
8585
return fmt.Errorf("missing secret")

cmd/incusd/instance_file.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func instanceFileGet(s *state.State, inst instance.Instance, path string, r *htt
311311
// $ref: "#/responses/NotFound"
312312
// "500":
313313
// $ref: "#/responses/InternalServerError"
314-
func instanceFileHead(s *state.State, inst instance.Instance, path string, r *http.Request) response.Response {
314+
func instanceFileHead(_ *state.State, inst instance.Instance, path string, _ *http.Request) response.Response {
315315
reverter := revert.New()
316316
defer reverter.Fail()
317317

@@ -588,7 +588,7 @@ func instanceFilePost(s *state.State, inst instance.Instance, path string, r *ht
588588
// $ref: "#/responses/NotFound"
589589
// "500":
590590
// $ref: "#/responses/InternalServerError"
591-
func instanceFileDelete(s *state.State, inst instance.Instance, path string, r *http.Request) response.Response {
591+
func instanceFileDelete(s *state.State, inst instance.Instance, path string, _ *http.Request) response.Response {
592592
// Get a SFTP client.
593593
client, err := inst.FileSFTP()
594594
if err != nil {

0 commit comments

Comments
 (0)