-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
967 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.md | ||
!README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# monopacker SBOMs | ||
|
||
## overview | ||
|
||
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# a barebones image used for testing monopacker | ||
template: googlecompute | ||
platform: linux | ||
|
||
builder_var_files: | ||
- default_linux | ||
- default_gcp | ||
- googlecompute_jammy | ||
- ubuntu_amd64 | ||
- monopacker_generate_sbom | ||
|
||
script_directories: | ||
- ubuntu-tc-barebones |
54 changes: 54 additions & 0 deletions
54
monopacker/post-processors/move_sbom_to_latest_artifact_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import sys | ||
import argparse | ||
import os | ||
import shutil | ||
|
||
# Set up argparse | ||
parser = argparse.ArgumentParser(description="Move temp_sbom.md to the last build's artifact name.md") | ||
parser.add_argument('-d', '--debug', action='store_true', help='Print what would have happened instead of performing the move') | ||
args = parser.parse_args() | ||
|
||
# Load the JSON data from the file in the current working directory | ||
file_path = 'packer-artifacts.json' | ||
with open(file_path, 'r') as file: | ||
data = json.load(file) | ||
|
||
# Extract the last_run_uuid | ||
last_run_uuid = data['last_run_uuid'] | ||
|
||
# Find the matching build in the builds array | ||
matching_build = None | ||
for build in data['builds']: | ||
if build['packer_run_uuid'] == last_run_uuid: | ||
matching_build = build | ||
break | ||
|
||
# Handle the move operation or describe the action if in debug mode | ||
if matching_build: | ||
artifact_id = matching_build['artifact_id'] | ||
source_path = 'SBOMs/temp_sbom.md' | ||
destination_dir = 'SBOMs' | ||
destination_path = f'{destination_dir}/{artifact_id}.md' | ||
|
||
if not os.path.exists(source_path): | ||
print(f'File {source_path} not found.') | ||
sys.exit(0) | ||
|
||
if args.debug: | ||
print(f'Would move {source_path} to {destination_path}') | ||
else: | ||
try: | ||
# Create the destination directory if it doesn't exist | ||
os.makedirs(destination_dir, exist_ok=True) | ||
# Move the file | ||
shutil.move(source_path, destination_path) | ||
print(f'Moved {source_path} to {destination_path}') | ||
except Exception as e: | ||
print(f'An error occurred: {e}') | ||
sys.exit(1) | ||
else: | ||
print('No matching build found.') | ||
sys.exit(1) |
Oops, something went wrong.