Back to godoc.org

Package core

v0.0.0-...-c738852
Latest Go to latest

The highest tagged major version is .

Published: Oct 4, 2020 | License: GPL3 | Module: github.com/MichaelMure/git-bug

Overview

Package core contains the target-agnostic code to define and run a bridge

Index

Constants

const (
	ConfigKeyTarget = "target"

	MetaKeyOrigin = "origin"
)

Variables

var ErrExportNotSupported = errors.New("export is not supported")
var ErrImportNotSupported = errors.New("import is not supported")

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 FinishConfig

func FinishConfig(repo *cache.RepoCache, metaKey string, login string) error

func LoginMetaKey

func LoginMetaKey(target string) (string, 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.

func Register

func Register(impl BridgeImpl)

Register will register a new BridgeImpl

func RemoveBridge

func RemoveBridge(repo repository.RepoConfig, name string) error

Remove a configured bridge

func TargetExist

func TargetExist(target string) bool

TargetExist return true if the given target has a bridge implementation

func Targets

func Targets() []string

Targets return all known bridge implementation target

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

func DefaultBridge(repo *cache.RepoCache) (*Bridge, error)

Attempt to retrieve a default bridge for the given repo. If zero or multiple bridge exist, it fails.

func LoadBridge

func LoadBridge(repo *cache.RepoCache, name string) (*Bridge, error)

LoadBridge instantiate a new bridge from a repo configuration

func NewBridge

func NewBridge(repo *cache.RepoCache, target string, name string) (*Bridge, error)

Instantiate a new Bridge for a repo, from the given target and name

func (*Bridge) Configure

func (b *Bridge) Configure(params BridgeParams) error

Configure run the target specific configuration process

func (*Bridge) ExportAll

func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportResult, error)

func (*Bridge) ImportAll

func (b *Bridge) ImportAll(ctx context.Context) (<-chan ImportResult, error)

func (*Bridge) ImportAllSince

func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan ImportResult, error)

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) (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 Configuration map[string]string

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

	// Error happened during export
	ExportEventError
)

type ExportResult

type ExportResult struct {
	Err    error
	Event  ExportEvent
	ID     entity.Id
	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(id entity.Id) ExportResult

func NewExportComment

func NewExportComment(id entity.Id) ExportResult

func NewExportCommentEdition

func NewExportCommentEdition(id entity.Id) ExportResult

func NewExportError

func NewExportError(err error, id entity.Id) ExportResult

func NewExportLabelChange

func NewExportLabelChange(id entity.Id) ExportResult

func NewExportNothing

func NewExportNothing(id entity.Id, reason string) ExportResult

func NewExportStatusChange

func NewExportStatusChange(id entity.Id) ExportResult

func NewExportTitleEdition

func NewExportTitleEdition(id entity.Id) ExportResult

func NewExportWarning

func NewExportWarning(err error, id entity.Id) ExportResult

func (ExportResult) String

func (er ExportResult) String() string

type Exporter

type Exporter interface {
	Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
	ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ExportResult, error)
}

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

	// Error happened during import
	ImportEventError
)

type ImportResult

type ImportResult struct {
	Err    error
	Event  ImportEvent
	ID     entity.Id
	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(id entity.Id) ImportResult

func NewImportComment

func NewImportComment(id entity.Id) ImportResult

func NewImportCommentEdition

func NewImportCommentEdition(id entity.Id) ImportResult

func NewImportError

func NewImportError(err error, id entity.Id) ImportResult

func NewImportIdentity

func NewImportIdentity(id entity.Id) ImportResult

func NewImportLabelChange

func NewImportLabelChange(id entity.Id) ImportResult

func NewImportNothing

func NewImportNothing(id entity.Id, reason string) ImportResult

func NewImportStatusChange

func NewImportStatusChange(id entity.Id) ImportResult

func NewImportTitleEdition

func NewImportTitleEdition(id entity.Id) ImportResult

func NewImportWarning

func NewImportWarning(err error, id entity.Id) ImportResult

func (ImportResult) String

func (er ImportResult) String() string

type Importer

type Importer interface {
	Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
	ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ImportResult, error)
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier