aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/bridges.go
blob: 9bbf3941126b8b0b47fd7c9c5328353eebcbeeaf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package bridge contains the high-level public functions to use and manage bridges
package bridge

import (
	"github.com/MichaelMure/git-bug/bridge/core"
	"github.com/MichaelMure/git-bug/bridge/github"
	"github.com/MichaelMure/git-bug/bridge/gitlab"
	"github.com/MichaelMure/git-bug/bridge/launchpad"
	"github.com/MichaelMure/git-bug/cache"
	"github.com/MichaelMure/git-bug/repository"
)

func init() {
	core.Register(&github.Github{})
	core.Register(&gitlab.Gitlab{})
	core.Register(&launchpad.Launchpad{})
}

// Targets return all known bridge implementation target
func Targets() []string {
	return core.Targets()
}

// Instantiate a new Bridge for a repo, from the given target and name
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)
}

// Attempt to retrieve a default bridge for the given repo. If zero or multiple
// bridge exist, it fails.
func DefaultBridge(repo *cache.RepoCache) (*core.Bridge, error) {
	return core.DefaultBridge(repo)
}

// ConfiguredBridges return the list of bridge that are configured for the given
// repo
func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
	return core.ConfiguredBridges(repo)
}

// Remove a configured bridge
func RemoveBridge(repo repository.RepoCommon, name string) error {
	return core.RemoveBridge(repo, name)
}