Bug 1836391
| Summary: | hammer erratum list --fields does not work for all fields | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Stephen Wadeley <swadeley> |
| Component: | Hammer | Assignee: | satellite6-bugs <satellite6-bugs> |
| Status: | CLOSED WORKSFORME | QA Contact: | Stephen Wadeley <swadeley> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.7.0 | CC: | apatel, kgaikwad, mshira, ofedoren, rabajaj |
| Target Milestone: | Unspecified | Keywords: | Triaged |
| Target Release: | Unused | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-06-02 10:36:54 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Stephen Wadeley
2020-05-15 19:01:32 UTC
Hello,
The command works just fine. Probably you've wrongly specified fields to display.
To have printed `id` and errata `type` fields only, you need to specify those fields as they are shown in the default output:
> hammer ... --fields 'id,type'
Additional:
By default this command has ID,Errata ID,Type,Title,Issued,Updated fields. This command has not `errata_type` or `errata_id` fields. It's just `type` and `errata id` respectively.
Could you please try again with this information and confirm if this is still a bug?
Hello Oleh
thank you for the quick response.
I confirm 'type' works:
[root@dell-r330-12 ~]# hammer erratum list --fields 'id,type'
-----|------------
ID | TYPE
-----|------------
32 | bugfix
9048 | security
But I am not getting any thing for:
root@dell-r330-12 ~]# hammer erratum list --fields 'errata_id'
<blank output>
The help output has these two lines under Search / Order fields:
errata_id string
errata_type string
that is why I was trying those two values. Its actually the 'errata_id' I wanted to use in a script.
BTW, there is a typo in:
--fields FIELDS Show specified fileds or predefined filed sets only.
s/fileds/fields/ and s/filed/field/
I wanted to make pull request, but could not find that line in the repos:
hammer-cli-katello]$ grep -r "Show specified" .
<no hits>
hammer-cli-foreman]$ grep -r "Show specified" .
<no hits>
Looking in the repo, in lib/hammer_cli_katello/erratum_info_command.rb, I see:
field :errata_id, _("Errata ID")
field :type, _("Type")
so errata_id should work.
[root@dell-r330-12 ~]# hammer erratum list --fields 'id,errata_id' | head -n 4
----
ID
----
32
but does not on my system.
Thank you
Hello again, 1) Thanks for additional information. As I said (probably not clearly enough, sorry), you need to use labels for --fields option. So, even though in the code the field's id is `errata_id` the label of it is just `errata id` (without the underscore). --fields option uses labels because this is what user can see in the command's output, he cannot see the actual ids. 2) Since this option comes as a default one from the core, you need to search for it in the hammer-cli repo: https://github.com/theforeman/hammer-cli/blob/master/lib/hammer_cli/options/predefined.rb. Thanks for noticing this! We could translate this BZ for this issue if the described one is not an actual issue. 3) Search / Order fields are the fields you can pass to --search/--order options only. (In reply to Oleh Fedorenko from comment #3) > Hello again, > > 1) Thanks for additional information. As I said (probably not clearly > enough, sorry), you need to use labels for --fields option. So, even though > in the code the field's id is `errata_id` the label of it is just `errata > id` (without the underscore). --fields option uses labels because this is > what user can see in the command's output, he cannot see the actual ids. I confirm that works: [root@dell-r330-12 ~]# hammer erratum list --fields 'id,errata id' -----|---------------- ID | ERRATA ID -----|---------------- 32 | RHBA-2020:2139 9048 | RHSA-2020:2081 So the help out put is confusing. > > 2) Since this option comes as a default one from the core, you need to > search for it in the hammer-cli repo: > https://github.com/theforeman/hammer-cli/blob/master/lib/hammer_cli/options/ > predefined.rb. Thanks for noticing this! We could translate this BZ for this > issue if the described one is not an actual issue. PR made: https://github.com/theforeman/hammer-cli/pull/331 Fix typo: s/filed/feild/ by swadeley · Pull Request #331 · theforeman/hammer-cli > > 3) Search / Order fields are the fields you can pass to --search/--order > options only. Can I make another OR to check: these two lines under Search / Order fields: errata_id string errata_type string to: errata id string type string oir perhaps you can improve the code to accept both forms? Thank you (In reply to Stephen Wadeley from comment #4) > > > So the help out put is confusing. So, I'd suggest to improve help as part of the https://bugzilla.redhat.com/show_bug.cgi?id=1829701. Feel free to add in the comments what should be improved additionally. > > PR made: https://github.com/theforeman/hammer-cli/pull/331 > Fix typo: s/filed/feild/ by swadeley · Pull Request #331 · > theforeman/hammer-cli This was merged, thanks! > Can I make another OR to check: > > these two lines under Search / Order fields: > > errata_id string > errata_type string > > to: > > errata id string > type string > > oir perhaps you can improve the code to accept both forms? I would have not mixed those two cases. --fields options was designed to use labels as those are shown to users. So a user can arrange what he/she sees without further knowledge. Hidden fields' ids may not be in sync with their labels, e.g. :errata_type vs "Type". And I'd like to leave it this way. Otherwise we would need to refactor a lot of code across all the hammer plugins which is quite unnecessary to accept field ids instead of labels (or to sync them). Search/Order fields are coming from the server models' definitions. If we will accept both forms it may cause errors such as showing incorrect or undesirable field. Closing this one, since the issue here is more about help output and wrong usage. If you think that this is still a relevant bug, please reopen. Otherwise, use https://bugzilla.redhat.com/show_bug.cgi?id=1829701 for additional suggestions regarding help improvement. |