Skip to content
Open
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
6 changes: 6 additions & 0 deletions demisto_sdk/commands/common/git_content_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# dirs
import requests
from dotenv import load_dotenv

from demisto_sdk.commands.common.constants import (
DEMISTO_SDK_CI_SERVER_HOST,
Expand All @@ -33,6 +34,8 @@ class GitCredentials:
ENV_GITLAB_TOKEN_NAME = "DEMISTO_SDK_GITLAB_TOKEN"

def __init__(self):
# This is required, because this is called before any command is run, and before any other dotenv load.
load_dotenv(".env", override=True)
self.github_token = os.getenv(self.ENV_GITHUB_TOKEN_NAME, "")
self.gitlab_token = os.getenv(self.ENV_GITLAB_TOKEN_NAME, "")

Expand Down Expand Up @@ -291,6 +294,9 @@ def _search_github_repo(
)
if r.ok:
return github_hostname, repo_name
if r.status_code == 403 and GitContentConfig.CREDENTIALS.github_token:
logger.error(f"Access forbidden to the repository {repo_name} on {api_host}. Error message: {r.text}")
exit(1)
r = requests.get(
f"https://api.{api_host}/repos/{repo_name}",
verify=False,
Expand Down