mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
Removing escape char processing from strenv #2517
This commit is contained in:
parent
9e0c5fd3c9
commit
1b91fc63ea
@ -32,7 +32,7 @@ func envOperator(_ *dataTreeNavigator, context Context, expressionNode *Expressi
|
|||||||
node = &CandidateNode{
|
node = &CandidateNode{
|
||||||
Kind: ScalarNode,
|
Kind: ScalarNode,
|
||||||
Tag: "!!str",
|
Tag: "!!str",
|
||||||
Value: processEscapeCharacters(rawValue),
|
Value: rawValue,
|
||||||
}
|
}
|
||||||
} else if rawValue == "" {
|
} else if rawValue == "" {
|
||||||
return Context{}, fmt.Errorf("value for env variable '%v' not provided in env()", envName)
|
return Context{}, fmt.Errorf("value for env variable '%v' not provided in env()", envName)
|
||||||
|
|||||||
@ -63,78 +63,6 @@ var envOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[], ()::a: \"12\"\n",
|
"D0, P[], ()::a: \"12\"\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
description: "strenv with newline escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\n"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: |\n string with a\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with tab escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\t"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\t\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with carriage return escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\r"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\r\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with form feed escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\f"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\f\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with vertical tab escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\v"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\v\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with backspace escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\b"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\b\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with alert/bell escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\a"},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: \"string with a\\a\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "strenv with double quote escape",
|
|
||||||
skipDoc: true,
|
|
||||||
environmentVariables: map[string]string{"myenv": "string with a\\\""},
|
|
||||||
expression: `.a = strenv(myenv)`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], ()::a: string with a\"\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
description: "Dynamically update a path from an environment variable",
|
description: "Dynamically update a path from an environment variable",
|
||||||
subdescription: "The env variable can be any valid yq expression.",
|
subdescription: "The env variable can be any valid yq expression.",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user