Documentation ¶
Index ¶
- func ApplyArrayReplacements(in string, stringReplacements map[string]string, ...) []string
- func ApplyReplacements(in string, replacements map[string]string) string
- func ExtractArrayIndexingParamsExpressions(s string) []string
- func ExtractIndex(s string) (int, error)
- func ExtractIndexString(s string) string
- func ExtractVariableExpressions(s, prefix string) ([]string, error)
- func ExtractVariablesFromString(s, prefix string) ([]string, bool, string)
- func StripStarVarSubExpression(s string) string
- func TrimArrayIndex(s string) string
- func ValidateNoReferencesToEntireProhibitedVariables(value, prefix string, vars sets.String) *apis.FieldError
- func ValidateNoReferencesToProhibitedVariables(value, prefix string, vars sets.String) *apis.FieldError
- func ValidateNoReferencesToUnknownVariables(value, prefix string, vars sets.String) *apis.FieldError
- func ValidateVariableReferenceIsIsolated(value, prefix string, vars sets.String) *apis.FieldError
- func ValidateWholeArrayOrObjectRefInStringVariable(name, value, prefix string, vars sets.String) (isIsolated bool, errs *apis.FieldError)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyArrayReplacements ¶
func ApplyArrayReplacements(in string, stringReplacements map[string]string, arrayReplacements map[string][]string) []string
ApplyArrayReplacements takes an input string, and output an array of strings related to possible arrayReplacements. If there aren't any areas where the input can be split up via arrayReplacements, then just return an array with a single element, which is ApplyReplacements(in, replacements).
func ApplyReplacements ¶
ApplyReplacements returns a string with references to parameters replaced, based on the mapping provided in replacements. For example, if the input string is "foo: $(params.foo)", and replacements maps "params.foo" to "bar", the output would be "foo: bar".
func ExtractArrayIndexingParamsExpressions ¶
ExtractArrayIndexingParamsExpressions will find all `$(params.paramName[int])` expressions
func ExtractIndex ¶
ExtractIndex will extract int from `[int]`
func ExtractIndexString ¶
ExtractIndexString will find the leftmost match of `[int]`
func ExtractVariablesFromString ¶
ExtractVariablesFromString extracts variables from an input string s with the given prefix via regex matching. It returns a slice of strings which contains the extracted variables, a bool flag to indicate if matches were found and the error string if the referencing of parameters is invalid. If the string does not contain the input prefix then the output will contain a slice of strings with length 0.
func StripStarVarSubExpression ¶
StripStarVarSubExpression strips "$(target[*])"" to get "target"
func TrimArrayIndex ¶
TrimArrayIndex replaces all `[i]` and `[*]` to "".
func ValidateNoReferencesToEntireProhibitedVariables ¶
func ValidateNoReferencesToEntireProhibitedVariables(value, prefix string, vars sets.String) *apis.FieldError
ValidateNoReferencesToEntireProhibitedVariables returns an error if the input string contains any whole array/object references to any variables in vars. References to array indexes or object keys are permitted.
Inputs: - value: a string containing a reference to a variable that can be substituted, e.g. "echo $(params.foo)" - prefix: the prefix of the substitutable variable, e.g. "params" or "context.pipeline" - vars: names of known variables
func ValidateNoReferencesToProhibitedVariables ¶
func ValidateNoReferencesToProhibitedVariables(value, prefix string, vars sets.String) *apis.FieldError
ValidateNoReferencesToProhibitedVariables returns an error if the input string contains any references to any variables in vars, except for array indexing references.
Inputs: - value: a string containing a reference to a variable that can be substituted, e.g. "echo $(params.foo)" - prefix: the prefix of the substitutable variable, e.g. "params" or "context.pipeline" - vars: names of known variables
func ValidateNoReferencesToUnknownVariables ¶
func ValidateNoReferencesToUnknownVariables(value, prefix string, vars sets.String) *apis.FieldError
ValidateNoReferencesToUnknownVariables returns an error if the input string contains references to unknown variables Inputs: - value: a string containing a reference to a variable that can be substituted, e.g. "echo $(params.foo)" - prefix: the prefix of the substitutable variable, e.g. "params" or "context.pipeline" - vars: names of known variables
func ValidateVariableReferenceIsIsolated ¶
func ValidateVariableReferenceIsIsolated(value, prefix string, vars sets.String) *apis.FieldError
ValidateVariableReferenceIsIsolated returns an error if the input string contains characters in addition to references to known parameters. For example, if "foo" is a known parameter, a value of "foo: $(params.foo)" returns an error, but a value of "$(params.foo)" does not. Inputs: - value: a string containing a reference to a variable that can be substituted, e.g. "echo $(params.foo)" - prefix: the prefix of the substitutable variable, e.g. "params" or "context.pipeline" - vars: names of known variables
func ValidateWholeArrayOrObjectRefInStringVariable ¶
func ValidateWholeArrayOrObjectRefInStringVariable(name, value, prefix string, vars sets.String) (isIsolated bool, errs *apis.FieldError)
ValidateWholeArrayOrObjectRefInStringVariable validates if a single string field uses references to the whole array/object appropriately valid example: "$(params.myObject[*])" invalid example: "$(params.name-not-exist[*])"
Types ¶
This section is empty.