Documentation
¶
Overview ¶
Package skeleton contains types that define the structure of a skeleton and its config. It also provides helpers to find, create and merge skeletons.
Index ¶
Constants ¶
const ConfigFileName = ".kickoff.yaml"
ConfigFileName is the name of the skeleton's config file.
Variables ¶
var ( // ErrDirNotFound indicates that a skeleton directory was not found. ErrDirNotFound = errors.New("skeleton dir not found") // ErrMergeEmpty is returned by Merge if no skeletons were passed. ErrMergeEmpty = errors.New("cannot merge empty list of skeletons") )
Functions ¶
func Create ¶
Create creates a new skeleton at path. The created skeleton contains an example .kickoff.yaml and example README.md.skel as starter. Returns an error if creating path or writing any of the files fails.
func FindSkeletonDir ¶
FindSkeletonDir finds the skeleton dir path resides in. It walk up the filesystem tree and checks for each parent if it is a skeleton dir and returns its path if the check was successful. Returns ErrDirNotFound if path does not reside within a skeleton dir or one of its subdirectories. Returns any other errors that may occur while traversing the filesystem tree.
func IsInsideSkeletonDir ¶
IsInsideSkeletonDir returns true if path is inside a skeleton dir. If path is a skeleton dir itself, this will return false.
func IsSkeletonDir ¶
IsSkeletonDir returns true if dir is a skeleton dir. Skeleton dirs are detected by the fact that they contain a .kickoff.yaml file.
Types ¶
type Config ¶
type Config struct {
Description string `json:"description,omitempty"`
Parent *Reference `json:"parent,omitempty"`
Values template.Values `json:"values"`
}
Config describes the schema of a skeleton's .kickoff.yaml.
func LoadConfig ¶
LoadConfig loads the skeleton config from path and returns it.
type File ¶
type File struct {
// RelPath is the file path relative to root directory of the skeleton.
RelPath string `json:"relPath"`
// AbsPath is the absolute path to the file on disk.
AbsPath string `json:"absPath"`
// Info is the os.FileInfo for the file
Info os.FileInfo `json:"-"`
}
File contains paths and other information about a skeleton file, e.g. whether it was inherited from a parent skeleton or not.
type Info ¶
type Info struct {
Name string `json:"name"`
Path string `json:"path"`
Repo *RepoInfo `json:"repo"`
}
Info holds information about the location of a skeleton.
func (*Info) LoadConfig ¶
LoadConfig loads the skeleton config for the info.
type Reference ¶
type Reference struct {
RepositoryURL string `json:"repositoryURL,omitempty"`
SkeletonName string `json:"skeletonName"`
}
Reference is a reference to a skeleton in a specific repository.
type RepoInfo ¶
type RepoInfo struct {
Name string `json:"name"`
Path string `json:"path"`
URL string `json:"url,omitempty"`
Revision string `json:"revision,omitempty"`
}
RepoInfo holds information about a skeleton repository.
func (*RepoInfo) FindSkeletons ¶
FindSkeletons recursively finds all skeletons in dir and attaches i to the results. Returns any error that may occur while traversing dir.
type Skeleton ¶
type Skeleton struct {
// Description is the skeleton description text obtained from the skeleton
// config.
Description string `json:"description,omitempty"`
// Parent is a reference to the parent skeleton. Is nil if the skeleton has
// no parent.
Parent *Skeleton `json:"parent,omitempty"`
// Info is the skeleton info that was used to load the skeleton.
Info *Info `json:"info"`
// The Files slice contains a merged and sorted list of file references
// that includes all files from the skeleton and its parents (if any).
Files []*File `json:"files,omitempty"`
// Values are the template values from the skeleton's config merged with
// those of it's parents (if any).
Values template.Values `json:"values,omitempty"`
}
Skeleton is the representation of a skeleton loaded from a skeleton repository.
func Merge ¶
Merge merges multiple skeletons together and returns a new *Skeleton. The skeletons are merged left to right with template values, skeleton files and skeleton info of the rightmost skeleton taking preference over already existing values. Template values are recursively merged and may cause errors on type mismatch. The resulting *Skeleton will have the second-to-last skeleton set as its parent, the second-to-last will have the third-to-last as parent and so forth. The original skeletons are not altered. If only one skeleton is passed it will be returned as is without modification. Passing a slice with length of zero will return in an error.