Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
fix service account config writing
Browse files Browse the repository at this point in the history
  • Loading branch information
zimengyang committed Jun 4, 2018
1 parent e945c49 commit 4f10fec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
18 changes: 2 additions & 16 deletions pkg/dispatchcli/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type hostConfig struct {
APIHTTPSPort int `json:"api-https-port,omitempty"`
APIHTTPPort int `json:"api-http-port,omitempty"`
Token string `json:"-"`
ServiceAccount string `json:"serviceAccount,omitempty"`
JWTPrivateKey string `json:"jwtPrivateKey,omitempty"`
ServiceAccount string `json:"serviceaccount,omitempty"`
JWTPrivateKey string `json:"jwtprivatekey,omitempty"`
}

// Current Config Context
Expand Down Expand Up @@ -132,20 +132,6 @@ func NewCLI(in io.Reader, out, errOut io.Writer) *cobra.Command {
cmds.PersistentFlags().StringVar(&jwtToken, "token", "", "JWT Bearer Token")
cmds.PersistentFlags().StringVar(&serviceAccount, "service-account", "", "Name of the service account, if specified, a jwt-private-key is also required")
cmds.PersistentFlags().StringVar(&jwtPrivateKey, "jwt-private-key", "", "JWT private key file path")
viper.BindPFlag("host", cmds.PersistentFlags().Lookup("host"))
viper.BindPFlag("port", cmds.PersistentFlags().Lookup("port"))
viper.BindPFlag("organization", cmds.PersistentFlags().Lookup("organization"))
viper.BindPFlag("insecure", cmds.PersistentFlags().Lookup("insecure"))
viper.BindPFlag("json", cmds.PersistentFlags().Lookup("json"))
viper.BindPFlag("dispatchToken", cmds.PersistentFlags().Lookup("token"))
viper.BindPFlag("serviceAccount", cmds.PersistentFlags().Lookup("service-account"))
viper.BindPFlag("jwtPrivateKey", cmds.PersistentFlags().Lookup("jwt-private-key"))
// Limited support for env variables
viper.BindEnv("config", "DISPATCH_CONFIG")
viper.BindEnv("insecure", "DISPATCH_INSECURE")
viper.BindEnv("dispatchToken", "DISPATCH_TOKEN")
viper.BindEnv("serviceAccount", "DISPATCH_SERVICE_ACCOUNT")
viper.BindEnv("jwtPrivateKey", "DISPATCH_JWT_PRIVATE_KEY")

cmds.AddCommand(NewCmdGet(out, errOut))
cmds.AddCommand(NewCmdCreate(out, errOut))
Expand Down
3 changes: 2 additions & 1 deletion pkg/dispatchcli/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ func serviceAccountLogin(in io.Reader, out, errOut io.Writer, cmd *cobra.Command
}

// write dispatchConfig to file
vsConfigJSON, err := json.MarshalIndent(dispatchConfig, "", " ")
cmdConfig.Contexts[cmdConfig.Current] = &dispatchConfig
vsConfigJSON, err := json.MarshalIndent(cmdConfig, "", " ")
if err != nil {
return errors.Wrap(err, "error marshalling json")
}
Expand Down

0 comments on commit 4f10fec

Please sign in to comment.