aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/launchpad
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/launchpad')
-rw-r--r--bridge/launchpad/config.go39
-rw-r--r--bridge/launchpad/import.go4
2 files changed, 21 insertions, 22 deletions
diff --git a/bridge/launchpad/config.go b/bridge/launchpad/config.go
index be81c0ac..8db39100 100644
--- a/bridge/launchpad/config.go
+++ b/bridge/launchpad/config.go
@@ -11,7 +11,7 @@ import (
"time"
"github.com/MichaelMure/git-bug/bridge/core"
- "github.com/MichaelMure/git-bug/repository"
+ "github.com/MichaelMure/git-bug/cache"
)
var ErrBadProjectURL = errors.New("bad Launchpad project URL")
@@ -22,9 +22,9 @@ const (
defaultTimeout = 60 * time.Second
)
-func (l *Launchpad) Configure(repo repository.RepoCommon, params core.BridgeParams) (core.Configuration, error) {
- if params.Token != "" {
- fmt.Println("warning: --token is ineffective for a Launchpad bridge")
+func (l *Launchpad) Configure(repo *cache.RepoCache, params core.BridgeParams) (core.Configuration, error) {
+ if params.TokenRaw != "" {
+ fmt.Println("warning: token params are ineffective for a Launchpad bridge")
}
if params.Owner != "" {
fmt.Println("warning: --owner is ineffective for a Launchpad bridge")
@@ -34,22 +34,19 @@ func (l *Launchpad) Configure(repo repository.RepoCommon, params core.BridgePara
var err error
var project string
- if params.Project != "" {
+ switch {
+ case params.Project != "":
project = params.Project
-
- } else if params.URL != "" {
+ case params.URL != "":
// get project name from url
project, err = splitURL(params.URL)
- if err != nil {
- return nil, err
- }
-
- } else {
+ default:
// get project name from terminal prompt
project, err = promptProjectName()
- if err != nil {
- return nil, err
- }
+ }
+
+ if err != nil {
+ return nil, err
}
// verify project
@@ -61,8 +58,8 @@ func (l *Launchpad) Configure(repo repository.RepoCommon, params core.BridgePara
return nil, fmt.Errorf("project doesn't exist")
}
- conf[keyProject] = project
conf[core.ConfigKeyTarget] = target
+ conf[keyProject] = project
err = l.ValidateConfig(conf)
if err != nil {
@@ -73,12 +70,14 @@ func (l *Launchpad) Configure(repo repository.RepoCommon, params core.BridgePara
}
func (*Launchpad) ValidateConfig(conf core.Configuration) error {
- if _, ok := conf[keyProject]; !ok {
- return fmt.Errorf("missing %s key", keyProject)
+ if v, ok := conf[core.ConfigKeyTarget]; !ok {
+ return fmt.Errorf("missing %s key", core.ConfigKeyTarget)
+ } else if v != target {
+ return fmt.Errorf("unexpected target name: %v", v)
}
- if _, ok := conf[core.ConfigKeyTarget]; !ok {
- return fmt.Errorf("missing %s key", core.ConfigKeyTarget)
+ if _, ok := conf[keyProject]; !ok {
+ return fmt.Errorf("missing %s key", keyProject)
}
return nil
diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go
index 59fc5c5f..619631b3 100644
--- a/bridge/launchpad/import.go
+++ b/bridge/launchpad/import.go
@@ -15,7 +15,7 @@ type launchpadImporter struct {
conf core.Configuration
}
-func (li *launchpadImporter) Init(conf core.Configuration) error {
+func (li *launchpadImporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
li.conf = conf
return nil
}
@@ -31,7 +31,7 @@ func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson)
if err == nil {
return i, nil
}
- if _, ok := err.(entity.ErrMultipleMatch); ok {
+ if entity.IsErrMultipleMatch(err) {
return nil, err
}