Skip to content

Instantly share code, notes, and snippets.

@jspeed-meyers
Last active January 9, 2024 19:12
Show Gist options
  • Save jspeed-meyers/b34a768141c3b4465ac109c5bfead58b to your computer and use it in GitHub Desktop.
Save jspeed-meyers/b34a768141c3b4465ac109c5bfead58b to your computer and use it in GitHub Desktop.
Create JSON listing ironbank images
import json
import pandas as pd
import requests
YOUR_SHEET_ID = "1ifFaQyNfgC-V0AnubYm9P3btkNwN9rXJNAHiauflHV4"
CSV_URL = f"https://docs.google.com/spreadsheet/ccc?key={YOUR_SHEET_ID}&output=csv"
res = requests.get(url=CSV_URL)
with open("image-names.csv", "wb") as data:
data.write(res.content)
df = pd.read_csv("image-names.csv")
# filter to only rows that should be compared
df = df[df["compare"] == "Y"]
image_list = []
for index, row in df.iterrows():
image = {}
image["name"] = row["ironbank"].replace("/", "-")
image["vendors"] = [
{
"name": "chainguard",
"domain": "cgr.dev",
"path": f'chainguard-private/{row["chainguard"]}',
"tag": row["chainguard-tag"],
},
{
"name": "ironbank",
"domain": "registry1.dso.mil/ironbank",
"path": row["ironbank"],
"tag": row["ironbank-tag"],
},
{
"name": "upstream",
"domain": "",
"path": row["upstream"],
"tag": row["upstream-tag"],
},
]
image_list.append(image)
# the expected data structure has a top-level "images" field
# with the list of images as the value
final_data_structure = {}
final_data_structure["images"] = image_list
with open("ironbank-data.json", "w", encoding="utf-8") as f:
json.dump(final_data_structure, f, sort_keys=True, ensure_ascii=False, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment