Modernize a couple of loops, fix incorrect function docs (#5637)

This commit is contained in:
Marcus Ramberg
2025-10-14 13:00:19 +02:00
committed by GitHub
parent 2907159e02
commit 647fa843f6
4 changed files with 6 additions and 7 deletions

View File

@@ -283,8 +283,8 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
}
})
for i := 0; i < maxWorkflows; i++ {
i := i
// https://go.dev/blog/go1.22 fixed scope for goroutines in loops
for i := range maxWorkflows {
serviceWaitingGroup.Go(func() error {
runner := agent.NewRunner(client, filter, hostname, counter, &backendEngine)
log.Debug().Msgf("created new runner %d", i)

View File

@@ -28,7 +28,7 @@ const (
LogEntryProgress
)
// Line is a line of console output.
// LogEntry is a line of console output.
type LogEntry struct {
StepUUID string `json:"step_uuid,omitempty"`
Time int64 `json:"time,omitempty"`

View File

@@ -28,7 +28,7 @@ type JWTManager struct {
tokenDuration time.Duration
}
// UserClaims is a custom JWT claims that contains some user's information.
// AgentTokenClaims is a custom JWT claims that contains an agent's information.
type AgentTokenClaims struct {
jwt.RegisteredClaims
AgentID int64 `json:"agent_id"`

View File

@@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"strconv"
"time"
@@ -73,9 +74,7 @@ func (s *RPC) Next(c context.Context, agentFilter rpc.Filter) (*rpc.Workflow, er
}
// enforce labels from server by overwriting agent labels
for k, v := range agentServerLabels {
agentFilter.Labels[k] = v
}
maps.Copy(agentFilter.Labels, agentServerLabels)
log.Trace().Msgf("Agent %s[%d] tries to pull task with labels: %v", agent.Name, agent.ID, agentFilter.Labels)