openshift-eng/elliott

elliot get - "--json" flag is missing

Closed this issue · 17 comments

According to the documentation, the output of the get subcommand can be formatted in JSON using the --json flag, but this flag is missing.

 > elliott get --json 40392
Usage: elliott get [OPTIONS] ADVISORY
Try "elliott get -h" for help.

Error: no such option: --json

This is a feature that was lost when we switched over from called the ET api ourselves to using https://github.com/red-hat-storage/errata-tool/

Is json output something that would be helpful to you? If so, I can try and make time to reimplement, otherwise I will just update the documentation.

Yes, Json output is useful. It much safer than use grep/awk to parse elliott's output.

Hi, we need this to process the output in our pipeline. Having to parse the text to get to the list of builds is very brittle.

I'd dare to say reinstating --json should be a high priority.

Just to add a +1 here.

json would make it easy to integrate elliott in other tools and workflows due to built-in support for parsing / marshaling json objects, etc.

I've opened red-hat-storage/errata-tool#156 , but this seems like it is a more specific use-case for listing builds in an advisory. In other words, it sounds like some other tools are consuming the JSON from the elliot CLI, and you would not want the "DEBUG: ..." prefix, etc.

Can these tools use the Python errata-tool library directly, or do they need to shell out to elliot?

If they must shell out, would you please give an example of the exact JSON you need for this?

That is a good question:

"Can these tools use the Python errata-tool library directly, or do they need to shell out to elliot?"

In my specific case that is what I am doing for replacing elliott "get" due to the loss of --json.
It was basically a one line change. The big value of elliott comes from operations like "create".

But we were trying to consolidate operations by always calling elliott, which has been mage into a Jenkins step (or global variable) in the RHPROD shared library, aptly named 'elliott' :-)

The step idea a few details (like kerberos authentication) and code using it becomes more clear than code calling an endpoint with an URL repeated in many places.

And if the API changes someday there is only one place to change. It just happened with the Ansible Tower.

In summary, it would still be preferable to use elliott with the --json flag than calling the API directly.

There's a lot of context I'm missing here unfortunately. I'm not familiar with RHPROD, or the point about kerberos, but we've not yet had to break the API for python-errata-tool, and we follow semver there.

What is the example JSON you need for elliot get? I guess I can look back through the Git history of this project and find a point where it was working?

I'm working on adding --json back to elliott get as well as adding it to elliott find-builds over at #37

I wasn't particularly aware of the concerns about the API changing, and I probably should pay more attention to it, would be nice if errata-tool could serve as something of a facade for the API, but for now it seemed easiest to just work with what the API gives back.

Nice! thanks @sosiouxme ! 👍

@sosiouxme I'd like to merge red-hat-storage/errata-tool#160 and then cut a new release of that project. I will be on vacation for the latter half of this week, so I will plan to tag and release the new python-errata-tool version to PyPI Apr 29th.

I've pushed errata-tool v1.19.0 to https://pypi.org/project/errata-tool/ today.

Thanks, then I can officially require it :)

Hi guys, is ET v1.19.0 deployed to production yet?

What does it mean to deploy a version to production?

I mean, be in the ET that we are currently using. I was assuming that you had "stage" and set release dates like Koji (Brew). I just want to know if we can use this now in the RHPROD library (part of the CPaaS initiative)

Oh ok. I'm not part of the Errata Tool team. I just maintain the errata-tool Python library, and I don't have a schedule for that.

Issue was resolved. didn't check for how long it was resolved already, but using the current latest version https://pypi.org/project/rh-elliott/0.2.14/ gives us a beautiful JSON output.

$ elliott get 40392 --json -                                                               
{                         
    "actual_ship_date": null, 
    "assigned_to_id": 3001603, 
    "batch_id": null,                    
    "cloned_from_id": null, 
    "closed": 0,       
    "content_types": [
        "docker"       
    ],          
    "contract": null,  
    "created_at": "2019-03-19T14:02:52Z", 
........