diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-23 14:05:03 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-23 14:20:54 +0100 |
commit | 0cebe1e57e7e4b03aef77cd11bd4fc683c32afc6 (patch) | |
tree | 6c488eef7d39ffcf9226cb1952460b44920ed39e /bridge/jira | |
parent | b3318335986618388637a9d35d68b39633e4548a (diff) | |
download | git-bug-0cebe1e57e7e4b03aef77cd11bd4fc683c32afc6.tar.gz |
bridge: record the login used during the configure and use it as default credential
fix #338
Diffstat (limited to 'bridge/jira')
-rw-r--r-- | bridge/jira/config.go | 13 | ||||
-rw-r--r-- | bridge/jira/import.go | 6 | ||||
-rw-r--r-- | bridge/jira/jira.go | 1 |
3 files changed, 16 insertions, 4 deletions
diff --git a/bridge/jira/config.go b/bridge/jira/config.go index 79fd8507..1a6ab18a 100644 --- a/bridge/jira/config.go +++ b/bridge/jira/config.go @@ -79,7 +79,7 @@ func (j *Jira) Configure(repo *cache.RepoCache, params core.BridgeParams) (core. } login = l default: - login := params.Login + login = params.Login if login == "" { // TODO: validate username login, err = input.Prompt("JIRA login", "login", input.Required) @@ -98,6 +98,7 @@ func (j *Jira) Configure(repo *cache.RepoCache, params core.BridgeParams) (core. conf[confKeyBaseUrl] = baseURL conf[confKeyProject] = project conf[confKeyCredentialType] = credType + conf[confKeyDefaultLogin] = login err = j.ValidateConfig(conf) if err != nil { @@ -144,10 +145,18 @@ func (*Jira) ValidateConfig(conf core.Configuration) error { } else if v != target { return fmt.Errorf("unexpected target name: %v", v) } - + if _, ok := conf[confKeyBaseUrl]; !ok { + return fmt.Errorf("missing %s key", confKeyBaseUrl) + } if _, ok := conf[confKeyProject]; !ok { return fmt.Errorf("missing %s key", confKeyProject) } + if _, ok := conf[confKeyCredentialType]; !ok { + return fmt.Errorf("missing %s key", confKeyCredentialType) + } + if _, ok := conf[confKeyDefaultLogin]; !ok { + return fmt.Errorf("missing %s key", confKeyDefaultLogin) + } return nil } diff --git a/bridge/jira/import.go b/bridge/jira/import.go index f35f114f..21305bd5 100644 --- a/bridge/jira/import.go +++ b/bridge/jira/import.go @@ -40,8 +40,9 @@ func (ji *jiraImporter) Init(ctx context.Context, repo *cache.RepoCache, conf co // Prioritize LoginPassword credentials to avoid a prompt creds, err := auth.List(repo, auth.WithTarget(target), - auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]), auth.WithKind(auth.KindLoginPassword), + auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]), + auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]), ) if err != nil { return err @@ -53,8 +54,9 @@ func (ji *jiraImporter) Init(ctx context.Context, repo *cache.RepoCache, conf co creds, err = auth.List(repo, auth.WithTarget(target), - auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]), auth.WithKind(auth.KindLogin), + auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]), + auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]), ) if err != nil { return err diff --git a/bridge/jira/jira.go b/bridge/jira/jira.go index b891ee3d..066c6597 100644 --- a/bridge/jira/jira.go +++ b/bridge/jira/jira.go @@ -25,6 +25,7 @@ const ( confKeyBaseUrl = "base-url" confKeyProject = "project" + confKeyDefaultLogin = "default-login" confKeyCredentialType = "credentials-type" // "SESSION" or "TOKEN" confKeyIDMap = "bug-id-map" confKeyIDRevMap = "bug-id-revmap" |