Documentation ¶
Overview ¶
Package maker provides CLI tools to manage and use GNU make-compliant snippet files, which contain rules to deal with specific domains such as programming language toolchains or helper tools as docker, linters, dependency injectors (google wire, uber fx, etc) that are needed during any stage of a repository management.
Those snippet files rely on a convention-over-configuration style that uses variables that can be either set before the include happens or overridden later on. They also should not be modified directly on the client repositories, as they are meant to be updated with the upstream version.
Copyright (c) William Artero. MIT License
Index ¶
- Constants
- type Config
- type File
- type FileReader
- type Lock
- type Lockable
- type Maker
- type Repository
- func (repository *Repository) AddSnippet(name, version string) error
- func (repository *Repository) Get(reference, name string) (FileReader, error)
- func (repository *Repository) HasSnippet(name string) bool
- func (repository *Repository) Init() error
- func (repository *Repository) SetSnippet(name, version string)
- type Truncable
- type UnlockCloser
- type Unlockable
Constants ¶
const ( SnippetsDirectory = ".make" ConfFilename = "maker.yaml" LockFilename = "maker.lock" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Repositories []*Repository `yaml:"repositories"`
}
Config stores the snippets required and any extra Maker setting
func (*Config) AddRepository ¶
func (config *Config) AddRepository(repo *Repository) error
func (*Config) GetRepository ¶
func (config *Config) GetRepository(reference string) (*Repository, error)
GetRepository returns a repository for the given reference, which can be either an alias or an URL. An empty reference returns the first (i.e. default) entry found in the configuration.
type File ¶
File represents a descriptor object that supports read, write, seek, truncate and lock operations.
type FileReader ¶
type FileReader interface { ID() plumbing.Hash Reader() (io.ReadCloser, error) }
type Lockable ¶
type Lockable interface { // Lock applies an advisory lock e.g. flock. It protects against access from // other processes Lock() error }
Lockable represents an IO object that supports locking its access to the current process
type Maker ¶
type Maker struct {
// contains filtered or unexported fields
}
Maker manages the configuration, lock data and snippet files on a directory
func New ¶
New returns an instance of Maker using the provided file descriptors to read and write data from, and a target directory to manage the snippets within.
The caller is responsible for closing both file descriptors
func NewDefault ¶
NewDefault creates a standard Maker instance using the OS filesystem and the current directory as the repository root.
func (*Maker) Install ¶
Install fetches the snippets if they're not present, or if there's any local changes
type Repository ¶
type Repository struct { *git.Repository `yaml:"-"` Snippets map[string]string `yaml:"snippets"` Alias string `yaml:"alias,omitempty"` URL string `yaml:"url"` sync.Mutex `yaml:"-"` }
func (*Repository) AddSnippet ¶
func (repository *Repository) AddSnippet(name, version string) error
func (*Repository) Get ¶
func (repository *Repository) Get(reference, name string) (FileReader, error)
Get returns the snippet file contents reader. The caller is responsible for closing it after usage.
func (*Repository) HasSnippet ¶
func (repository *Repository) HasSnippet(name string) bool
func (*Repository) Init ¶
func (repository *Repository) Init() error
func (*Repository) SetSnippet ¶
func (repository *Repository) SetSnippet(name, version string)
type Truncable ¶
type Truncable interface { // Truncate changes the size of the object. It does not change the I/O offset Truncate(size int64) error }
Truncable represents an IO object that supports truncating its size to a specific value
type UnlockCloser ¶
type UnlockCloser interface { io.Closer Unlockable }
UnlockCloser represents an IO object that supports unlocking and closing
type Unlockable ¶
type Unlockable interface { // Unlock removes the advisory lock to enable other processes to access it Unlock() error }
Unlockable represents an IO object that supports unlocking its access to be accessible by any process