Skip to content

Commit 94151ee

Browse files
committed
feat(cli): add flag --register for runner
1 parent c2275c7 commit 94151ee

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

cli/cmd/runner_register.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,28 @@ func init() {
1818
runnerCmd.AddCommand(runnerRegisterCmd)
1919
}
2020

21-
func registerRunner() {
21+
func initRunnerRegistrationToken() {
22+
if !runnerRegisterArgs.stdinRegistrationToken {
23+
return
24+
}
2225

23-
configFile := util.ConfigInit(persistentFlags.configPath, persistentFlags.noConfig)
26+
tokenBytes, err := io.ReadAll(os.Stdin)
27+
if err != nil {
28+
panic(err)
29+
}
2430

25-
if runnerRegisterArgs.stdinRegistrationToken {
26-
tokenBytes, err := io.ReadAll(os.Stdin)
27-
if err != nil {
28-
panic(err)
29-
}
31+
if len(tokenBytes) == 0 {
32+
panic("Empty token")
33+
}
3034

31-
if len(tokenBytes) == 0 {
32-
panic("Empty token")
33-
}
35+
util.Config.Runner.RegistrationToken = strings.TrimSpace(string(tokenBytes))
36+
}
3437

35-
util.Config.Runner.RegistrationToken = strings.TrimSpace(string(tokenBytes))
36-
}
38+
func registerRunner() {
39+
40+
configFile := util.ConfigInit(persistentFlags.configPath, persistentFlags.noConfig)
41+
42+
initRunnerRegistrationToken()
3743

3844
taskPool := createRunnerJobPool()
3945

0 commit comments

Comments
 (0)