Skip to content

Commit

Permalink
enable revive, fix all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Mar 7, 2024
1 parent ab0c418 commit 74509a1
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cluster/calcium/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (c *Calcium) doCreateWorkloads(ctx context.Context, opts *types.DeployOptio
return
}
for nodename, rollbackIndices := range rollbackMap {
if e := c.withNodePodLocked(ctx, nodename, func(ctx context.Context, node *types.Node) error {
if e := c.withNodePodLocked(ctx, nodename, func(ctx context.Context, _ *types.Node) error {
rollbackResources := utils.Map(rollbackIndices, func(idx int) resourcetypes.Resources {
return workloadResourcesMap[nodename][idx]
})
Expand Down
2 changes: 1 addition & 1 deletion cluster/calcium/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestCreateWorkloadTxn(t *testing.T) {
engine.AssertExpectations(t)
}

func newCreateWorkloadCluster(t *testing.T) (*Calcium, []*types.Node) {
func newCreateWorkloadCluster(_ *testing.T) (*Calcium, []*types.Node) {
c := NewTestCluster()

engine := &enginemocks.API{}
Expand Down
2 changes: 1 addition & 1 deletion cluster/calcium/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *Calcium) RemoveNode(ctx context.Context, nodename string) error {
return nil
},
// rollback: do nothing
func(ctx context.Context, failureByCond bool) error {
func(_ context.Context, _ bool) error {
return nil
},
c.config.GlobalTimeout)
Expand Down
2 changes: 1 addition & 1 deletion cluster/calcium/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Calcium) RemovePod(ctx context.Context, podname string) error {
Podname: podname,
All: true,
}
return c.withNodesPodLocked(ctx, nodeFilter, func(ctx context.Context, nodes map[string]*types.Node) error {
return c.withNodesPodLocked(ctx, nodeFilter, func(ctx context.Context, _ map[string]*types.Node) error {
// TODO dissociate workload to node
// TODO should remove node first
err := c.store.RemovePod(ctx, podname)
Expand Down
2 changes: 1 addition & 1 deletion cluster/calcium/sendlarge.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (c *Calcium) SendLargeFile(ctx context.Context, inputChan chan *types.SendL
senders := make(map[string]*workloadSender)
// for each file
for data := range inputChan {
for _, id := range data.Ids {
for _, id := range data.IDs {
if _, ok := senders[id]; !ok {
log.Debugf(ctx, "[SendLargeFile] create sender for %s", id)
// for each container, let's create a new sender to send identical file chunk, each chunk will include the metadata of this file
Expand Down
2 changes: 1 addition & 1 deletion cluster/calcium/sendlarge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestSendLarge(t *testing.T) {
defer os.RemoveAll(tmpfile.Name())
defer tmpfile.Close()
opts := &types.SendLargeFileOptions{
Ids: []string{"cid"},
IDs: []string{"cid"},
Size: 1,
Dst: "/tmp/1",
Chunk: []byte{},
Expand Down
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func serve(c *cli.Context) error {
}

func main() {
cli.VersionPrinter = func(c *cli.Context) {
cli.VersionPrinter = func(_ *cli.Context) {
fmt.Print(version.String())
}

Expand Down
4 changes: 2 additions & 2 deletions engine/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (e *EngineCache) CheckAlive(ctx context.Context) {

paramsChan := make(chan engineParams)
go func() {
e.keysToCheck.ForEach(func(k string, v engineParams) bool {
e.keysToCheck.ForEach(func(_ string, v engineParams) bool {
paramsChan <- v
return true
})
Expand Down Expand Up @@ -169,7 +169,7 @@ func (e *EngineCache) CheckNodeStatus(ctx context.Context) {
continue
}
// a node may have multiple engines, so we need check all key here
e.keysToCheck.ForEach(func(k string, ep engineParams) bool {
e.keysToCheck.ForEach(func(_ string, ep engineParams) bool {
if ep.nodename == ns.Nodename {
logger.Infof(ctx, "remove engine %+v from cache", ep.getCacheKey())
RemoveEngineFromCache(ctx, ep.endpoint, ep.ca, ep.cert, ep.key)
Expand Down
2 changes: 1 addition & 1 deletion resource/cobalt/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (m Manager) Alloc(ctx context.Context, nodename string, deployCount int, op
return nil
},
// rollback: do nothing
func(ctx context.Context) error {
func(_ context.Context) error {
return nil
},
m.config.GlobalTimeout,
Expand Down
6 changes: 3 additions & 3 deletions resource/cobalt/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (m Manager) AddNode(ctx context.Context, nodename string, opts resourcetype

return res, utils.PCR(ctx,
// prepare: do nothing
func(ctx context.Context) error {
func(_ context.Context) error {
return nil
},
// commit: call plugins to add the node
Expand Down Expand Up @@ -224,7 +224,7 @@ func (m Manager) SetNodeResourceUsage(ctx context.Context, nodename string, node
after := resourcetypes.Resources{}

return before, after, utils.PCR(ctx,
func(ctx context.Context) error {
func(_ context.Context) error {
// prepare: covert []resourcetypes.Resources to map[plugin]resourcetypes.Resources
// [{"cpu-plugin": {"cpu": 1}}, {"cpu-plugin": {"cpu": 1}}] -> {"cpu-plugin": [{"cpu": 1}, {"cpu": 1}]}
for _, workloadResource := range workloadsResource {
Expand Down Expand Up @@ -319,7 +319,7 @@ func (m Manager) SetNodeResourceCapacity(ctx context.Context, nodename string, n
after := resourcetypes.Resources{}

return before, after, utils.PCR(ctx,
func(ctx context.Context) error {
func(_ context.Context) error {
if nodeResourceRequest == nil {
nodeResourceRequest = resourcetypes.Resources{}
}
Expand Down
2 changes: 1 addition & 1 deletion resource/cobalt/realloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (m Manager) Realloc(ctx context.Context, nodename string, nodeResource reso
return nil
},
// rollback: do nothing
func(ctx context.Context) error {
func(_ context.Context) error {
return nil
},
m.config.GlobalTimeout,
Expand Down
4 changes: 2 additions & 2 deletions resource/plugins/cpumem/schedule/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ func (h *host) getFullCPUPlans(cores []*cpuCore, full int) []types.CPUMap {
}

// Try to ensure the effectiveness of the previous priority
sumOfIds := func(c types.CPUMap) int {
sumOfIDs := func(c types.CPUMap) int {
sum := 0
for ID := range c {
sum += indexMap[ID]
}
return sum
}

sort.Slice(result, func(i, j int) bool { return sumOfIds(result[i]) < sumOfIds(result[j]) })
sort.Slice(result, func(i, j int) bool { return sumOfIDs(result[i]) < sumOfIDs(result[j]) })

return result
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func toCoreListImageOptions(opts *pb.ListImageOptions) *types.ImageOptions {

func toSendLargeFileOptions(opts *pb.FileOptions) (*types.SendLargeFileOptions, error) {
ret := &types.SendLargeFileOptions{
Ids: opts.Ids,
IDs: opts.Ids,
Dst: opts.Dst,
Size: opts.Size,
Mode: opts.Mode.Mode,
Expand All @@ -604,7 +604,7 @@ func toSendLargeFileChunks(file types.LinuxFile, ids []string) []*types.SendLarg
ret := make([]*types.SendLargeFileOptions, 0)
for idx := 0; idx < len(file.Content); idx += maxChunkSize {
sendLargeFileOptions := &types.SendLargeFileOptions{
Ids: ids,
IDs: ids,
Dst: file.Filename,
Size: int64(len(file.Content)),
Mode: file.Mode,
Expand Down
4 changes: 2 additions & 2 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const SendLargeFileChunkSize = 2 << 10

// SendLargeFileOptions for LargeFileTransfer
type SendLargeFileOptions struct {
Ids []string
IDs []string
Dst string
Size int64
Mode int64
Expand All @@ -319,7 +319,7 @@ type SendLargeFileOptions struct {

// Validate checks options
func (o *SendLargeFileOptions) Validate() error {
if len(o.Ids) == 0 {
if len(o.IDs) == 0 {
return ErrNoWorkloadIDs
}
if len(o.Chunk) == 0 {
Expand Down

0 comments on commit 74509a1

Please sign in to comment.