Skip to content

Commit b6fe371

Browse files
authored
allow to set up worker name (#210)
1 parent 2a2ddea commit b6fe371

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

internal/command/worker/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var (
2323
ErrEmptyBootstrapTokenProvided = errors.New("empty bootstrap token was provided")
2424
)
2525

26+
var name string
2627
var bootstrapTokenRaw string
2728
var bootstrapTokenStdin bool
2829
var logFilePath string
@@ -38,6 +39,8 @@ func newRunCommand() *cobra.Command {
3839
Args: cobra.ExactArgs(1),
3940
}
4041

42+
cmd.PersistentFlags().StringVar(&name, "name", "",
43+
"name of the worker (defaults to the hostname)")
4144
cmd.PersistentFlags().StringVar(&bootstrapTokenRaw, "bootstrap-token", "",
4245
"a bootstrap token retrieved via \"orchard get bootstrap-token <service-account-name-for-workers>\"")
4346
cmd.PersistentFlags().BoolVar(&bootstrapTokenStdin, "bootstrap-token-stdin", false,
@@ -111,6 +114,7 @@ func runWorker(cmd *cobra.Command, args []string) (err error) {
111114

112115
workerInstance, err := worker.New(
113116
controllerClient,
117+
worker.WithName(name),
114118
worker.WithResources(resources),
115119
worker.WithLogger(logger),
116120
)

internal/worker/option.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ import (
77

88
type Option func(*Worker)
99

10+
func WithName(name string) Option {
11+
return func(worker *Worker) {
12+
worker.name = name
13+
}
14+
}
15+
1016
func WithResources(resources v1.Resources) Option {
1117
return func(worker *Worker) {
1218
worker.resources = resources

0 commit comments

Comments
 (0)