git-bug/bridge/bridges.go

59 lines
1.9 KiB
Go
Raw Normal View History

2018-10-01 22:47:12 +03:00
// Package bridge contains the high-level public functions to use and manage bridges
package bridge
import (
"github.com/MichaelMure/git-bug/bridge/core"
2019-10-12 12:10:44 +03:00
"github.com/MichaelMure/git-bug/bridge/github"
"github.com/MichaelMure/git-bug/bridge/gitlab"
2019-11-07 19:01:08 +03:00
"github.com/MichaelMure/git-bug/bridge/jira"
2019-10-12 12:10:44 +03:00
"github.com/MichaelMure/git-bug/bridge/launchpad"
2018-09-24 17:24:38 +03:00
"github.com/MichaelMure/git-bug/cache"
2018-09-24 16:25:15 +03:00
"github.com/MichaelMure/git-bug/repository"
)
2019-10-12 12:10:44 +03:00
func init() {
core.Register(&github.Github{})
core.Register(&gitlab.Gitlab{})
core.Register(&launchpad.Launchpad{})
2019-11-07 19:01:08 +03:00
core.Register(&jira.Jira{})
2019-10-12 12:10:44 +03:00
}
2018-09-24 16:25:15 +03:00
// Targets return all known bridge implementation target
func Targets() []string {
return core.Targets()
}
2020-02-05 00:05:34 +03:00
// LoginMetaKey return the metadata key used to store the remote bug-tracker login
// on the user identity. The corresponding value is used to match identities and
// credentials.
func LoginMetaKey(target string) (string, error) {
return core.LoginMetaKey(target)
}
2018-10-01 22:47:12 +03:00
// Instantiate a new Bridge for a repo, from the given target and name
2018-09-24 17:24:38 +03:00
func NewBridge(repo *cache.RepoCache, target string, name string) (*core.Bridge, error) {
return core.NewBridge(repo, target, name)
}
// LoadBridge instantiate a new bridge from a repo configuration
func LoadBridge(repo *cache.RepoCache, name string) (*core.Bridge, error) {
return core.LoadBridge(repo, name)
2018-09-24 18:11:50 +03:00
}
2018-10-01 22:47:12 +03:00
// Attempt to retrieve a default bridge for the given repo. If zero or multiple
// bridge exist, it fails.
2018-09-24 18:11:50 +03:00
func DefaultBridge(repo *cache.RepoCache) (*core.Bridge, error) {
return core.DefaultBridge(repo)
}
2018-10-01 22:47:12 +03:00
// ConfiguredBridges return the list of bridge that are configured for the given
// repo
func ConfiguredBridges(repo repository.RepoConfig) ([]string, error) {
2018-09-24 16:25:15 +03:00
return core.ConfiguredBridges(repo)
}
2018-09-24 17:24:38 +03:00
2018-10-01 22:47:12 +03:00
// Remove a configured bridge
func RemoveBridge(repo repository.RepoConfig, name string) error {
return core.RemoveBridge(repo, name)
2018-09-24 17:24:38 +03:00
}