Skip to content

Commit

Permalink
Add separate config for service flags (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksanders authored Mar 26, 2021
1 parent e03f5a7 commit e734974
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,22 @@ func (p *program) Start(s service.Service) error {
}

func (p *program) run() {
var err error
log.Info("starting weep service!")
exitCode := 0

flags := viper.GetStringSlice("service.args")
err = rootCmd.ParseFlags(flags)
if err != nil {
log.Errorf("could not parse flags: %v", err)
}

args := viper.GetStringSlice("service.args")
switch command := viper.GetString("service.command"); command {
case "ecs_credential_provider":
fallthrough
case "serve":
err := runWeepServer(nil, args)
err = runWeepServer(nil, args)
if err != nil {
log.Error(err)
exitCode = 1
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func init() {
viper.SetDefault("server.port", 9091)
viper.SetDefault("service.command", "ecs_credential_provider")
viper.SetDefault("service.args", []string{})
viper.SetDefault("service.flags", []string{})

// Set aliases for backward-compatibility
viper.RegisterAlias("server.ecs_credential_provider_port", "server.port")
Expand Down
6 changes: 4 additions & 2 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ server:
address: 127.0.0.1
port: 9091
service:
command: ecs_credential_provider
args:
command: serve
flags: # Flags are CLI options
- --log-level
- debug
args: # Args are command arguments. This configuration will start the metadata service with credentials for roleName
- roleName
#challenge_settings: # (Optional) Username can be provided. If it is not provided, user will be prompted on first authentication attempt
# user: [email protected]
mtls_settings: # only needed if authentication_method is mtls
Expand Down

0 comments on commit e734974

Please sign in to comment.