Skip to content

Commit

Permalink
Make the default worker name pretty (#223)
Browse files Browse the repository at this point in the history
To simplify the default configuration
  • Loading branch information
fkorotkov authored Jan 10, 2021
1 parent 35a327f commit 6452e95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/commands/worker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
"strings"
)

var ErrRun = errors.New("run failed")
Expand Down Expand Up @@ -61,8 +62,12 @@ func NewRunCmd() *cobra.Command {

cmd.PersistentFlags().StringVarP(&configPath, "file", "f", "", "configuration file path (e.g. /etc/cirrus/worker.yml)")

hostname, _ := os.Hostname()
cmd.PersistentFlags().StringVar(&name, "name", hostname, "worker name to use when registering in the pool")
// Default worker name to host name
defaultName, _ := os.Hostname()
// Make the default name pretty by removing common suffixes
defaultName = strings.TrimSuffix(defaultName, ".lan")
defaultName = strings.TrimSuffix(defaultName, ".local")
cmd.PersistentFlags().StringVar(&name, "name", defaultName, "worker name to use when registering in the pool")
_ = viper.BindPFlag("name", cmd.PersistentFlags().Lookup("name"))

cmd.PersistentFlags().StringVar(&token, "token", "", "pool registration token")
Expand Down

0 comments on commit 6452e95

Please sign in to comment.