bridges.go

 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/gitea"
 7	"github.com/MichaelMure/git-bug/bridge/github"
 8	"github.com/MichaelMure/git-bug/bridge/gitlab"
 9	"github.com/MichaelMure/git-bug/bridge/jira"
10	"github.com/MichaelMure/git-bug/bridge/launchpad"
11	"github.com/MichaelMure/git-bug/cache"
12	"github.com/MichaelMure/git-bug/repository"
13)
14
15func init() {
16	core.Register(&gitea.Gitea{})
17	core.Register(&github.Github{})
18	core.Register(&gitlab.Gitlab{})
19	core.Register(&launchpad.Launchpad{})
20	core.Register(&jira.Jira{})
21}
22
23// Targets return all known bridge implementation target
24func Targets() []string {
25	return core.Targets()
26}
27
28// LoginMetaKey return the metadata key used to store the remote bug-tracker login
29// on the user identity. The corresponding value is used to match identities and
30// credentials.
31func LoginMetaKey(target string) (string, error) {
32	return core.LoginMetaKey(target)
33}
34
35// Instantiate a new Bridge for a repo, from the given target and name
36func NewBridge(repo *cache.RepoCache, target string, name string) (*core.Bridge, error) {
37	return core.NewBridge(repo, target, name)
38}
39
40// LoadBridge instantiate a new bridge from a repo configuration
41func LoadBridge(repo *cache.RepoCache, name string) (*core.Bridge, error) {
42	return core.LoadBridge(repo, name)
43}
44
45// Attempt to retrieve a default bridge for the given repo. If zero or multiple
46// bridge exist, it fails.
47func DefaultBridge(repo *cache.RepoCache) (*core.Bridge, error) {
48	return core.DefaultBridge(repo)
49}
50
51// ConfiguredBridges return the list of bridge that are configured for the given
52// repo
53func ConfiguredBridges(repo repository.RepoConfig) ([]string, error) {
54	return core.ConfiguredBridges(repo)
55}
56
57// Remove a configured bridge
58func RemoveBridge(repo repository.RepoConfig, name string) error {
59	return core.RemoveBridge(repo, name)
60}