parsers

package
v0.6.24 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultVariableTemplate = JsonVariableTemplate
View Source
const InvalidTemplate = "invalid-template"
View Source
const UnknownVariableErrorMsg = "unknown variables found, %s"
View Source
const UnknownVariableFound = "unknown-variable-found"
View Source
const VariableParsingFailed = "variable-parsing-failed"
View Source
const VariableRegex = `@\{\{[a-zA-Z0-9-+/*%_\s]+\}\}`
View Source
const VariableSubRegexWithQuotes = `\"@{{([a-zA-Z0-9-+/*%_\s]+)}}\"`

Variables

View Source
var ParseBoolFunc = function.New(&function.Spec{
	Description: `convert to bool value`,
	Params: []function.Parameter{
		{
			Name:             "val",
			Type:             cty.String,
			AllowDynamicType: true,
			AllowMarked:      true,
		},
	},
	Type:         function.StaticReturnType(cty.Bool),
	RefineResult: refineNonNull,
	Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
		boolVal, err := strconv.ParseBool(args[0].AsString())
		return cty.BoolVal(boolVal), err
	},
})

Functions

func GetScopedVarData

func GetScopedVarData(varData map[string]string) []*models.ScopedVariableData

Types

type VariableParserRequest

type VariableParserRequest struct {
	TemplateType           VariableTemplateType
	Template               string
	Variables              []*models.ScopedVariableData
	IgnoreUnknownVariables bool
}

func (VariableParserRequest) GetValuesMap

func (request VariableParserRequest) GetValuesMap() map[string]string

type VariableParserResponse

type VariableParserResponse struct {
	Request          VariableParserRequest
	ResolvedTemplate string
	Error            error
	DetailedError    string
}

type VariableTemplateParser

type VariableTemplateParser interface {
	ExtractVariables(template string, templateType VariableTemplateType) ([]string, error)
	//ParseTemplate(template string, values map[string]string) string
	ParseTemplate(parserRequest VariableParserRequest) VariableParserResponse
}

type VariableTemplateParserConfig added in v0.6.24

type VariableTemplateParserConfig struct {
	ScopedVariableEnabled          bool `env:"SCOPED_VARIABLE_ENABLED" envDefault:"false"`
	ScopedVariableHandlePrimitives bool `env:"SCOPED_VARIABLE_HANDLE_PRIMITIVES" envDefault:"false"`
}

type VariableTemplateParserImpl

type VariableTemplateParserImpl struct {
	// contains filtered or unexported fields
}

func NewVariableTemplateParserImpl

func NewVariableTemplateParserImpl(logger *zap.SugaredLogger) (*VariableTemplateParserImpl, error)

func (*VariableTemplateParserImpl) ExtractVariables

func (impl *VariableTemplateParserImpl) ExtractVariables(template string, templateType VariableTemplateType) ([]string, error)

func (*VariableTemplateParserImpl) ParseTemplate

func (impl *VariableTemplateParserImpl) ParseTemplate(parserRequest VariableParserRequest) VariableParserResponse

type VariableTemplateType

type VariableTemplateType int
const (
	StringVariableTemplate VariableTemplateType = 0
	JsonVariableTemplate                        = 1
)

Jump to

Keyboard shortcuts

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