Documentation
¶
Index ¶
- Constants
- Variables
- func PushRecipe(ctx context.Context, path string, opts oci.Repository) error
- func SaveRemoteRecipe(ctx context.Context, dest string, opts oci.Repository) error
- type File
- type Metadata
- type Recipe
- type RecipeConflict
- type RenderEngine
- type Sauce
- type Test
- type Variable
- type VariableValidator
- type VariableValues
Constants ¶
View Source
const ( YAMLExtension = ".yml" RecipeFileName = "recipe" RecipeTemplatesDirName = "templates" RecipeTestsDirName = "tests" RecipeTestMetaFileName = "test" RecipeTestFilesDirName = "files" IgnoreFileName = ".jalapenoignore" )
View Source
const ( SaucesFileName = "sauces" // The directory name which contains all Jalapeno related files // in the project directory SauceDirName = ".jalapeno" )
View Source
const (
HashPrefix = "sha256:"
)
Variables ¶
View Source
var ( ErrNoTestsSpecified error = errors.New("no tests specified") ErrTestWrongFileAmount = errors.New("recipe rendered different amount of files than expected") ErrTestMissingFile = errors.New("recipe did not render file which was expected") ErrTestContentMismatch = errors.New("the contents of the files did not match") )
View Source
var (
ErrSauceNotFound = errors.New("sauce not found")
)
View Source
var (
)
View Source
var TestID uuid.UUID = uuid.Must(uuid.FromString("12345678-1234-5678-1234-567812345678"))
Random hardcoded UUID
Functions ¶
func PushRecipe ¶ added in v0.1.26
func SaveRemoteRecipe ¶ added in v0.1.26
SaveRemoteRecipe pulls a recipe from repository and saves it to dest directory
Types ¶
type File ¶ added in v0.1.0
type File struct { Checksum string `yaml:"checksum"` // e.g. "sha256:xxxxxxxxx" w. default algo Content []byte `yaml:"-"` }
func (File) HasBeenModified ¶ added in v0.1.26
type Metadata ¶
type Metadata struct { // Version of the recipe metadata API schema. Currently should have value "v1" APIVersion string `yaml:"apiVersion"` // Name of the recipe Name string `yaml:"name"` // Version of the recipe. Must be valid [semver](https://semver.org/) Version string `yaml:"version"` // Description of what the recipe does Description string `yaml:"description"` // A list of URLs to source code for this recipe Sources []string `yaml:"sources,omitempty"` // A message which will be showed to an user after a succesful recipe execution. // Can be used to guide the user what should be done next in the project directory. InitHelp string `yaml:"initHelp,omitempty"` // Glob patterns for ignoring generated files from future recipe upgrades. Ignored // files will not be regenerated even if their templates change in future versions // of the recipe. IgnorePatterns []string `yaml:"ignorePatterns,omitempty"` // File extension of files in "templates" directory which should be templated. // Files not matched by this extension will be copied as-is. // If left empty (the default), all files will be templated. TemplateExtension string `yaml:"templateExtension,omitempty"` }
type Recipe ¶
type Recipe struct { Metadata `yaml:",inline"` Variables []Variable `yaml:"vars,omitempty"` Templates map[string]File `yaml:"-"` Tests []Test `yaml:"-"` }
func LoadRecipe ¶ added in v0.1.0
LoadRecipe reads a recipe from a given path
func PullRecipe ¶ added in v0.1.26
func (*Recipe) Execute ¶ added in v0.1.0
func (re *Recipe) Execute(engine RenderEngine, values VariableValues, id uuid.UUID) (*Sauce, error)
Execute executes the recipe and returns a sauce
type RecipeConflict ¶ added in v0.1.0
type RenderEngine ¶
type Sauce ¶ added in v0.1.0
type Sauce struct { Recipe Recipe `yaml:",inline"` Values VariableValues `yaml:"values,omitempty"` Files map[string]File `yaml:"files"` // Random unique ID whose value is determined on first render and stays the same // on subsequent re-renders (upgrades) of the sauce. Can be used for example as a seed // for template random functions to provide same result on each template ID uuid.UUID `yaml:"id"` // CheckFrom defines the repository where updates should be checked for the recipe CheckFrom string `yaml:"from,omitempty"` }
Sauce represents a rendered recipe
func LoadSauces ¶ added in v0.1.0
Load all sauces from a project directory. Returns empty slice if the project directory did not contain any sayces
func (*Sauce) Conflicts ¶ added in v0.1.0
func (s *Sauce) Conflicts(other *Sauce) []RecipeConflict
Check if the recipe conflicts with another recipe. Recipes conflict if they touch the same files.
type Test ¶ added in v0.1.0
type Test struct { // Name of the test case. Defined by directory name of the test case Name string `yaml:"-"` // Values to use to render the recipe templates Values VariableValues `yaml:"values"` // Snapshots of the rendered templates which were rendered with the values specified in the test Files map[string]File `yaml:"-"` // If true, test will not fail if the templates generates more files than the test specifies IgnoreExtraFiles bool `yaml:"ignoreExtraFiles"` }
type Variable ¶
type Variable struct { // The name of the variable. It is also used as unique identifier. Name string `yaml:"name"` Description string `yaml:"description,omitempty"` // Default value of the variable Default string `yaml:"default,omitempty"` // If set to true, the prompt will be yes/no question, and the value type will be boolean Confirm bool `yaml:"confirm,omitempty"` // If set to true, the variable can be left empty Optional bool `yaml:"optional,omitempty"` // The user selects the value from a list of options Options []string `yaml:"options,omitempty"` // Validators for the variable Validators []VariableValidator `yaml:"validators,omitempty"` // Makes the variable conditional based on the result of the expression. The result of the evaluation needs to be a boolean value. Uses https://github.com/antonmedv/expr If string `yaml:"if,omitempty"` // Set the variable as a table type with columns defined by this property Columns []string `yaml:"columns,omitempty"` }
type VariableValidator ¶ added in v0.1.12
type VariableValidator struct { // Regular expression pattern to match the input against Pattern string `yaml:"pattern,omitempty"` // If the regular expression validation fails, this help message will be shown to the user Help string `yaml:"help,omitempty"` // Apply the validator to a column if the variable type is table Column string `yaml:"column,omitempty"` }
func (*VariableValidator) CreateValidatorFunc ¶ added in v0.1.12
func (r *VariableValidator) CreateValidatorFunc() func(input string) error
type VariableValues ¶
type VariableValues map[string]interface{}
VariableValues stores values for each variable
Click to show internal directories.
Click to hide internal directories.