Skip to content

Commit

Permalink
Feat: add pkg support in orasclient (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aryan-rajoria authored Nov 6, 2024
1 parent f887ab5 commit 87c8e5e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-meson-tst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
source venv/bin/activate
cd blint-db/
python blint_db/cli.py --clean-start -f -Z1
python ./.oras/orasclient.py
python ./.oras/orasclient.py -p meson-tst
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
2 changes: 1 addition & 1 deletion .github/workflows/build-meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
source venv/bin/activate
cd blint-db/
python blint_db/cli.py --clean-start -Z1
python ./.oras/orasclient.py
python ./.oras/orasclient.py -p meson
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
2 changes: 1 addition & 1 deletion .github/workflows/build-vcpkg-tst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
source venv/bin/activate
cd blint-db/
python3 blint-db/blint_db/cli.py --clean-start -f -Z2
python3 ./.oras/orasclient.py
python3 ./.oras/orasclient.py -p vcpkg-tst
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
2 changes: 1 addition & 1 deletion .github/workflows/build-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
source venv/bin/activate
cd blint-db/
python3 blint-db/blint_db/cli.py --clean-start -Z2
python3 ./.oras/orasclient.py
python3 ./.oras/orasclient.py -p vcpkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
60 changes: 51 additions & 9 deletions .oras/orasclient.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@
import oras.client
import os
import argparse

client = oras.client.OrasClient()

token = os.getenv("GITHUB_TOKEN", "")
username = os.getenv("GITHUB_USERNAME", "")


client.login(password=token, username=username)

client.push(
target="ghcr.io/appthreat/blintdb-meson:v0.1",
config_path="./.oras/config.json",
annotation_file="./.oras/annotations.json",
files=[
"./blint.db:application/vnd.appthreat.blintdb.layer.v1+tar",
],
)
parser = argparse.ArgumentParser(
prog="orasclient_blintdb", description="Helps pushing blint.db into a container and uploading to ghcr.io"
)
parser.add_argument(
"-p",
"--pkg-manager",
dest="pkg",
help="Path to the CDXGEN bom file (NOT IMPLEMENTED)",
)
args = vars(parser.parse_args())

if pkg := args.get("pkg", None):
# not using fstring here to make sure value is correct
# otherwise wrong file may be uploaded
if pkg=="vcpkg":
client.push(
target="ghcr.io/appthreat/blintdb-vcpkg:v0.1",
config_path="./.oras/config.json",
annotation_file="./.oras/annotations.json",
files=[
"./blint.db:application/vnd.appthreat.blintdb.layer.v1+tar",
],
)
if pkg=="meson":
client.push(
target="ghcr.io/appthreat/blintdb-meson:v0.1",
config_path="./.oras/config.json",
annotation_file="./.oras/annotations.json",
files=[
"./blint.db:application/vnd.appthreat.blintdb.layer.v1+tar",
],
)
if pkg=="vcpkg-tst":
client.push(
target="ghcr.io/appthreat/blintdb-vcpkg-tst:v0.1",
config_path="./.oras/config.json",
annotation_file="./.oras/annotations.json",
files=[
"./blint.db:application/vnd.appthreat.blintdb.layer.v1+tar",
],
)
if pkg=="meson-tst":
client.push(
target="ghcr.io/appthreat/blintdb-meson-tst:v0.1",
config_path="./.oras/config.json",
annotation_file="./.oras/annotations.json",
files=[
"./blint.db:application/vnd.appthreat.blintdb.layer.v1+tar",
],
)

0 comments on commit 87c8e5e

Please sign in to comment.