Skip to content

[uss_qualifier] Fix private repos locally #1027

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion monitoring/uss_qualifier/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def _get_web_content(url: str) -> str:

# Check if this is a request to a private GitHub repo
github_private_repos_key = "GITHUB_PRIVATE_REPOS"
if github_private_repos_key in os.environ:
if github_private_repos_key in os.environ and os.environ.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.environ.get is going to be None if the variable is not present, so the in part is redudent no?

github_private_repos_key
):
github_match = re.match(
r"^https://(?P<hostname>github\.com|raw\.githubusercontent\.com|api\.github\.com)/(?P<org>[^/]*)/(?P<repo>[^/?#]*)(?P<predicate>.*)$",
url,
Expand Down
10 changes: 9 additions & 1 deletion monitoring/uss_qualifier/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ else
docker_args="-it"
fi

# Initialize an empty string for additional Docker options
PRIVATE_REPOS_ENV_FLAG=""

# Check if GITHUB_PRIVATE_REPOS is set and not empty
if [ -n "${GITHUB_PRIVATE_REPOS}" ]; then
PRIVATE_REPOS_ENV_FLAG="-e GITHUB_PRIVATE_REPOS=${GITHUB_PRIVATE_REPOS}"
fi

# shellcheck disable=SC2086
docker run ${docker_args} --name uss_qualifier \
--rm \
Expand All @@ -69,7 +77,7 @@ docker run ${docker_args} --name uss_qualifier \
-e PYTHONBUFFERED=1 \
-e AUTH_SPEC=${AUTH_SPEC} \
-e AUTH_SPEC_2=${AUTH_SPEC_2} \
-e GITHUB_PRIVATE_REPOS=${GITHUB_PRIVATE_REPOS:-} \
${PRIVATE_REPOS_ENV_FLAG} \
-e MONITORING_GITHUB_ROOT=${MONITORING_GITHUB_ROOT:-} \
-v "$(pwd)/$OUTPUT_DIR:/app/$OUTPUT_DIR" \
-v "$(pwd)/$CACHE_DIR:/app/$CACHE_DIR" \
Expand Down
Loading