moduleconfig

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFirstConditionElseValue added in v0.2.1

func GetFirstConditionElseValue(parameter Parameter) string

GetFirstConditionElseValue returns the default value of the first condition that has a default

func SummarizeConditions added in v0.1.0

func SummarizeConditions(module ModuleConfig) []projectconfig.Condition

SummarizeConditions based on conditions from zero-module.yml creates and returns slice of conditions for project config

func SummarizeParameters added in v0.1.0

func SummarizeParameters(module ModuleConfig, allParams map[string]string) map[string]string

SummarizeParameters receives all parameters gathered from prompts during `Zero init` and based on module definition to construct the parameters for each module for zero-project.yml filters out parameters defined as OmitFromProjectFile: true

func ValidateZeroVersion added in v0.1.0

func ValidateZeroVersion(mc ModuleConfig) bool

ValidateZeroVersion receives a module config, and returns whether the running zero's binary is compatible with the module

Types

type Condition

type Condition struct {
	Action     string   `yaml:"action"`
	MatchField string   `yaml:"matchField"`
	WhenValue  string   `yaml:"whenValue"`
	Data       []string `yaml:"data,omitempty"`
	ElseValue  string   `yaml:"elseValue,omitempty"`
}

type ModuleCommands added in v0.1.1

type ModuleCommands struct {
	Apply   string `yaml:"apply,omitempty"`
	Check   string `yaml:"check,omitempty"`
	Summary string `yaml:"summary,omitempty"`
}

type ModuleConfig

type ModuleConfig struct {
	Name                string
	Description         string
	Author              string
	Commands            ModuleCommands `yaml:"commands,omitempty"`
	DependsOn           []string       `yaml:"dependsOn,omitempty"`
	TemplateConfig      `yaml:"template"`
	RequiredCredentials []string           `yaml:"requiredCredentials"`
	ZeroVersion         VersionConstraints `yaml:"zeroVersion,omitempty"`
	Parameters          []Parameter
	Conditions          []Condition `yaml:"conditions,omitempty"`
}

func LoadModuleConfig

func LoadModuleConfig(filePath string) (ModuleConfig, error)

func (ModuleConfig) GetParamEnvVarTranslationMap added in v0.1.0

func (cfg ModuleConfig) GetParamEnvVarTranslationMap() map[string]string

GetParamEnvVarTranslationMap returns a map for translating parameter's `Field` into env-var keys It loops through each parameter then adds to translation map if applicable for zero apply / zero init's prompt execute, this is useful for translating params like AWS credentials for running the AWS cli

type Parameter

type Parameter struct {
	Field               string
	Label               string        `yaml:"label,omitempty"`
	Options             yaml.MapSlice `yaml:"options,omitempty"`
	Execute             string        `yaml:"execute,omitempty"`
	Value               string        `yaml:"value,omitempty"`
	Default             string        `yaml:"default,omitempty"`
	Info                string        `yaml:"info,omitempty"`
	FieldValidation     Validate      `yaml:"fieldValidation,omitempty"`
	Type                string        `yaml:"type,omitempty"`
	OmitFromProjectFile bool          `yaml:"omitFromProjectFile,omitempty"`
	Conditions          []Condition   `yaml:"conditions,omitempty"`
	EnvVarName          string        `yaml:"envVarName,omitempty"`
}

type TemplateConfig

type TemplateConfig struct {
	StrictMode bool
	Delimiters []string
	InputDir   string `yaml:"inputDir"`
	OutputDir  string `yaml:"outputDir"`
}

type Validate

type Validate struct {
	Type         string `yaml:"type,omitempty"`
	Value        string `yaml:"value,omitempty"`
	ErrorMessage string `yaml:"errorMessage,omitempty"`
}

type VersionConstraints added in v0.1.0

type VersionConstraints struct {
	goVersion.Constraints
}

func (*VersionConstraints) UnmarshalYAML added in v0.1.0

func (semVer *VersionConstraints) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML Parses a version constraint string into go-version constraint during yaml parsing

Jump to

Keyboard shortcuts

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