Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot]
e6bcc7de1f Fix: add parse comments in lookupScript to make patch work (#3843)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
(cherry picked from commit 1758dc319d)

Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2022-05-10 13:38:07 +08:00
github-actions[bot]
a67270fb00 Fix: pend registry test (#3422)
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
(cherry picked from commit c8d9035109)

Co-authored-by: Somefive <yd219913@alibaba-inc.com>
2022-03-11 11:38:25 +08:00
3 changed files with 20 additions and 2 deletions

View File

@@ -317,7 +317,7 @@ func (val *Value) LookupValue(paths ...string) (*Value, error) {
func (val *Value) LookupByScript(script string) (*Value, error) {
var outputKey = "zz_output__"
script = strings.TrimSpace(script)
scriptFile, err := parser.ParseFile("-", script)
scriptFile, err := parser.ParseFile("-", script, parser.ParseComments)
if err != nil {
return nil, errors.WithMessage(err, "parse script")
}
@@ -327,7 +327,7 @@ func (val *Value) LookupByScript(script string) (*Value, error) {
return nil, err
}
rawFile, err := parser.ParseFile("-", raw)
rawFile, err := parser.ParseFile("-", raw, parser.ParseComments)
if err != nil {
return nil, errors.WithMessage(err, "parse script")
}

View File

@@ -597,6 +597,23 @@ func TestLookupByScript(t *testing.T) {
}{
{
src: `
traits: {
ingress: {
// +patchKey=name
test: [{name: "main", image: "busybox"}]
}
}
`,
script: `traits["ingress"]`,
expect: `// +patchKey=name
test: [{
name: "main"
image: "busybox"
}]
`,
},
{
src: `
apply: containers: [{name: "main", image: "busybox"}]
`,
script: `apply.containers[0].image`,

View File

@@ -25,6 +25,7 @@ import (
)
func TestRegistry(t *testing.T) {
t.Skip("temporary pend this test")
testAddon := "dynamic-sa"
regName := "testReg"
localPath, err := filepath.Abs("../../e2e/plugin/testdata")