(c *config.Config, hostname string)
| 137 | } |
| 138 | |
| 139 | func getToken(c *config.Config, hostname string) (tokenSource, error) { |
| 140 | if token, _ := c.Get(append(hostsKey, hostname, "oauth_token")); token != "" { |
| 141 | return tokenSource{token: token, inKeyring: false}, nil |
| 142 | } |
| 143 | token, err := keyring.Get(keyringServiceName(hostname), "") |
| 144 | |
| 145 | // If we have an error and it's not relating to there being no token |
| 146 | // then we'll return the error cause that's really unexpected. |
| 147 | if err != nil && !errors.Is(err, keyring.ErrNotFound) { |
| 148 | return tokenSource{}, err |
| 149 | } |
| 150 | |
| 151 | // Otherwise we'll return a sentinel error |
| 152 | if err != nil || token == "" { |
| 153 | return tokenSource{}, noTokenError |
| 154 | } |
| 155 | |
| 156 | return tokenSource{ |
| 157 | token: token, |
| 158 | inKeyring: true, |
| 159 | }, nil |
| 160 | } |
| 161 | |
| 162 | func getUsername(c *config.Config, hostname, token string, transport http.RoundTripper) (string, error) { |
| 163 | username, _ := c.Get(append(hostsKey, hostname, "user")) |
no test coverage detected