Unverified Commit 36b6c3e7 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Fix: trim quot char for velaql output (#4269)

Signed-off-by: default avatarJianbo Sun <jianbo.sjb@alibaba-inc.com>
(cherry picked from commit fdd0c93dbaef9b8be86fa67c9306cb595dfd97c4)
Co-authored-by: default avatarJianbo Sun <jianbo.sjb@alibaba-inc.com>
parent 4cc01972
Showing with 8 additions and 4 deletions
+8 -4
......@@ -21,6 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"github.com/spf13/cobra"
"sigs.k8s.io/controller-runtime/pkg/client"
......@@ -47,7 +48,10 @@ func NewQlCommand(c common.Args, order string, ioStreams util.IOStreams) *cobra.
cmd := &cobra.Command{
Use: "ql",
Short: "Show result of executing velaQL.",
Long: "Show result of executing velaQL.",
Long: `Show result of executing velaQL, use it like:
vela ql --query "<inner-view-name>{<param1>=<value1>,<param2>=<value2>}
vela ql --file=./ql.cue
`,
Example: `Users can query with a query statement:
vela ql --query "<inner-view-name>{<param1>=<value1>,<param2>=<value2>}"
They can also query by a ql file:
......@@ -133,11 +137,11 @@ func print(queryValue *value.Value, cmd *cobra.Command) error {
return err
}
var out bytes.Buffer
err = json.Indent(&out, response, "", " ")
err = json.Indent(&out, response, "", " ")
if err != nil {
return err
}
cmd.Printf("%s\n", out.String())
cmd.Println(strings.Trim(strings.TrimSpace(out.String()), "\""))
return nil
}
......
......@@ -76,7 +76,7 @@ export: "status"
var buff = bytes.NewBufferString("")
cmd.SetOut(buff)
Expect(queryFromView(context.TODO(), k8sClient, arg, name, cmd)).Should(BeNil())
Expect(buff.String()).Should(ContainSubstring(`my-value`))
Expect(strings.TrimSpace(buff.String())).Should(BeEquivalentTo("my-value"))
})
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment