allow to set up worker name (#210)
This commit is contained in:
parent
2a2ddea62a
commit
b6fe371416
|
|
@ -23,6 +23,7 @@ var (
|
|||
ErrEmptyBootstrapTokenProvided = errors.New("empty bootstrap token was provided")
|
||||
)
|
||||
|
||||
var name string
|
||||
var bootstrapTokenRaw string
|
||||
var bootstrapTokenStdin bool
|
||||
var logFilePath string
|
||||
|
|
@ -38,6 +39,8 @@ func newRunCommand() *cobra.Command {
|
|||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVar(&name, "name", "",
|
||||
"name of the worker (defaults to the hostname)")
|
||||
cmd.PersistentFlags().StringVar(&bootstrapTokenRaw, "bootstrap-token", "",
|
||||
"a bootstrap token retrieved via \"orchard get bootstrap-token <service-account-name-for-workers>\"")
|
||||
cmd.PersistentFlags().BoolVar(&bootstrapTokenStdin, "bootstrap-token-stdin", false,
|
||||
|
|
@ -111,6 +114,7 @@ func runWorker(cmd *cobra.Command, args []string) (err error) {
|
|||
|
||||
workerInstance, err := worker.New(
|
||||
controllerClient,
|
||||
worker.WithName(name),
|
||||
worker.WithResources(resources),
|
||||
worker.WithLogger(logger),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ import (
|
|||
|
||||
type Option func(*Worker)
|
||||
|
||||
func WithName(name string) Option {
|
||||
return func(worker *Worker) {
|
||||
worker.name = name
|
||||
}
|
||||
}
|
||||
|
||||
func WithResources(resources v1.Resources) Option {
|
||||
return func(worker *Worker) {
|
||||
worker.resources = resources
|
||||
|
|
|
|||
Loading…
Reference in New Issue