(repo repository.RepoKeyring, login, baseUrl string)
| 168 | } |
| 169 | |
| 170 | func promptTokenOptions(repo repository.RepoKeyring, login, baseUrl string) (auth.Credential, error) { |
| 171 | creds, err := auth.List(repo, |
| 172 | auth.WithTarget(target), |
| 173 | auth.WithKind(auth.KindToken), |
| 174 | auth.WithMeta(auth.MetaKeyLogin, login), |
| 175 | auth.WithMeta(auth.MetaKeyBaseURL, baseUrl), |
| 176 | ) |
| 177 | if err != nil { |
| 178 | return nil, err |
| 179 | } |
| 180 | |
| 181 | cred, index, err := input.PromptCredential(target, "token", creds, []string{ |
| 182 | "enter my token", |
| 183 | }) |
| 184 | switch { |
| 185 | case err != nil: |
| 186 | return nil, err |
| 187 | case cred != nil: |
| 188 | return cred, nil |
| 189 | case index == 0: |
| 190 | return promptToken(baseUrl) |
| 191 | default: |
| 192 | panic("missed case") |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func promptToken(baseUrl string) (*auth.Token, error) { |
| 197 | fmt.Printf("You can generate a new token by visiting %s.\n", strings.TrimSuffix(baseUrl, "/")+"/-/user_settings/personal_access_tokens") |
no test coverage detected