Documentation
¶
Index ¶
- Variables
- func Create(path, skeletonName string) error
- func DisableCache()
- func EnableCache()
- func LoadSkeleton(ctx context.Context, repo Repository, name string) (*skeleton.Skeleton, error)
- func LoadSkeletons(ctx context.Context, repo Repository, names []string) ([]*skeleton.Skeleton, error)
- func ParseURL(rawurl string) (*skeleton.RepoInfo, error)
- type DependencyCycleError
- type LocalRepository
- type MultiRepository
- type RemoteRepository
- type Repository
- type SkeletonNotFoundError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoRepositories is returned by NewMultiRepository if no repositories are // configured. ErrNoRepositories = errors.New("no skeleton repositories configured") // ErrNotARemoteRepository is returned by NewRemoteRepository if the provided // info does not describe a remote repository. ErrNotARemoteRepository = errors.New("not a remote repository") )
var LocalCache = configdir.LocalCache("kickoff", "repositories")
LocalCache holds the path to the local repository cache. This is platform specific.
Functions ¶
func Create ¶
Create creates a new skeleton repository at path and initializes it with a skeleton located in a subdir named skeletonName.
func EnableCache ¶
func EnableCache()
EnableCache enables the repository cache. An enabled cache will cause New and NewNamed to return the same Repository instance for consecutive calls with pairs of the same name and url. This can speed up operations on remote skeleton repositories as it reduce the number of git operations that need to be carried out. The speedup may be noticeable when working with skeletons that have parents.
func LoadSkeleton ¶
LoadSkeleton loads the skeleton with name from given repository. The passed in context is propagated to all operations that cross API boundaries (e.g. git operations) and can be used to enforce timeouts or cancel them. Returns an error if loading the skeleton fails.
func LoadSkeletons ¶
func LoadSkeletons(ctx context.Context, repo Repository, names []string) ([]*skeleton.Skeleton, error)
LoadSkeletons loads multiple skeletons from given repository. The passed in context is propagated to all operations that cross API boundaries (e.g. git operations) and can be used to enforce timeouts or cancel them. Returns an error if loading of any of the skeletons fails.
func ParseURL ¶
ParseURL parses a raw repository url and returns a repository info describing a local or remote skeleton repository. The rawurl parameter must be either a local path or a remote url to a git repository. Remote url may optionally include a `revision` query parameter. If absent, `master` will be assumed. Returns an error if url does not match any of the criteria mentioned above.
Types ¶
type DependencyCycleError ¶
DependencyCycleError is the error returned while loading a skeleton's parent if a dependency cycle is detected.
func (DependencyCycleError) Error ¶
func (e DependencyCycleError) Error() string
Error implements error.
type LocalRepository ¶
type LocalRepository struct {
// contains filtered or unexported fields
}
LocalRepository is a local skeleton repository. A local skeleton repository can be any directory on disk that contains a skeletons/ subdirectory.
func NewLocalRepository ¶
func NewLocalRepository(info skeleton.RepoInfo) (*LocalRepository, error)
NewLocalRepository creates a *LocalRepository from info. Returns an error if resolving the absolute path to the skeleton repository fails.
func (*LocalRepository) GetSkeleton ¶
GetSkeleton implements Repository.
func (*LocalRepository) ListSkeletons ¶
ListSkeletons implements Repository.
type MultiRepository ¶
type MultiRepository struct {
// contains filtered or unexported fields
}
MultiRepository is a repository that aggregates multiple repositories and implements the Repository interface.
func NewMultiRepository ¶
func NewMultiRepository(repoURLMap map[string]string) (*MultiRepository, error)
NewMultiRepository creates a *MultiRepository which aggregates the repositores from the repoURLMap. The repoURLMap is a mapping of repository name to its url. Returns an error if repoURLMap contains empty keys or if creating individual repositories fails, or if repoURLMap is empty.
func (*MultiRepository) GetSkeleton ¶
GetSkeleton implements Repository.
Attempts to find the named skeleton in any of the backing repositories and returns it. If the skeleton name is ambiguous, GetSkeleton will return an error. Repositories are traversed in the lexicographical order of their names. If name has the form `<repoName>:<skeletonName>`, the skeleton will be looked up in the repository that matched repoName. Returns SkeletonNotFoundError if the skeleton was not found in any of the configured repositories.
func (*MultiRepository) ListSkeletons ¶
ListSkeletons implements Repository.
Lists the skeletons of all configured repositories lexicographically sorted by repository name.
type RemoteRepository ¶
type RemoteRepository struct {
*LocalRepository
// contains filtered or unexported fields
}
RemoteRepository is a skeleton repository that resides in a remote git repository.
func NewRemoteRepository ¶
func NewRemoteRepository(info skeleton.RepoInfo) (*RemoteRepository, error)
NewRemoteRepository creates a *RemoteRepository from info. Returns ErrNotARemoteRepository if info does not describe a remote repository location. Internally creates a *LocalRepository for the cached copy of the remote and returns any error that might occur while creating it.
func (*RemoteRepository) GetSkeleton ¶
GetSkeleton implements Repository.
Lazily synchronizes the cached local copy of the remote repository before looking up the skeleton.
func (*RemoteRepository) ListSkeletons ¶
ListSkeletons implements Repository.
Lazily synchronizes the cached local copy of the remote repository before listing skeletons.
type Repository ¶
type Repository interface {
// GetSkeleton retrieves information about a skeleton from the repository.
// The passed in context is propagated to all operations that cross API
// boundaries (e.g. git operations) and can be used to enforce timeouts or
// cancel them. Returns an error of type SkeletonNotFoundError if the named
// skeleton was not found in the repository.
GetSkeleton(ctx context.Context, name string) (*skeleton.Info, error)
// ListSkeletons retrieves information about all skeletons in the
// repository. The passed in context is propagated to all operations that
// cross API boundaries (e.g. git operations) and can be used to enforce
// timeouts or cancel them. If the repository is empty, ListSkeletons will
// return an empty slice.
ListSkeletons(ctx context.Context) ([]*skeleton.Info, error)
}
Repository is the interface for a skeleton repository.
func New ¶
func New(url string) (Repository, error)
New creates a new Repository for url. Returns an error if url is not a valid local path or remote url.
func NewNamed ¶
func NewNamed(name, url string) (repo Repository, err error)
NewNamed creates a new named Repository. The name is propagated into the repository info that is attached to every skeleton that is retrieved from it. Apart from that is behaves exactly like New.
type SkeletonNotFoundError ¶
SkeletonNotFoundError is the error returned if a skeleton cannot be found in a repository.
func (SkeletonNotFoundError) Error ¶
func (e SkeletonNotFoundError) Error() string
Error implements error.