core

package
v0.0.0-...-8ec1dd0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrExportNorSupported = errors.New("export is not supported")
View Source
var ErrImportNorSupported = errors.New("import is not supported")

Functions

func ConfiguredBridges

func ConfiguredBridges(repo repository.RepoCommon) ([]string, error)

ConfiguredBridges return the list of bridge that are configured for the given repo

func Register

func Register(impl BridgeImpl)

Register will register a new BridgeImpl

func RemoveBridge

func RemoveBridge(repo repository.RepoCommon, fullName string) error

Remove a configured bridge

func Targets

func Targets() []string

Targets return all known bridge implementation target

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

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 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 NewBridgeFullName

func NewBridgeFullName(repo *cache.RepoCache, fullName string) (*Bridge, error)

Instantiate a new bridge for a repo, from the combined target and name contained in the full name

func (*Bridge) Configure

func (b *Bridge) Configure() error

Configure run the target specific configuration process

func (Bridge) Export

func (b Bridge) Export(id string) error

func (Bridge) ExportAll

func (b Bridge) ExportAll() error

func (Bridge) Import

func (b Bridge) Import(id string) error

func (Bridge) ImportAll

func (b Bridge) ImportAll() error

type BridgeImpl

type BridgeImpl interface {
	// Target return the target of the bridge (e.g.: "github")
	Target() string

	// Configure handle the user interaction and return a key/value configuration
	// for future use
	Configure(repo repository.RepoCommon) (Configuration, error)

	// ValidateConfig check the configuration for error
	ValidateConfig(conf Configuration) error

	// Importer return an Importer implementation if the import is supported
	Importer() Importer

	// Exporter return an Exporter implementation if the export is supported
	Exporter() Exporter
}

type Configuration

type Configuration map[string]string

type Exporter

type Exporter interface {
	ExportAll(repo *cache.RepoCache, conf Configuration) error
	Export(repo *cache.RepoCache, conf Configuration, id string) error
}

type Importer

type Importer interface {
	ImportAll(repo *cache.RepoCache, conf Configuration) error
	Import(repo *cache.RepoCache, conf Configuration, id string) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL