Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #126 from RedHatProductSecurity/fix-versions
Browse files Browse the repository at this point in the history
GRIF-83 enhance product-components
  • Loading branch information
JimFuller-RedHat authored Mar 31, 2023
2 parents d0efcb6 + 3d4e5b5 commit 809b242
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
4 changes: 3 additions & 1 deletion griffon/commands/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ def list_components(
session = CorgiService.create_session()

conditions = default_conditions
conditions["include_fields"] = "link,purl,nvr,version,type,name,upstreams,related_url"
conditions[
"include_fields"
] = "link,purl,nvr,version,type,name,upstreams,related_url,download_url"

# TODO- condition union could be a separate helper function

Expand Down
40 changes: 31 additions & 9 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def component_type_style(type):
def output_version(ctx, version):
if version:
if version.startswith("sha256") and ctx.obj["SHORT_VERSION_VALUES"]:
return f"sha256-..{version[-8:]}"
return f"sha256...{version[-8:]}"
return version


Expand Down Expand Up @@ -544,15 +544,37 @@ def text_output_list(ctx, output, format):
else:
component_ns = Text(purl.namespace.upper(), style="bold red")

version = output_version(ctx, purl.version)
if "version" in row:
version = row["version"]
if purl.version:
if purl.version.startswith("sha256"):
version = f"{row['version']} {output_version(ctx,purl.version)}"

if "release" in row:
version = f"{version}-{row['release']}"
if not ctx.obj["SHOW_PURL"]:
console.print(
component_ns,
purl.type.upper(),
Text(purl.name, style="bold white"),
output_version(ctx, purl.version),
row["related_url"],
purl.qualifiers.get("arch"),
)
if ctx.obj["VERBOSE"] == 0:
console.print(
component_ns,
purl.type.upper(),
Text(purl.name, style="bold white"),
version,
row["related_url"],
purl.qualifiers.get("arch"),
)
if ctx.obj["VERBOSE"] == 1:
component_name = purl.name
if "nvr" in row:
component_name = row["nvr"]
console.print(
component_ns,
purl.type.upper(),
Text(component_name, style="bold white"),
row["related_url"],
row["download_url"],
purl.qualifiers.get("arch"),
)
else:
console.print(
row["purl"],
Expand Down

0 comments on commit 809b242

Please sign in to comment.