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