config

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 9 Imported by: 0

README

config

import "github.com/eunomie/dague/config"

Index

Constants

const (
    defaultConfigFile = ".dague.yml"
)

Variables

var defaults []byte

func IsMapping

func IsMapping(i interface{}) bool

IsMapping reports whether a type is a mapping in YAML, represented as a map[interface{}]interface{}.

func IsScalar

func IsScalar(i interface{}) bool

IsScalar reports whether a type is a scalar value in YAML.

func IsSequence

func IsSequence(i interface{}) bool

IsSequence reports whether a type is a sequence in YAML, represented as an []interface{}.

func YAML

func YAML(sources [][]byte, strict bool) (*bytes.Buffer, error)

YAML deep-merges any number of YAML sources, with later sources taking priority over earlier ones.

Maps are deep-merged. For example,

{"one": 1, "two": 2} + {"one": 42, "three": 3}
== {"one": 42, "two": 2, "three": 3}

Sequences are replaced. For example,

{"foo": [1, 2, 3]} + {"foo": [4, 5, 6]}
== {"foo": [4, 5, 6]}

In non-strict mode, duplicate map keys are allowed within a single source, with later values overwriting previous ones. Attempting to merge mismatched types (e.g., merging a sequence into a map) replaces the old value with the new.

Enabling strict mode returns errors in both of the above cases.

func describe

func describe(i interface{}) string

func merge

func merge(into, from interface{}, strict bool) (interface{}, error)

type Build

type Build struct {
    Targets map[string]Target `yaml:"targets"`
}

type Cache

type Cache struct {
    Target string `yaml:"target"`
}

type Dague

type Dague struct {
    Vars  map[string]string `yaml:"vars"`
    Go    Go                `yaml:"go"`
    Tasks Tasks             `yaml:"tasks"`
}
func Load
func Load(ctx context.Context) (Dague, error)
func (*Dague) VarsDup
func (d *Dague) VarsDup() map[string]string

type Exec

type Exec struct {
    Deps   []string `yaml:"deps"`
    Cmds   string   `yaml:"cmds"`
    Export Export   `yaml:"export"`
}

type Export

type Export struct {
    Pattern string `yaml:"pattern"`
    Path    string `yaml:"path"`
}

type Fmt

type Fmt struct {
    Formatter string    `yaml:"formatter"`
    Goimports Goimports `yaml:"goimports"`
}

type Go

type Go struct {
    Image  Image           `yaml:"image"`
    AppDir string          `yaml:"appDir"`
    Fmt    Fmt             `yaml:"fmt"`
    Lint   Lint            `yaml:"lint"`
    Build  Build           `yaml:"build"`
    Exec   map[string]Exec `yaml:"exec"`
}

type Goimports

type Goimports struct {
    Locals []string `yaml:"locals"`
}

type Golangci

type Golangci struct {
    Enable bool   `yaml:"enable"`
    Image  string `yaml:"image"`
}

type Govulncheck

type Govulncheck struct {
    Enable bool `yaml:"enable"`
}

type Image

type Image struct {
    Src         string            `yaml:"src"`
    AptPackages []string          `yaml:"aptPackages"`
    ApkPackages []string          `yaml:"apkPackages"`
    GoPackages  []string          `yaml:"goPackages"`
    Mounts      map[string]string `yaml:"mounts"`
    Env         map[string]string `yaml:"env"`
    Caches      []Cache           `yaml:"caches"`
}

type Lint

type Lint struct {
    Govulncheck Govulncheck `yaml:"govulncheck"`
    Golangci    Golangci    `yaml:"golangci"`
}

type Target

type Target struct {
    Path      string            `yaml:"path"`
    Out       string            `yaml:"out"`
    Env       map[string]string `yaml:"env"`
    Ldflags   string            `yaml:"ldflags"`
    Platforms []string          `yaml:"platforms,omitempty"`
}

type Task

type Task struct {
    Deps []string `yaml:"deps"`
    Cmds string   `yaml:"cmds"`
}

type Tasks

type Tasks map[string]Task

type mapping

YAML has three fundamental types. When unmarshaled into interface{}, they're represented like this.

type mapping = map[interface{}]interface{}
func mergeMapping
func mergeMapping(into, from mapping, strict bool) (mapping, error)

type sequence

type sequence = []interface{}

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMapping added in v0.6.0

func IsMapping(i interface{}) bool

IsMapping reports whether a type is a mapping in YAML, represented as a map[interface{}]interface{}.

func IsScalar added in v0.6.0

func IsScalar(i interface{}) bool

IsScalar reports whether a type is a scalar value in YAML.

func IsSequence added in v0.6.0

func IsSequence(i interface{}) bool

IsSequence reports whether a type is a sequence in YAML, represented as an []interface{}.

func YAML added in v0.6.0

func YAML(sources [][]byte, strict bool) (*bytes.Buffer, error)

YAML deep-merges any number of YAML sources, with later sources taking priority over earlier ones.

Maps are deep-merged. For example,

{"one": 1, "two": 2} + {"one": 42, "three": 3}
== {"one": 42, "two": 2, "three": 3}

Sequences are replaced. For example,

{"foo": [1, 2, 3]} + {"foo": [4, 5, 6]}
== {"foo": [4, 5, 6]}

In non-strict mode, duplicate map keys are allowed within a single source, with later values overwriting previous ones. Attempting to merge mismatched types (e.g., merging a sequence into a map) replaces the old value with the new.

Enabling strict mode returns errors in both of the above cases.

Types

type Build added in v0.5.1

type Build struct {
	Targets map[string]Target `yaml:"targets"`
}

type Cache added in v0.12.0

type Cache struct {
	Target string `yaml:"target"`
}

type Dague added in v0.5.1

type Dague struct {
	Vars  map[string]string `yaml:"vars"`
	Go    Go                `yaml:"go"`
	Tasks Tasks             `yaml:"tasks"`
}

func Load added in v0.5.1

func Load(ctx context.Context) (Dague, error)

func (*Dague) VarsDup added in v0.12.0

func (d *Dague) VarsDup() map[string]string

type Exec added in v0.10.0

type Exec struct {
	Deps   []string `yaml:"deps"`
	Cmds   string   `yaml:"cmds"`
	Export Export   `yaml:"export"`
}

type Export added in v0.10.0

type Export struct {
	Pattern string `yaml:"pattern"`
	Path    string `yaml:"path"`
}

type Fmt added in v0.5.1

type Fmt struct {
	Formatter string    `yaml:"formatter"`
	Goimports Goimports `yaml:"goimports"`
}

type Go added in v0.5.1

type Go struct {
	Image  Image           `yaml:"image"`
	AppDir string          `yaml:"appDir"`
	Fmt    Fmt             `yaml:"fmt"`
	Lint   Lint            `yaml:"lint"`
	Build  Build           `yaml:"build"`
	Exec   map[string]Exec `yaml:"exec"`
}

type Goimports added in v0.5.1

type Goimports struct {
	Locals []string `yaml:"locals"`
}

type Golangci added in v0.5.1

type Golangci struct {
	Enable bool   `yaml:"enable"`
	Image  string `yaml:"image"`
}

type Govulncheck added in v0.5.1

type Govulncheck struct {
	Enable bool `yaml:"enable"`
}

type Image added in v0.11.0

type Image struct {
	Src         string            `yaml:"src"`
	AptPackages []string          `yaml:"aptPackages"`
	ApkPackages []string          `yaml:"apkPackages"`
	GoPackages  []string          `yaml:"goPackages"`
	Mounts      map[string]string `yaml:"mounts"`
	Env         map[string]string `yaml:"env"`
	Caches      []Cache           `yaml:"caches"`
}

type Lint added in v0.5.1

type Lint struct {
	Govulncheck Govulncheck `yaml:"govulncheck"`
	Golangci    Golangci    `yaml:"golangci"`
}

type Target added in v0.5.1

type Target struct {
	Path      string            `yaml:"path"`
	Out       string            `yaml:"out"`
	Env       map[string]string `yaml:"env"`
	Ldflags   string            `yaml:"ldflags"`
	Platforms []string          `yaml:"platforms,omitempty"`
}

type Task added in v0.9.0

type Task struct {
	Deps []string `yaml:"deps"`
	Cmds string   `yaml:"cmds"`
}

type Tasks added in v0.8.0

type Tasks map[string]Task

Jump to

Keyboard shortcuts

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