internal

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentDir   = "content"
	ManifestFile = "layout.yaml"
)
View Source
const (
	MagicVarDir = "dirname" // contains base name of destination directory (aka: project name)
)

Variables

This section is empty.

Functions

func CopyTree

func CopyTree(src string, dest string) ([]string, error)

func Deploy

func Deploy(ctx context.Context, config Config) error

Deploy layout, which means clone repo, ask for question, and template content.

Types

type Computed

type Computed struct {
	Var   string
	Value interface{} // template only if value is string
	Type  VarType     // convert to this type if value is string, otherwise value used as-is
	When  Condition
}

type Condition

type Condition string // tengo, by-default false

func (Condition) Eval

func (p Condition) Eval(ctx context.Context, state map[string]interface{}) (bool, error)

Eval returns true only in case evaluated expression (in Tengo language) returns true.

func (Condition) Ok

func (p Condition) Ok(ctx context.Context, state map[string]interface{}) (bool, error)

Ok is corner case of Eval and returns true in case expression is not set, otherwise it returns result of Eval.

type Config

type Config struct {
	Source   string                 // git URL, shorthand, or path to directory
	Target   string                 // destination directory
	Aliases  map[string]string      // aliases (abbreviations) for cloning, values may contain {0} placeholder
	Default  string                 // default alias (for cloning without abbreviations, such as owner/repo), value may contain {0} placeholder, default is Github
	Display  ui.UI                  // how to interact with user, default is Simple TUI
	Debug    bool                   // enable debug messages and tracing
	Version  string                 // current version, used to filter manifests by constraints
	AskOnce  bool                   // do not try to ask for user input after wrong value and interrupt deployment
	Git      gitclient.Client       // Git client, default is gitclient.Auto
	Defaults map[string]interface{} // Global default values
}

Config of layout deployment.

type Default

type Default struct {
	Var   string
	Value interface{} // template only if value is string
	Type  VarType     // convert to this type if value is string, otherwise value used as-is
}

type Hook

type Hook struct {
	Runnable `yaml:",inline"`
	Label    string // optional message which will displayed during execution. If nothing set, then nothing will be shown
	When     Condition
}

type Manifest

type Manifest struct {
	Version     string // minimal layout version (semver). Empty means any version
	Title       string // short description of what manifest doing, should be unique in multi-layouts repo
	Description string // full manifest description
	Delimiters  struct {
		Open  string
		Close string
	} // custom template delimiter for go templates, default is '{{' and '}}'
	Prompts  []Prompt
	Default  []Default  // computed values to define internal default values before processing state, useful in case of condition includes to prevent `undefined variable` error
	Computed []Computed // computed values used to calculate variables after user input
	Before   []Hook     // hook executed before generation
	After    []Hook     // hook executed after generation
	Ignore   []string   // globs, filtered files will not be templated
}

type Prompt

type Prompt struct {
	Label   string // template
	Include string // template
	Var     string
	Type    VarType
	Options []string    // allowed values, templated
	Default interface{} // template if not strings, array could be used for picking multiple default values (in case type is list)
	When    Condition
}

type Runnable

type Runnable struct {
	Run    string // templated, shell like (mvdan.cc/sh)
	Script string // path to script (executable), relative to manifest, content templated. It has limited support for shell execution, and designed for direct script invocation: <script> [args...]
}

type VarType

type VarType string
const (
	VarString VarType = "str"
	VarBool   VarType = "bool"
	VarInt    VarType = "int"
	VarFloat  VarType = "float"
	VarList   VarType = "list"
)

func (VarType) Parse

func (vt VarType) Parse(value string) (interface{}, error)

Directories

Path Synopsis
ui

Jump to

Keyboard shortcuts

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