allow to set up worker name (#210)

This commit is contained in:
Fedor Korotkov 2024-10-11 07:44:01 -04:00 committed by GitHub
parent 2a2ddea62a
commit b6fe371416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -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),
)

View File

@ -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