MCPcopy Index your code
hub / github.com/git-bug/git-bug / promptTokenOptions

Function promptTokenOptions

bridge/gitlab/config.go:170–194  ·  view source on GitHub ↗
(repo repository.RepoKeyring, login, baseUrl string)

Source from the content-addressed store, hash-verified

168}
169
170func 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
196func 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")

Callers 1

ConfigureMethod · 0.70

Calls 6

ListFunction · 0.92
WithTargetFunction · 0.92
WithKindFunction · 0.92
WithMetaFunction · 0.92
PromptCredentialFunction · 0.92
promptTokenFunction · 0.70

Tested by

no test coverage detected