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

Add --json output to advisory info #1970

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stewartsmith
Copy link
Contributor

@stewartsmith stewartsmith commented Dec 20, 2024

Enable --json for 'dnf advisory info'. The same information as would be displayed as text is included in the JSON output. While the libscols code could be adapted to produce JSON as well, without serious reworking of key_value_table (and all callers), the produced JSON is quite weird, so we instead choose to implement the JSON output separately.

Example output from dnf5 advisory info --json FEDORA-2024-1ec4cd5fd3:

{
  "FEDORA-2024-1ec4cd5fd3":{
    "Name":"FEDORA-2024-1ec4cd5fd3",
    "Title":"libtirpc-1.3.6-1.fc41",
    "Severity":"None",
    "Type":"unspecified",
    "Status":"stable",
    "Vendor":"[email protected]",
    "Issued":"2024-11-16 02:13:46",
    "Description":"    - Fix regression in NVR\n    - Removed libtirpc-1-3-7-rc1 patch (bz 2325556)\n",
    "Message":"",
    "Rights":"Copyright (C) 2024 Red Hat, Inc. and others.",
    "references":[
      {
        "Title":"[nfs-utils] nfs-server restart times out",
        "Id":"2325556",
        "Type":"bugzilla",
        "Url":"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=2325556"
      }
    ],
    "collections":{
      "packages":[
        "libtirpc-1.3.6-1.fc41.src",
        "libtirpc-debuginfo-1.3.6-1.fc41.i686",
        "libtirpc-1.3.6-1.fc41.i686",
        "libtirpc-debugsource-1.3.6-1.fc41.i686",
        "libtirpc-devel-1.3.6-1.fc41.i686",
        "libtirpc-debuginfo-1.3.6-1.fc41.x86_64",
        "libtirpc-1.3.6-1.fc41.x86_64",
        "libtirpc-devel-1.3.6-1.fc41.x86_64",
        "libtirpc-debugsource-1.3.6-1.fc41.x86_64",
        "libtirpc-debuginfo-1.3.6-1.fc41.aarch64",
        "libtirpc-debugsource-1.3.6-1.fc41.aarch64",
        "libtirpc-devel-1.3.6-1.fc41.aarch64",
        "libtirpc-1.3.6-1.fc41.aarch64",
        "libtirpc-1.3.6-1.fc41.ppc64le",
        "libtirpc-debuginfo-1.3.6-1.fc41.ppc64le",
        "libtirpc-debugsource-1.3.6-1.fc41.ppc64le",
        "libtirpc-devel-1.3.6-1.fc41.ppc64le",
        "libtirpc-devel-1.3.6-1.fc41.s390x",
        "libtirpc-debuginfo-1.3.6-1.fc41.s390x",
        "libtirpc-debugsource-1.3.6-1.fc41.s390x",
        "libtirpc-1.3.6-1.fc41.s390x"
      ]
    }
  }
}

Enable --json for 'dnf advisory info'. The same information as would be
displayed as text is included in the JSON output. While the libscols
code could be adapted to produce JSON as well, without serious reworking
of key_value_table (and all callers), the produced JSON is quite weird,
so we instead choose to implement the JSON output separately.
@kontura kontura self-assigned this Jan 2, 2025
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only a couple really minor simplification notes.

Otherwise this looks good.
Thank you!

Comment on lines +135 to +136
json_object_array_add(json_modules, json_object_new_string((*module_iter)->get_nsvca().c_str()));
module_iter++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit confusing, I think we don't have to do the first iteration outside of the loop here.
Unlike the regular version the first json line is formatted the same way as the rest.

Comment on lines +149 to +150
json_object_array_add(json_pkgs, json_object_new_string((*package_iter)->get_nevra().c_str()));
package_iter++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

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

Successfully merging this pull request may close these issues.

2 participants