Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st2 pack install --json outputs non-json text to stdout #4260

Closed
nmaludy opened this issue Jul 23, 2018 · 4 comments · Fixed by #4394
Closed

st2 pack install --json outputs non-json text to stdout #4260

nmaludy opened this issue Jul 23, 2018 · 4 comments · Fixed by #4394
Assignees

Comments

@nmaludy
Copy link
Member

nmaludy commented Jul 23, 2018

SUMMARY

When running st2 pack install --json xxx there is information printed to stdout that is not in JSON format, causing integration with external tools that expect JSON to fail.

ISSUE TYPE
  • Bug Report
STACKSTORM VERSION
$ st2 --version
st2 2.8.1, on Python 2.7.5
OS / ENVIRONMENT / INSTALL METHOD
os = CentOS 7
install method = one-liner
STEPS TO REPRODUCE
$ st2 pack install --json git
EXPECTED RESULTS

Output should only contain JSON on stdout (and ideally stderr)

$ st2 pack install --json git
{
    "author": "StackStorm, Inc.", 
    "description": "st2 content pack containing git integrations", 
    "name": "git", 
    "version": "0.4.0"
    "content":
    {
        "rules": 1,
        "sensors": 1,
        "triggers": 0,
        "actions": 3,
        "aliases": 1
    }
}
ACTUAL RESULTS

Note the non-JSON text above the JSON output.

$ st2 pack install --json git
For the "git" pack, the following content will be registered:

rules     |  1
sensors   |  1
triggers  |  0
actions   |  3
aliases   |  0

Installation may take a while for packs with many items.
{
    "author": "StackStorm, Inc.", 
    "description": "st2 content pack containing git integrations", 
    "name": "git", 
    "version": "0.4.0"
}
@arm4b arm4b added the bug label Jul 23, 2018
@Kami Kami added the CLI label Sep 3, 2018
@lakshmi-kannan lakshmi-kannan self-assigned this Oct 12, 2018
@lakshmi-kannan
Copy link
Contributor

@nmaludy Is this an actual issue meaning are you trying to tool around st2 pack install -j? Or is this just a cosmetic issue?

I can try it make all json but I am not sure how "useful" this is?

@nmaludy
Copy link
Member Author

nmaludy commented Oct 12, 2018

@lakshmi-kannan I ran into this when working on Tasks for the StackStorm puppet module. Those tasks call st2 pack install -j. It's expecting JSON output so there it can returning meaningful, structured data to the caller.

I just really want the output to contain only JSON data, or only YAML data when requesting those output formats. Then parsing the data from another program is straight forward.

Does that make sense?

@lakshmi-kannan
Copy link
Contributor

@nmaludy Yes. I'll see how can I make everything JSON output there but some of the info returned there assumes a human. So maybe just skipping it if --json is specified is an acceptable change you think?

@nmaludy
Copy link
Member Author

nmaludy commented Oct 12, 2018

Yeah , I think skipping if asking for JSON it YAML is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants