regex

package
v2.14.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvVariableRegexPattern = regexp.MustCompile(`{{ *\.Env\.([A-Za-z0-9_-]*) *}}`)

EnvVariableRegexPattern matching environment variable template reference of the format '{{ .Env.NAME_OF_VAR }}' accepting any possible whitespace before and after the actual variable, and capturing the name of the actual env var (anything following .Env. up to the first whitespace or } character)

View Source
var ListVariableRegexPattern = regexp.MustCompile(`"[\w\s]+"\s*:\s*(\[\s*\{\{\s*\.([\w]+)\s*}}\s*])`)

ListVariableRegexPattern matching list references in a Template, capturing the variable name as well as the enclosing square bracket block Sample format: "listKey": [ {{.list_variable}} ], captures: "[ {{.list_variable}} ]" and "list_variable"

Functions

func IsEnvVariable

func IsEnvVariable(s string) bool

IsEnvVariable checks if a given string conforms to how monaco expects an environment variable reference looks in a template ( '{{ .Env.NAME_OF_VAR }}' )

func IsListDefinition

func IsListDefinition(s string) bool

IsListDefinition checks if a given string conforms to a pattern of the format '"value", "value", ...' which are sometimes used to set lists into JSON templates

func IsSimpleValueDefinition

func IsSimpleValueDefinition(s string) bool

IsSimpleValueDefinition checks if a given string is any text between double quotes

func MatchListVariable

func MatchListVariable(s string) (fullMatch string, listMatch string, variableName string, err error)

func TrimToEnvVariableName

func TrimToEnvVariableName(envReference string) string

TrimToEnvVariableName takes an environment variable reference of the format '{{ .Env.NAME_OF_VAR }}' and trims it down to just the name of the environment variable ('NAME_OF_VAR'). If an input does not conform to the expected format of an environment variable, this will return the input back as is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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