Skip to content

Commit

Permalink
fix AlmaLinux#26 and mini refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kawaharasouta committed May 24, 2024
1 parent 6fee5b2 commit 8fd8a27
Showing 1 changed file with 51 additions and 37 deletions.
88 changes: 51 additions & 37 deletions alma_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,47 @@ def add_package_source_info(immudb_metadata: Dict, component: Dict):
)


def add_build_info(
immudb_metadata: Dict,
component: Dict,
albs_url: str,
):
component['properties'].extend(
[
{
'name': 'almalinux:package:buildhost',
'value': immudb_metadata['build_host']
if 'build_host' in immudb_metadata
else None,
},
{
'name': 'almalinux:albs:build:targetArch',
'value': immudb_metadata['build_arch']
if 'build_arch' in immudb_metadata
else None,
},
{
'name': 'almalinux:albs:build:ID',
'value': immudb_metadata['build_id']
if 'build_id' in immudb_metadata
else None,
},
{
'name': 'almalinux:albs:build:URL',
'value': f'{albs_url}/build/{immudb_metadata["build_id"]}'
if 'build_id' in immudb_metadata
else None,
},
{
'name': 'almalinux:albs:build:author',
'value': immudb_metadata['built_by']
if 'built_by' in immudb_metadata
else None,
},
]
)


def get_info_about_package(
immudb_hash: str,
albs_url: str,
Expand Down Expand Up @@ -295,18 +336,10 @@ def get_info_about_package(
'name': 'almalinux:package:sourcerpm',
'value': source_rpm,
},
{
'name': 'almalinux:package:buildhost',
'value': immudb_metadata['build_host'],
},
{
'name': 'almalinux:package:timestamp',
'value': immudb_info_about_package['timestamp'],
},
{
'name': 'almalinux:albs:build:targetArch',
'value': immudb_metadata['build_arch'],
},
{
'name': 'almalinux:albs:build:packageType',
'value': 'rpm',
Expand All @@ -315,21 +348,13 @@ def get_info_about_package(
'name': 'almalinux:sbom:immudbHash',
'value': immudb_hash,
},
{
'name': 'almalinux:albs:build:ID',
'value': immudb_metadata['build_id'],
},
{
'name': 'almalinux:albs:build:URL',
'value': f'{albs_url}/build/{immudb_metadata["build_id"]}',
},
{
'name': 'almalinux:albs:build:author',
'value': immudb_metadata['built_by'],
},
],
}

add_build_info(
immudb_metadata=immudb_metadata,
component=result['component'],
albs_url=albs_url,
)
add_package_source_info(
immudb_metadata=immudb_metadata,
component=result['component'],
Expand Down Expand Up @@ -420,14 +445,6 @@ def get_info_about_build(
'name': 'almalinux:package:sourcerpm',
'value': source_rpm,
},
{
'name': 'almalinux:package:buildhost',
'value': immudb_metadata['build_host'],
},
{
'name': 'almalinux:albs:build:targetArch',
'value': immudb_metadata['build_arch'],
},
{
'name': 'almalinux:albs:build:packageType',
'value': 'rpm',
Expand All @@ -436,20 +453,17 @@ def get_info_about_build(
'name': 'almalinux:sbom:immudbHash',
'value': result_of_execution['Hash'],
},
{
'name': 'almalinux:albs:build:ID',
'value': build_id,
},
{
'name': 'almalinux:albs:build:URL',
'value': build_url,
},
{
'name': 'almalinux:albs:build:author',
'value': immudb_metadata['built_by'],
},
],
}
add_build_info(
immudb_metadata=immudb_metadata,
component=component,
albs_url=albs_url,
)
add_package_source_info(
immudb_metadata=immudb_metadata,
component=component,
Expand Down

0 comments on commit 8fd8a27

Please sign in to comment.