Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

elliot get - "--json" flag is missing #27

Closed
gbenhaim opened this issue Mar 31, 2019 · 17 comments
Closed

elliot get - "--json" flag is missing #27

gbenhaim opened this issue Mar 31, 2019 · 17 comments

Comments

@gbenhaim
Copy link

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
@smunilla
Copy link
Contributor

smunilla commented Apr 1, 2019

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.

@gbenhaim
Copy link
Author

gbenhaim commented Apr 2, 2019

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

@fnasser
Copy link

fnasser commented Apr 2, 2019

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.

@gsaslis
Copy link

gsaslis commented Apr 3, 2019

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.

@ktdreyer
Copy link

ktdreyer commented Apr 3, 2019

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?

@fnasser
Copy link

fnasser commented Apr 4, 2019

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.

@ktdreyer
Copy link

ktdreyer commented Apr 4, 2019

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?

@sosiouxme
Copy link
Contributor

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.

@gsaslis
Copy link

gsaslis commented Apr 22, 2019

Nice! thanks @sosiouxme ! 👍

@ktdreyer
Copy link

@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.

@ktdreyer
Copy link

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

@sosiouxme
Copy link
Contributor

Thanks, then I can officially require it :)

@fnasser
Copy link

fnasser commented May 23, 2019

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

@ktdreyer
Copy link

What does it mean to deploy a version to production?

@fnasser
Copy link

fnasser commented May 23, 2019

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)

@ktdreyer
Copy link

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.

@thiagoalessio
Copy link
Contributor

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", 
........

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

No branches or pull requests

7 participants