Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support private repos by adding auth_token key to yaml #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mussels/mussels.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def load_directory(self, cookbook: str, load_path: str) -> tuple:
continue
else:
recipe_class.url = yaml_file["url"]

if "auth_token" in yaml_file:
recipe_class.auth_token = yaml_file["auth_token"]
self.logger.debug("found auth. token " + yaml_file["auth_token"] )


if "archive_name_change" in yaml_file:
recipe_class.archive_name_change = (
Expand Down
8 changes: 7 additions & 1 deletion mussels/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import requests
import urllib.request
import patch
from requests.api import head

from mussels.utils.versions import pick_platform, nvc_str

Expand All @@ -64,6 +65,8 @@ class BaseRecipe(object):
# This hack is necessary because archives with changed names will extract to their original directory name.
archive_name_change: tuple = ("", "")

auth_token = ""

platforms: dict = {} # Dictionary of recipe instructions for each platform.

builds: dict = {} # Dictionary of build paths.
Expand Down Expand Up @@ -192,7 +195,10 @@ def _download_archive(self) -> bool:
return False
else:
try:
r = requests.get(self.url)
self.logger.debug("downloading using auth_token " + self.auth_token)
headers_dict={'Authorization': 'token '+self.auth_token}
r = requests.get(self.url , headers=headers_dict)
self.logger.debug(r.status_code)
with open(self.download_path, "wb") as f:
f.write(r.content)
except Exception:
Expand Down