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