Skip to content

Commit

Permalink
rename token -> access_token
Browse files Browse the repository at this point in the history
  • Loading branch information
David Byrd committed Sep 21, 2015
1 parent 78c85bc commit f6a9adc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--token DigitalOcean API V2 Token [$DIGITAL_OCEAN_TOKEN]
--access-token DigitalOcean API V2 Access Token [$DIGITALOCEAN_ACCESS_TOKEN]
--debug Debug
--output output format (json or text)
--help, -h show help
Expand All @@ -43,18 +43,18 @@ By default, `doit` will load a configuration file from `$HOME/.doitcfg` if found

### Configuration OPTIONS

* `token` - The DigitalOcean token. You can generate a token in the [Apps & API](https://cloud.digitalocean.com/settings/applications) Of the DigitalOcean control panel.
* `access-token` - The DigitalOcean access token. You can generate a token in the [Apps & API](https://cloud.digitalocean.com/settings/applications) Of the DigitalOcean control panel.
* `output` - Type of output to display results in. Choices are `json` or `text`. If not supplied, `doit` will default to `text`.

Example:

```yaml
{
token: MY_TOKEN
access-token: MY_TOKEN
output: text
}
```

## Plugins

`doit` functionality can be enhanced using plugins.
`doit` functionality can be enhanced using plugins.
10 changes: 5 additions & 5 deletions commands/doit.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
func init() {
viper.SetConfigType("yaml")

DoitCmd.PersistentFlags().StringVarP(&Token, "token", "t", "", "DigtialOcean API V2 Token")
DoitCmd.PersistentFlags().StringVarP(&Token, "access-token", "t", "", "DigtialOcean API V2 Access Token")
DoitCmd.PersistentFlags().StringVarP(&Output, "output", "o", "text", "output formt [text|json]")
}

Expand Down Expand Up @@ -80,8 +80,8 @@ func addCommands() {

func initFlags() {
viper.SetEnvPrefix("DIGITALOCEAN")
viper.BindEnv("token", "ACCESS_TOKEN")
viper.BindPFlag("token", DoitCmd.PersistentFlags().Lookup("token"))
viper.BindEnv("access-token", "DIGITALOCEAN_ACCESS_TOKEN")
viper.BindPFlag("access-token", DoitCmd.PersistentFlags().Lookup("access-token"))
viper.BindPFlag("output", DoitCmd.PersistentFlags().Lookup("output"))
}

Expand All @@ -95,8 +95,8 @@ func initializeConfig() {
LoadConfig()
initFlags()

if DoitCmd.PersistentFlags().Lookup("token").Changed {
viper.Set("token", Token)
if DoitCmd.PersistentFlags().Lookup("access-token").Changed {
viper.Set("access-token", Token)
}

if DoitCmd.PersistentFlags().Lookup("output").Changed {
Expand Down
2 changes: 1 addition & 1 deletion doit.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ Config = &LiveConfig{}

// GetGodoClient returns a GodoClient.
func (c *LiveConfig) GetGodoClient() *godo.Client {
token := viper.GetString("token")
token := viper.GetString("access-token")
tokenSource := &TokenSource{AccessToken: token}
oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
return godo.NewClient(oauthClient)
Expand Down

0 comments on commit f6a9adc

Please sign in to comment.