Documentation ¶
Overview ¶
Package core contains the target-agnostic code to define and run a bridge
Index ¶
- Constants
- Variables
- func BridgeExist(repo repository.RepoConfig, name string) bool
- func ConfiguredBridges(repo repository.RepoConfig) ([]string, error)
- func FinishConfig(repo *cache.RepoCache, metaKey string, login string) error
- func LoginMetaKey(target string) (string, error)
- func Register(impl BridgeImpl)
- func RemoveBridge(repo repository.RepoConfig, name string) error
- func TargetExist(target string) bool
- func Targets() []string
- type Bridge
- func (b *Bridge) Configure(params BridgeParams, interactive bool) error
- func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportResult, error)
- func (b *Bridge) ImportAll(ctx context.Context) (<-chan ImportResult, error)
- func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan ImportResult, error)
- type BridgeImpl
- type BridgeParams
- type Configuration
- type ExportEvent
- type ExportResult
- func NewExportBug(entityId entity.Id) ExportResult
- func NewExportComment(entityId entity.Id) ExportResult
- func NewExportCommentEdition(entityId entity.Id) ExportResult
- func NewExportError(err error, entityId entity.Id) ExportResult
- func NewExportLabelChange(entityId entity.Id) ExportResult
- func NewExportNothing(entityId entity.Id, reason string) ExportResult
- func NewExportRateLimiting(msg string) ExportResult
- func NewExportStatusChange(entityId entity.Id) ExportResult
- func NewExportTitleEdition(entityId entity.Id) ExportResult
- func NewExportWarning(err error, entityId entity.Id) ExportResult
- type Exporter
- type ImportEvent
- type ImportResult
- func NewImportBug(entityId entity.Id) ImportResult
- func NewImportComment(entityId entity.Id, commentId entity.CombinedId) ImportResult
- func NewImportCommentEdition(entityId entity.Id, commentId entity.CombinedId) ImportResult
- func NewImportError(err error, entityId entity.Id) ImportResult
- func NewImportIdentity(entityId entity.Id) ImportResult
- func NewImportLabelChange(entityId entity.Id, opId entity.Id) ImportResult
- func NewImportNothing(entityId entity.Id, reason string) ImportResult
- func NewImportRateLimiting(msg string) ImportResult
- func NewImportStatusChange(entityId entity.Id, opId entity.Id) ImportResult
- func NewImportTitleEdition(entityId entity.Id, opId entity.Id) ImportResult
- func NewImportWarning(err error, entityId entity.Id) ImportResult
- type Importer
Constants ¶
const ( ConfigKeyTarget = "target" MetaKeyOrigin = "origin" )
Variables ¶
var ErrExportNotSupported = errors.New("export is not supported")
var ErrImportNotSupported = errors.New("import is not supported")
Functions ¶
func BridgeExist ¶
func BridgeExist(repo repository.RepoConfig, name string) bool
Check if a bridge exist
func ConfiguredBridges ¶
func ConfiguredBridges(repo repository.RepoConfig) ([]string, error)
ConfiguredBridges return the list of bridge that are configured for the given repo
func LoginMetaKey ¶
LoginMetaKey return the metadata key used to store the remote bug-tracker login on the user identity. The corresponding value is used to match identities and credentials.
func RemoveBridge ¶
func RemoveBridge(repo repository.RepoConfig, name string) error
Remove a configured bridge
func TargetExist ¶
TargetExist return true if the given target has a bridge implementation
Types ¶
type Bridge ¶
type Bridge struct { Name string // contains filtered or unexported fields }
Bridge is a wrapper around a BridgeImpl that will bind low-level implementation with utility code to provide high-level functions.
func DefaultBridge ¶
Attempt to retrieve a default bridge for the given repo. If zero or multiple bridge exist, it fails.
func LoadBridge ¶
LoadBridge instantiate a new bridge from a repo configuration
func (*Bridge) Configure ¶
func (b *Bridge) Configure(params BridgeParams, interactive bool) error
Configure run the target specific configuration process
func (*Bridge) ImportAll ¶
func (b *Bridge) ImportAll(ctx context.Context) (<-chan ImportResult, error)
func (*Bridge) ImportAllSince ¶
type BridgeImpl ¶
type BridgeImpl interface { // Target return the target of the bridge (e.g.: "github") Target() string // NewImporter return an Importer implementation if the import is supported NewImporter() Importer // NewExporter return an Exporter implementation if the export is supported NewExporter() Exporter // Configure handle the user interaction and return a key/value configuration // for future use. Configure(repo *cache.RepoCache, params BridgeParams, interactive bool) (Configuration, error) // The set of the BridgeParams fields supported ValidParams() map[string]interface{} // ValidateConfig check the configuration for error ValidateConfig(conf Configuration) error // LoginMetaKey return the metadata key used to store the remote bug-tracker login // on the user identity. The corresponding value is used to match identities and // credentials. LoginMetaKey() string }
type BridgeParams ¶
type BridgeParams struct { URL string // complete URL of a repo (Github, Gitlab, , Launchpad) BaseURL string // base URL for self-hosted instance ( Gitlab, Jira, ) Login string // username for the passed credential (Github, Gitlab, Jira, ) CredPrefix string // ID prefix of the credential to use (Github, Gitlab, Jira, ) TokenRaw string // pre-existing token to use (Github, Gitlab, , ) Owner string // owner of the repo (Github, , , ) Project string // name of the repo or project key (Github, , Jira, Launchpad) }
BridgeParams holds parameters to simplify the bridge configuration without having to make terminal prompts.
type Configuration ¶
type ExportEvent ¶
type ExportEvent int
const ( // Bug has been exported on the remote tracker ExportEventBug ExportEvent // Comment has been exported on the remote tracker ExportEventComment // Comment has been edited on the remote tracker ExportEventCommentEdition // Bug's status has been changed on on the remote tracker ExportEventStatusChange // Bug's title has been changed on the remote tracker ExportEventTitleEdition // Bug's labels have been changed on the remote tracker ExportEventLabelChange // Nothing changed on the bug ExportEventNothing // Something wrong happened during export that is worth notifying to the user // but not severe enough to consider the export a failure. ExportEventWarning // The export system (web API) has reached a rate limit ExportEventRateLimiting // Error happened during export ExportEventError )
type ExportResult ¶
type ExportResult struct { Err error Event ExportEvent EntityId entity.Id // optional for err, warning Reason string }
ExportResult is an event that is emitted during the export process, to allow calling code to report on what is happening, collect metrics or display meaningful errors if something went wrong.
func NewExportBug ¶
func NewExportBug(entityId entity.Id) ExportResult
func NewExportComment ¶
func NewExportComment(entityId entity.Id) ExportResult
func NewExportCommentEdition ¶
func NewExportCommentEdition(entityId entity.Id) ExportResult
func NewExportError ¶
func NewExportError(err error, entityId entity.Id) ExportResult
func NewExportLabelChange ¶
func NewExportLabelChange(entityId entity.Id) ExportResult
func NewExportNothing ¶
func NewExportNothing(entityId entity.Id, reason string) ExportResult
func NewExportRateLimiting ¶ added in v0.8.0
func NewExportRateLimiting(msg string) ExportResult
func NewExportStatusChange ¶
func NewExportStatusChange(entityId entity.Id) ExportResult
func NewExportTitleEdition ¶
func NewExportTitleEdition(entityId entity.Id) ExportResult
func NewExportWarning ¶
func NewExportWarning(err error, entityId entity.Id) ExportResult
func (ExportResult) String ¶
func (er ExportResult) String() string
type ImportEvent ¶
type ImportEvent int
const ( // Bug has been created ImportEventBug ImportEvent // Comment has been created ImportEventComment // Comment has been edited ImportEventCommentEdition // Bug's status has changed ImportEventStatusChange // Bug's title has changed ImportEventTitleEdition // Bug's labels changed ImportEventLabelChange // Nothing happened on a Bug ImportEventNothing // Identity has been created ImportEventIdentity // Something wrong happened during import that is worth notifying to the user // but not severe enough to consider the import a failure. ImportEventWarning // The import system (web API) has reached the rate limit ImportEventRateLimiting // Error happened during import ImportEventError )
type ImportResult ¶
type ImportResult struct { Err error Event ImportEvent EntityId entity.Id // optional for err, warnings OperationId entity.Id // optional ComponentId entity.CombinedId // optional Reason string }
ImportResult is an event that is emitted during the import process, to allow calling code to report on what is happening, collect metrics or display meaningful errors if something went wrong.
func NewImportBug ¶
func NewImportBug(entityId entity.Id) ImportResult
func NewImportComment ¶
func NewImportComment(entityId entity.Id, commentId entity.CombinedId) ImportResult
func NewImportCommentEdition ¶
func NewImportCommentEdition(entityId entity.Id, commentId entity.CombinedId) ImportResult
func NewImportError ¶
func NewImportError(err error, entityId entity.Id) ImportResult
func NewImportIdentity ¶
func NewImportIdentity(entityId entity.Id) ImportResult
func NewImportLabelChange ¶
func NewImportLabelChange(entityId entity.Id, opId entity.Id) ImportResult
func NewImportNothing ¶
func NewImportNothing(entityId entity.Id, reason string) ImportResult
func NewImportRateLimiting ¶ added in v0.8.0
func NewImportRateLimiting(msg string) ImportResult
func NewImportStatusChange ¶
func NewImportStatusChange(entityId entity.Id, opId entity.Id) ImportResult
func NewImportTitleEdition ¶
func NewImportTitleEdition(entityId entity.Id, opId entity.Id) ImportResult
func NewImportWarning ¶
func NewImportWarning(err error, entityId entity.Id) ImportResult
func (ImportResult) String ¶
func (er ImportResult) String() string