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

Commit

Permalink
feat: add auth to write metadata request
Browse files Browse the repository at this point in the history
  • Loading branch information
1hachem committed Mar 5, 2024
1 parent 07e0be7 commit 1e2cbb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# basic auth for writing to toolkit db
USERNAME=
PASSWORD=
8 changes: 8 additions & 0 deletions scripts/toolkit-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
from dataclasses import dataclass

import httpx
from dotenv import load_dotenv
from pydantic import ValidationError

from hyko_sdk.metadata import Category, MetaData, MetaDataBase

# Load environment variables from .env file
load_dotenv()

SKIP_FOLDERS = ["__pycache__", "venv"]
USERNAME, PASSWORD = os.getenv("USERNAME"), os.getenv("PASSWORD")
print(USERNAME, PASSWORD)
assert USERNAME and PASSWORD, "no username and password found in .env"


@dataclass
Expand Down Expand Up @@ -113,6 +120,7 @@ def process_function_dir(path: str, dockerfile_path: str, host: str):
response = httpx.post(
f"https://api.{host}/toolkit/write",
content=metadata.model_dump_json(),
auth=httpx.BasicAuth(username=USERNAME, password=PASSWORD),
verify=False if host == "traefik.me" else True,
)

Expand Down

0 comments on commit 1e2cbb5

Please sign in to comment.