add label change post runner creation

This commit is contained in:
TheFox0x7 2024-04-09 20:53:12 +02:00
parent f1181cc62a
commit 7abbd84a8a
No known key found for this signature in database
GPG key ID: 6CA33903484AF7C2
2 changed files with 5 additions and 1 deletions

View file

@ -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)

View file

@ -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
}