Add Context.SetAuthToken
This commit is contained in:
parent
de85294c79
commit
2aa77fb8ea
2 changed files with 19 additions and 4 deletions
|
|
@ -26,6 +26,10 @@ func (c *blankContext) AuthToken() (string, error) {
|
|||
return c.authToken, nil
|
||||
}
|
||||
|
||||
func (c *blankContext) SetAuthToken(t string) {
|
||||
c.authToken = t
|
||||
}
|
||||
|
||||
func (c *blankContext) AuthLogin() (string, error) {
|
||||
return c.authLogin, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
// Context represents the interface for querying information about the current environment
|
||||
type Context interface {
|
||||
AuthToken() (string, error)
|
||||
SetAuthToken(string)
|
||||
AuthLogin() (string, error)
|
||||
Branch() (string, error)
|
||||
SetBranch(string)
|
||||
|
|
@ -36,10 +37,11 @@ func InitDefaultContext() Context {
|
|||
|
||||
// A Context implementation that queries the filesystem
|
||||
type fsContext struct {
|
||||
config *configEntry
|
||||
remotes Remotes
|
||||
branch string
|
||||
baseRepo *GitHubRepository
|
||||
config *configEntry
|
||||
remotes Remotes
|
||||
branch string
|
||||
baseRepo *GitHubRepository
|
||||
authToken string
|
||||
}
|
||||
|
||||
func (c *fsContext) configFile() string {
|
||||
|
|
@ -54,11 +56,16 @@ func (c *fsContext) getConfig() (*configEntry, error) {
|
|||
return nil, err
|
||||
}
|
||||
c.config = entry
|
||||
c.authToken = ""
|
||||
}
|
||||
return c.config, nil
|
||||
}
|
||||
|
||||
func (c *fsContext) AuthToken() (string, error) {
|
||||
if c.authToken != "" {
|
||||
return c.authToken, nil
|
||||
}
|
||||
|
||||
config, err := c.getConfig()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -66,6 +73,10 @@ func (c *fsContext) AuthToken() (string, error) {
|
|||
return config.Token, nil
|
||||
}
|
||||
|
||||
func (c *fsContext) SetAuthToken(t string) {
|
||||
c.authToken = t
|
||||
}
|
||||
|
||||
func (c *fsContext) AuthLogin() (string, error) {
|
||||
config, err := c.getConfig()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue