Documentation ¶
Index ¶
- Constants
- Variables
- func PushRecipe(ctx context.Context, path string, opts oci.Repository, replaceLatest bool) error
- func SaveRemoteRecipe(ctx context.Context, dest string, opts oci.Repository) error
- func ValidatePath(basePath, filePath string) error
- func ValidateSubpath(path string) error
- type File
- type Manifest
- type ManifestRecipe
- type Metadata
- type MultiSelectValue
- type Recipe
- type RecipeConflict
- type RenderEngine
- type Sauce
- type TableValue
- type TemplateContext
- type Test
- type URLType
- type Variable
- type VariableType
- type VariableValidator
- type VariableValues
Constants ¶
const ( YAMLExtension = ".yml" RecipeFileName = "recipe" RecipeTemplatesDirName = "templates" RecipeTestsDirName = "tests" RecipeTestMetaFileName = "test" RecipeTestFilesDirName = "files" IgnoreFileName = ".jalapenoignore" ManifestFileName = "manifest" )
const ( SaucesFileName = "sauces" // The directory name which contains all Jalapeno related files // in the project directory SauceDirName = ".jalapeno" )
const (
HashPrefix = "sha256:"
)
const LatestTag = "latest"
Variables ¶
var ( ErrSauceNotFound = errors.New("sauce not found") ErrAmbiguousSauce = errors.New("multiple sauces found with same recipe") )
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") )
var (
)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
func ValidatePath ¶ added in v1.10.0
func ValidateSubpath ¶ added in v1.4.0
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) HasBeenModifiedByUser ¶ added in v1.5.0
type Manifest ¶ added in v1.8.0
type Manifest struct { APIVersion string `yaml:"apiVersion"` Recipes []ManifestRecipe `yaml:"recipes"` }
func LoadManifest ¶ added in v1.8.0
func NewManifest ¶ added in v1.8.0
func NewManifest() Manifest
type ManifestRecipe ¶ added in v1.8.0
type ManifestRecipe struct { Name string `yaml:"name"` Version string `yaml:"version"` Repository string `yaml:"repository"` Values VariableValues `yaml:"values,omitempty"` }
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"` // Changelog of recipe versions Changelog map[string]string `yaml:"changelog,omitempty"` // URL to source code for this recipe Source string `yaml:"source,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"` }
func (*Metadata) UpdateVersion ¶ added in v1.14.0
type MultiSelectValue ¶ added in v1.12.0
type MultiSelectValue []string
func (*MultiSelectValue) FromString ¶ added in v1.12.0
func (v *MultiSelectValue) FromString(s string, delimiter rune)
func (MultiSelectValue) ToString ¶ added in v1.12.0
func (v MultiSelectValue) ToString(delimiter rune) string
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 { // Version of the sauce API schema. Currently should have value "v1" APIVersion string `yaml:"apiVersion"` // The recipe which was used to render the sauce Recipe Recipe `yaml:"recipe"` // Values which was used to execute the recipe Values VariableValues `yaml:"values,omitempty"` // Files genereated from the recipe 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"` // SubPath is used as a prefix when saving and loading the files rendered by the sauce. // This is useful for example in monorepos where the sauce is rendered to a subdirectory of the project directory. SubPath string `yaml:"subPath,omitempty"` // CheckFrom defines the repository where updates should be checked for the recipe CheckFrom string `yaml:"from,omitempty"` }
Sauce represents a rendered recipe
func LoadSauceByID ¶ added in v1.4.0
func LoadSauceByRecipe ¶ added in v1.4.0
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.
func (*Sauce) CreateTemplateContext ¶ added in v1.4.0
func (*Sauce) RenderInitHelp ¶ added in v1.4.0
type TableValue ¶ added in v1.1.1
func (*TableValue) FromCSV ¶ added in v1.1.1
func (t *TableValue) FromCSV(columns []string, input string, delimiter rune) error
func (TableValue) ToMapSlice ¶ added in v1.1.1
func (t TableValue) ToMapSlice() []map[string]string
type TemplateContext ¶ added in v1.4.0
type TemplateContext struct { ID string Recipe struct { APIVersion string Name string Version string Source string } Variables VariableValues }
TemplateContext defines the context that is passed to the template engine
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"` // Expected initHelp of the recipe when rendered with the values specified in the test ExpectedInitHelp string `yaml:"expectedInitHelp,omitempty"` // If true, test will not fail if the templates generates more files than the test specifies IgnoreExtraFiles bool `yaml:"ignoreExtraFiles,omitempty"` // Snapshots of the rendered templates which were rendered with the values specified in the test Files map[string]File `yaml:"-"` }
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"` // If set to true, the user can select multiple values from the list of options Multi bool `yaml:"multi,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/expr-lang/expr If string `yaml:"if,omitempty"` // Set the variable as a table type with columns defined by this property Columns []string `yaml:"columns,omitempty"` }
func (Variable) DetermineType ¶ added in v1.3.0
func (v Variable) DetermineType() VariableType
func (Variable) ParseDefaultValue ¶ added in v1.3.0
type VariableType ¶ added in v1.3.0
type VariableType uint8
const ( VariableTypeUnknown VariableType = iota VariableTypeString VariableTypeBoolean VariableTypeSelect VariableTypeMultiSelect VariableTypeTable )
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"` // When targeting table columns, set this to true to make sure that the values in the column are unique Unique bool `yaml:"unique,omitempty"` }
func (*VariableValidator) CreateTableValidatorFunc ¶ added in v1.9.0
func (*VariableValidator) CreateValidatorFunc ¶ added in v0.1.12
func (r *VariableValidator) CreateValidatorFunc() (func(input string) error, error)
func (*VariableValidator) RequiresTableContext ¶ added in v1.10.1
func (r *VariableValidator) RequiresTableContext() bool
RequiresTableContext returns true if the validator function should be created with CreateTableValidatorFunc
type VariableValues ¶
type VariableValues map[string]interface{}
VariableValues stores values for each variable
func (*VariableValues) UnmarshalYAML ¶ added in v1.2.0
func (vv *VariableValues) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler interface
func (VariableValues) Validate ¶ added in v1.8.0
func (val VariableValues) Validate() error
NOTE: This function does note validate the values against the variable definitions. It only checks if the name of the values are not empty and the values are of supported types.