git-bug/bridge/bridges.go

50 lines
1.5 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"
"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{})
}
2018-09-24 16:25:15 +03:00
// Targets return all known bridge implementation target
func Targets() []string {
return core.Targets()
}
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
}