mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
feat(runner): support flag --stdin-registration-token
This commit is contained in:
parent
2efef31213
commit
151106ac3f
@ -1,18 +1,40 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/services/runners"
|
||||
"github.com/ansible-semaphore/semaphore/util"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var runnerRegisterArgs struct {
|
||||
stdinRegistrationToken bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
runnerRegisterCmd.PersistentFlags().BoolVar(&runnerRegisterArgs.stdinRegistrationToken, "stdin-registration-token", false, "Read registration token from stdin")
|
||||
runnerCmd.AddCommand(runnerRegisterCmd)
|
||||
}
|
||||
|
||||
func registerRunner() {
|
||||
|
||||
util.ConfigInit(configPath, noConfig)
|
||||
|
||||
if runnerRegisterArgs.stdinRegistrationToken {
|
||||
tokenBytes, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(tokenBytes) == 0 {
|
||||
panic("Empty token")
|
||||
}
|
||||
|
||||
util.Config.Runner.Token = string(tokenBytes)
|
||||
}
|
||||
|
||||
taskPool := runners.JobPool{}
|
||||
err := taskPool.Register()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user