Merge pull request #7124 from cli/config-get-token-fix
config get: support getting oauth_token from keyring
This commit is contained in:
commit
71d9e0eb40
1 changed files with 11 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package get
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
|
|
@ -53,6 +54,16 @@ func NewCmdConfigGet(f *cmdutil.Factory, runF func(*GetOptions) error) *cobra.Co
|
|||
}
|
||||
|
||||
func getRun(opts *GetOptions) error {
|
||||
// search keyring storage when fetching the `oauth_token` value
|
||||
if opts.Hostname != "" && opts.Key == "oauth_token" {
|
||||
token, _ := opts.Config.Authentication().Token(opts.Hostname)
|
||||
if token == "" {
|
||||
return errors.New(`could not find key "oauth_token"`)
|
||||
}
|
||||
fmt.Fprintf(opts.IO.Out, "%s\n", token)
|
||||
return nil
|
||||
}
|
||||
|
||||
val, err := opts.Config.GetOrDefault(opts.Hostname, opts.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue