Documentation ¶
Index ¶
- Constants
- func GetProviderInstances() map[string]Provider
- func Init(configPath string)
- func LoadMirror(config *Config, node *ast.ObjectItem) error
- func LoadProvider(node *ast.ObjectItem) error
- func RegisterProvider(name string, providerFunc ProviderCreateFunc)
- func RegisterProviderInstance(name string, provider Provider)
- func SetCacheInstance(cache *Cache)
- func SetMirrors(config *Config)
- func Sync(mirror MirrorConfig)
- func TrySync(provider Provider, path string)
- func VersionString() string
- type Cache
- type CacheConfig
- type Config
- type MirrorConfig
- type Provider
- type ProviderCreateFunc
- type Repository
- type Server
- type ServerConfig
- type SourceConfig
- type TargetConfig
Constants ¶
const Version = "0.1.0"
Version is the current version of the software
const VersionStability = "dev"
VersionStability is the status of this build, either stable, rc or dev
Variables ¶
This section is empty.
Functions ¶
func GetProviderInstances ¶
GetProviderInstances returns all provider instances
func Init ¶
func Init(configPath string)
Init logs the config, sets the cache and mirrors, then start the http server
func LoadMirror ¶
func LoadMirror(config *Config, node *ast.ObjectItem) error
LoadMirror creates a new mirror
func LoadProvider ¶
func LoadProvider(node *ast.ObjectItem) error
LoadProvider creates a named provider instance
func RegisterProvider ¶
func RegisterProvider(name string, providerFunc ProviderCreateFunc)
RegisterProvider allows a provider to register itself with kagami
func RegisterProviderInstance ¶
RegisterProviderInstance saves a provider instance under a certain name
func SetCacheInstance ¶
func SetCacheInstance(cache *Cache)
SetCacheInstance sets the cache instance used by kagami
func VersionString ¶
func VersionString() string
VersionString returns a string in the form version-stability
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache takes care of abstracting caching directory name generation and cleanup
func GetCacheInstance ¶
func GetCacheInstance() *Cache
GetCacheInstance returns the cache instance used by kagami
func (*Cache) Repository ¶
func (c *Cache) Repository(p Provider, r *Repository) (string, error)
Repository returns the cache path for a given repository
type CacheConfig ¶
CacheConfig configures the caching policy of kagami
type Config ¶
type Config struct { Cache CacheConfig `hcl:"cache"` Server ServerConfig `hcl:"server"` Mirrors map[string]MirrorConfig `hcl:"mirror"` }
Config is the configuration structure for the kagami project
func LoadConfig ¶
LoadConfig loads the git mirroring configuration from a file name
func LoadConfigFromBytes ¶
LoadConfigFromBytes loads the git mirroring configuration from a byte array
type MirrorConfig ¶
type MirrorConfig struct { Source SourceConfig `hcl:"source"` Targets map[string]TargetConfig `hcl:"target"` }
MirrorConfig represents a git mirror, it should have one source and can have multiple targets
type Provider ¶
type Provider interface { Name() string Type() string Pull(repo *Repository, path string) error Push(repo *Repository, path string) error ServeHTTP(w http.ResponseWriter, req *http.Request) }
Provider represents a valid provider with valid credentials
func CreateProvider ¶
CreateProvider creates a new provider instance
func GetProviderInstance ¶
GetProviderInstance returns a named provider instance
type ProviderCreateFunc ¶
ProviderCreateFunc is a function that creates a provider from a HCL config node
type Repository ¶
Repository represents a git repo on the disk
func NewRepository ¶
func NewRepository(p Provider, path string) *Repository
NewRepository creates a new repository instance
func (*Repository) Exists ¶
func (r *Repository) Exists() bool
Exists checks if the repo currently exists on the disk
func (*Repository) GetRepoPath ¶
func (r *Repository) GetRepoPath() (string, error)
GetRepoPath creates and return a valid path where to clone the repository
type ServerConfig ¶
type ServerConfig struct {
Addr string `hcl:"addr"`
}
ServerConfig configures the http server that listens to service hooks
type SourceConfig ¶
SourceConfig tells the mirror where to pull the repository from
type TargetConfig ¶
TargetConfig is a push target, represented by a provider name and a path to push to