From b21d476acab1ffe576fa4ff043700efcd32a680e Mon Sep 17 00:00:00 2001 From: MarkusLoeffler01 Date: Fri, 9 Jun 2023 17:34:23 +0000 Subject: [PATCH] Exit with Code 1 if registering a runner fails (#228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### It's a "simple dirty fix" and I don't have any experiences with Go, so if this doesn't match your coding compliance, please adjust the code as needed I'm using bash scripts to register a token `./act_runner/act_runner register --no-interactive --name runner$number --instance http://localhost:3000 --token $token` But when a token is invalid, the command still returns 0, which is not practical for automation. A simple non-zero return would be more convenient for power users and developers. Co-authored-by: Markus Löffler Co-authored-by: techknowlogick Reviewed-on: https://gitea.com/gitea/act_runner/pulls/228 Reviewed-by: techknowlogick Co-authored-by: MarkusLoeffler01 Co-committed-by: MarkusLoeffler01 --- 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 51318e8..666d463 100644 --- a/internal/app/cmd/register.go +++ b/internal/app/cmd/register.go @@ -197,7 +197,7 @@ func registerInteractive(configFile string) error { if stage == StageWaitingForRegistration { log.Infof("Registering runner, name=%s, instance=%s, labels=%v.", inputs.RunnerName, inputs.InstanceAddr, inputs.CustomLabels) if err := doRegister(cfg, inputs); err != nil { - log.Errorf("Failed to register runner: %v", err) + return fmt.Errorf("Failed to register runner: %w", err) } else { log.Infof("Runner registered successfully.") } @@ -257,8 +257,7 @@ func registerNoInteractive(configFile string, regArgs *registerArgs) error { return nil } if err := doRegister(cfg, inputs); err != nil { - log.Errorf("Failed to register runner: %v", err) - return nil + return fmt.Errorf("Failed to register runner: %w", err) } log.Infof("Runner registered successfully.") return nil