Generating of description for entities in combination of `json` and `write to file` is broken
Drakorgaur opened this issue · 0 comments
Drakorgaur commented
Problem definition
In an attempt to create a description of an operator, account, or user using the nsc
tool with the output in JSON format and writing the output to a file via the --output-file
flag, the tool returns an error.
Steps to reproduce:
- set up nsc(set env vars, prepare space, etc)
- create operator(account, user optional)
- run
nsc describe operator -J --output-file $(pwd)/test.json
Expected behaviour:
Stdout:
[ OK ] wrote operator description to `~/<omitted>/test.json`
Real behaviour:
Stdout:
Error: expected 3 chunks
Problem explaination
When cmd.Json
is set, Load method sets raw
attribute as JSON-bytes
func (p *DescribeUserParams) Load(ctx ActionCtx) error {
. . .
p.raw, err = bodyAsJson(p.raw)
. . .
}
after this in Run method tries to decode JWT:
func (p *DescribeUserParams) Run(ctx ActionCtx) (store.Status, error) {
. . .
p.raw, err = jwt.DecorateJWT(string(p.raw))
. . .
}
which expects bytes be separated by dot, but it's already decoded to JSON.