Exit with Code 1 if registering a runner fails #228

Merged
techknowlogick merged 6 commits from MarkusLoeffler01/act_runner:main into main 2023-06-09 17:34:25 +00:00
Contributor

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.

### 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.
MarkusLoeffler01 added 1 commit 2023-06-05 17:16:23 +00:00
Exit with Code 1 if registering a runner fails
All checks were successful
checks / check and test (pull_request) Successful in 1m17s
1fbd03d99d
techknowlogick reviewed 2023-06-05 17:22:41 +00:00
@ -198,6 +198,7 @@ func registerInteractive(configFile string) error {
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)
os.Exit(1)

thanks for this PR. You may be able to return an error, and Cobra would exit with a non-zero status, I haven't tested this suggestion though.

thanks for this PR. You may be able to return an error, and Cobra would exit with a non-zero status, I haven't tested this suggestion though.
MarkusLoeffler01 marked this conversation as resolved
MarkusLoeffler01 added 1 commit 2023-06-05 17:46:00 +00:00
improved error return @techknowlogick
All checks were successful
checks / check and test (pull_request) Successful in 57s
3ab04768e8
wolfogre reviewed 2023-06-06 03:28:56 +00:00
@ -198,3 +199,3 @@
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 errors.New("Failed to register runner: " + err.Error())
Owner

Maybe:

				return fmt.Errorf("Failed to register runner: %w", err)
Maybe: ```go return fmt.Errorf("Failed to register runner: %w", err) ```
MarkusLoeffler01 marked this conversation as resolved
@ -259,3 +260,2 @@
if err := doRegister(cfg, inputs); err != nil {
log.Errorf("Failed to register runner: %v", err)
return nil
return errors.New("Failed to register runner: " + err.Error())
Owner

Ditto.

Ditto.
techknowlogick marked this conversation as resolved
MarkusLoeffler01 added 1 commit 2023-06-06 07:55:21 +00:00
#228 Changed error method accordingly @wolfogre
All checks were successful
checks / check and test (pull_request) Successful in 56s
a228edaaf6
MarkusLoeffler01 added 1 commit 2023-06-06 08:38:39 +00:00
Merge branch 'main' into main
All checks were successful
checks / check and test (pull_request) Successful in 39s
7a9bc6880e
techknowlogick added 1 commit 2023-06-09 17:31:55 +00:00
update per wolfogre feedback
All checks were successful
checks / check and test (pull_request) Successful in 56s
8184fe6de7
techknowlogick added 1 commit 2023-06-09 17:32:55 +00:00
Merge branch 'main' into main
All checks were successful
checks / check and test (pull_request) Successful in 55s
591bea4ef6
techknowlogick approved these changes 2023-06-09 17:32:55 +00:00
techknowlogick merged commit b21d476aca into main 2023-06-09 17:34:25 +00:00

Thanks so much for this PR!

Thanks so much for this PR!
Sign in to join this conversation.
No description provided.