Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions api/stack_notification_batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ func (nb *notificationBatcher) flush(ctx context.Context) {

var wg sync.WaitGroup
for batch := range slices.Chunk(notifications, maxNotificationsPerBatch) {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
nb.sendBatch(ctx, batch)
}()
})
}
wg.Wait()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func applyCLIOverrides(cfg *config.Config, cli *CLI) {
}

switch cliField.Kind() {
case reflect.Ptr:
case reflect.Pointer:
// Pointer types (nil = not set)
if !cliField.IsNil() {
cfgField.Set(cliField.Elem())
Expand Down
2 changes: 0 additions & 2 deletions internal/controller/agenttags/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestMapFromTags(t *testing.T) {
expectedErrs: []error{errors.New(`invalid agent tag: "kubernetes"`)},
},
} {
test := test
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
m, errs := agenttags.TagMapFromTags(test.agentTags)
Expand Down Expand Up @@ -206,7 +205,6 @@ func TestMatchJobTags(t *testing.T) {
expectedResult: true,
},
} {
test := test

t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
Expand Down
12 changes: 5 additions & 7 deletions internal/controller/scheduler/batch_buildkite_job_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

"github.com/buildkite/agent-stack-k8s/v2/api"
"github.com/google/uuid"
"log/slog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"log/slog"
)

// BatchBuildkiteJobChecker monitors Buildkite jobs for cancellation state changes.
Expand Down Expand Up @@ -94,18 +94,16 @@ func (c *BatchBuildkiteJobChecker) checkJobStates(ctx context.Context) {
jobStatesCh := make(chan map[string]api.JobState, batchCount)

for batch := range slices.Chunk(jobUUIDs, batchSize) {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {

jobStates, _, err := c.agentClient.GetJobStates(ctx, batch)
if err != nil {
c.logger.Error("Couldn't fetch states of jobs", "error", err, "batch_size", len(batch))
return
c.logger.Error("Couldn't fetch states of jobs", "error", err, "batch_size", len(batch))
return
}

jobStatesCh <- jobStates
}()
})
}

// Wait for all batches to complete and close channel
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type KubernetesPlugin struct {
PodTemplate string `json:"podTemplate,omitempty"`
GitEnvFrom []corev1.EnvFromSource `json:"gitEnvFrom,omitempty"`
Sidecars []corev1.Container `json:"sidecars,omitempty"`
Metadata config.Metadata `json:"metadata,omitempty"`
Metadata config.Metadata `json:"metadata"`
ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"`
CheckoutParams *config.CheckoutParams `json:"checkout,omitempty"`
CommandParams *config.CommandParams `json:"commandParams,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions internal/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func TestMain(m *testing.M) {
configArgs = append(configArgs, "--config="+os.Args[i+1])
}
}
if strings.HasPrefix(arg, "-f=") {
configArgs = append(configArgs, "--config="+strings.TrimPrefix(arg, "-f="))
if after, ok := strings.CutPrefix(arg, "-f="); ok {
configArgs = append(configArgs, "--config="+after)
}
if strings.HasPrefix(arg, "--config=") {
configArgs = append(configArgs, arg)
Expand All @@ -61,7 +61,7 @@ func TestMain(m *testing.M) {
if !cleanupPipelines && branch == "" {
log.Fatalf(
`The tests need to be run with the flag: -ldflags="-X %s.branch=$BRANCH_NAME"`,
reflect.TypeOf(testcase{}).PkgPath(),
reflect.TypeFor[testcase]().PkgPath(),
)
}

Expand Down