mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-24 13:49:08 +03:00
refactor(register): refactor registration functions and improve logging (#288)
- Remove the else clause in the `registerInteractive` function, and unconditionally log "Runner registered successfully." - Change the return value in the `doRegister` function from `nil` to `ctx.Err()`. Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/288 Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
87058716fb
commit
cf92a979e2
1 changed files with 2 additions and 3 deletions
|
@ -215,9 +215,8 @@ func registerInteractive(ctx context.Context, configFile string) error {
|
||||||
log.Infof("Registering runner, name=%s, instance=%s, labels=%v.", inputs.RunnerName, inputs.InstanceAddr, inputs.Labels)
|
log.Infof("Registering runner, name=%s, instance=%s, labels=%v.", inputs.RunnerName, inputs.InstanceAddr, inputs.Labels)
|
||||||
if err := doRegister(ctx, cfg, inputs); err != nil {
|
if err := doRegister(ctx, cfg, inputs); err != nil {
|
||||||
return fmt.Errorf("Failed to register runner: %w", err)
|
return fmt.Errorf("Failed to register runner: %w", err)
|
||||||
} else {
|
|
||||||
log.Infof("Runner registered successfully.")
|
|
||||||
}
|
}
|
||||||
|
log.Infof("Runner registered successfully.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +304,7 @@ func doRegister(ctx context.Context, cfg *config.Config, inputs *registerInputs)
|
||||||
}))
|
}))
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return ctx.Err()
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
|
Loading…
Reference in a new issue