1// Package bridge contains the high-level public functions to use and manage bridges
 2package bridge
 3
 4import (
 5	"github.com/MichaelMure/git-bug/bridge/core"
 6	"github.com/MichaelMure/git-bug/bridge/github"
 7	"github.com/MichaelMure/git-bug/bridge/gitlab"
 8	"github.com/MichaelMure/git-bug/bridge/launchpad"
 9	"github.com/MichaelMure/git-bug/cache"
10	"github.com/MichaelMure/git-bug/repository"
11)
12
13func init() {
14	core.Register(&github.Github{})
15	core.Register(&gitlab.Gitlab{})
16	core.Register(&launchpad.Launchpad{})
17}
18
19// Targets return all known bridge implementation target
20func Targets() []string {
21	return core.Targets()
22}
23
24// Instantiate a new Bridge for a repo, from the given target and name
25func NewBridge(repo *cache.RepoCache, target string, name string) (*core.Bridge, error) {
26	return core.NewBridge(repo, target, name)
27}
28
29// LoadBridge instantiate a new bridge from a repo configuration
30func LoadBridge(repo *cache.RepoCache, name string) (*core.Bridge, error) {
31	return core.LoadBridge(repo, name)
32}
33
34// Attempt to retrieve a default bridge for the given repo. If zero or multiple
35// bridge exist, it fails.
36func DefaultBridge(repo *cache.RepoCache) (*core.Bridge, error) {
37	return core.DefaultBridge(repo)
38}
39
40// ConfiguredBridges return the list of bridge that are configured for the given
41// repo
42func ConfiguredBridges(repo repository.RepoConfig) ([]string, error) {
43	return core.ConfiguredBridges(repo)
44}
45
46// Remove a configured bridge
47func RemoveBridge(repo repository.RepoConfig, name string) error {
48	return core.RemoveBridge(repo, name)
49}