config

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

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

Go to latest
Published: Nov 4, 2019 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoProject is the error returned when a project file is not
	// found in the current directory
	ErrNoProject = errors.New("failed to find project file in current path")
	// ErrNoGoModFile is an error signifying that a directory where
	// the user wants to initialise a project doesn't contain go.mod file.
	ErrNoGoModFile = errors.New("no go.mod file, run 'go mod init' first")
)

Functions

func AddApp

func AddApp(l *LockFile, wd, name string) error

AddApp adds a new app entry to the lock file in the provided working directory.

func GetProjectRoot

func GetProjectRoot(wd string) (string, error)

GetProjectRoot attempts to locate the root of the mona project based on the provided working directory. The provided path is traversed in reverse and each directory is checked for the existence of a mona.yml file.

func NewLockFile

func NewLockFile(dir string, name string) error

NewLockFile creates a new "mona.lock" file in the current working directory using the provided name.

func NewProject

func NewProject(dir string, name string) error

NewProject creates a new "mona.yml" file in the provided directory with the given name.

func UpdateLockFile

func UpdateLockFile(wd string, lock *LockFile) error

UpdateLockFile overwrites the current "mona.lock" file in the given working directory with the data provided.

Types

type AppVersion

type AppVersion struct {
	BuildHash string `yaml:"build"`
	TestHash  string `yaml:"test"`
	LintHash  string `yaml:"lint"`
}

The AppVersion type represents individual app information as stored in the lock file.

type BuildConfig

type BuildConfig struct {
	Env     map[string]string `yaml:"env"`
	Flags   []string          `yaml:"flags"`
	LDFlags struct {
		S bool              `yaml:"s"`
		X map[string]string `yaml:"X"`
	} `yaml:"ldflags"`
}

func (BuildConfig) AllFlags

func (bc BuildConfig) AllFlags() []string

func (BuildConfig) EnvToList

func (bc BuildConfig) EnvToList() []string

EnvToList converts the Env map to list of entries in form key=value.

type CommandConfig

type CommandConfig struct {
	Exclude    []string          `yaml:"exclude"`
	ExcludeMap map[string]bool   `yaml:"-"`
	Env        map[string]string `yaml:"env"`
	Flags      []string          `yaml:"flags"`
}

func (CommandConfig) EnvToList

func (cc CommandConfig) EnvToList() []string

EnvToList converts the Env map to list of entries in form key=value.

type LockFile

type LockFile struct {
	Apps map[string]*AppVersion `yaml:"apps,omitempty"`
}

The LockFile type represents the structure of a lock file, it stores the project name, version and the last build hashes used for each app

func LoadLockFile

func LoadLockFile(wd string) (*LockFile, error)

LoadLockFile attempts to load a lock file into memory from the provided working directory.

type Project

type Project struct {
	Name     string      `yaml:"name"`              // The name of the project
	Exclude  []string    `yaml:"exclude,omitempty"` // Global file patterns to ignore during hash generation
	Location string      `yaml:"-"`                 // The root project directory, not set in the yaml file but set on load for convenience
	BinDir   string      `yaml:"binDir"`            // Relative path from the root of the project to the directory where compiled binaries will be placed.
	Mod      deps.Module `yaml:"-"`
}

Project type represents the structure of the "mona.yml" file.

func LoadProject

func LoadProject(wd string) (*Project, error)

LoadProject attempts to read a "mona.yml" file into memory from the provided working directory

Jump to

Keyboard shortcuts

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