From cf92a979e274dace1d545cbe140f4f4db064f921 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 12 Jul 2023 14:12:16 +0000 Subject: [PATCH] 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 Reviewed-on: https://gitea.com/gitea/act_runner/pulls/288 Co-authored-by: Bo-Yi Wu Co-committed-by: Bo-Yi Wu --- internal/app/cmd/register.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/app/cmd/register.go b/internal/app/cmd/register.go index a2c5a95..f1114cf 100644 --- a/internal/app/cmd/register.go +++ b/internal/app/cmd/register.go @@ -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) if err := doRegister(ctx, cfg, inputs); err != nil { return fmt.Errorf("Failed to register runner: %w", err) - } else { - log.Infof("Runner registered successfully.") } + log.Infof("Runner registered successfully.") return nil } @@ -305,7 +304,7 @@ func doRegister(ctx context.Context, cfg *config.Config, inputs *registerInputs) })) select { case <-ctx.Done(): - return nil + return ctx.Err() default: } if ctx.Err() != nil {