summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorTheFox0x7 <thefox0x7@gmail.com>2024-04-09 20:53:12 +0200
committerTheFox0x7 <thefox0x7@gmail.com>2024-04-10 23:55:40 +0200
commit7abbd84a8a3dbfe64332a9def3a7c7ad9cedda4e (patch)
treeee36e716295363e1e94dd0b9d852a5c9be7dc427 /internal
parentafter reading labels, load them into registration (diff)
downloadforgejo-runner-7abbd84a8a3dbfe64332a9def3a7c7ad9cedda4e.tar.xz
forgejo-runner-7abbd84a8a3dbfe64332a9def3a7c7ad9cedda4e.zip
add label change post runner creation
Diffstat (limited to 'internal')
-rw-r--r--internal/app/cmd/daemon.go2
-rw-r--r--internal/app/run/runner.go4
2 files changed, 5 insertions, 1 deletions
diff --git a/internal/app/cmd/daemon.go b/internal/app/cmd/daemon.go
index 8de19f4..8e47bf6 100644
--- a/internal/app/cmd/daemon.go
+++ b/internal/app/cmd/daemon.go
@@ -64,7 +64,6 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
if len(ls) == 0 {
log.Warn("no labels configured, runner may not be able to pick up jobs")
}
- reg.Labels = ls.ToStrings()
if ls.RequireDocker() {
dockerSocketPath, err := getDockerSocketPath(cfg.Container.DockerHost)
@@ -112,6 +111,7 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
log.Infof("runner: %s, with version: %s, with labels: %v, declared successfully",
resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels)
// if declared successfully, override the labels in the.runner file with valid labels in the config file (if specified)
+ runner.Update(ctx, ls)
reg.Labels = ls.ToStrings()
if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil {
return fmt.Errorf("failed to save runner config: %w", err)
diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go
index ee12165..ff54fa7 100644
--- a/internal/app/run/runner.go
+++ b/internal/app/run/runner.go
@@ -242,3 +242,7 @@ func (r *Runner) Declare(ctx context.Context, labels []string) (*connect.Respons
Labels: labels,
}))
}
+
+func (r *Runner) Update(ctx context.Context, labels labels.Labels) {
+ r.labels = labels
+}