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

Adapt Docker Proxy #3975

Merged
merged 20 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/3975.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Added support for DOCKER_REGISTRY_URL environment variable.
type: internal
pr_number: 3975
1 change: 1 addition & 0 deletions demisto_sdk/commands/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"CI_PROJECT_ID", "1061"
) # Default value is the ID of the content repo on GitLab
ENV_SDK_WORKING_OFFLINE = "DEMISTO_SDK_OFFLINE_ENV"
DOCKER_REGISTRY_URL = os.getenv("DOCKER_REGISTRY_URL", "docker-io.art.code.pan.run")
michal-dagan marked this conversation as resolved.
Show resolved Hide resolved


# Authentication
Expand Down
13 changes: 6 additions & 7 deletions demisto_sdk/commands/common/docker_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from demisto_sdk.commands.common.constants import (
DEFAULT_PYTHON2_VERSION,
DEFAULT_PYTHON_VERSION,
DOCKER_REGISTRY_URL,
DOCKERFILES_INFO_REPO,
TYPE_PWSH,
TYPE_PYTHON,
Expand Down Expand Up @@ -253,9 +254,7 @@ def push_image(self, image: str, log_prompt: str = ""):
for _ in range(2):
try:

test_image_name_to_push = image.replace(
"docker-io.art.code.pan.run/", ""
)
test_image_name_to_push = image.replace(f"{DOCKER_REGISTRY_URL}/", "")
docker_push_output = init_global_docker_client().images.push(
test_image_name_to_push
)
Expand Down Expand Up @@ -319,7 +318,7 @@ def create_image(
)
if os.getenv("CONTENT_GITLAB_CI"):
container.commit(
repository=repository.replace("docker-io.art.code.pan.run/", ""),
repository=repository.replace(f"{DOCKER_REGISTRY_URL}/", ""),
tag=tag,
changes=self.changes[container_type],
)
Expand All @@ -329,8 +328,8 @@ def create_image(

@staticmethod
def get_image_registry(image: str) -> str:
if os.getenv("CONTENT_GITLAB_CI") and "code.pan.run" not in image:
return f"docker-io.art.code.pan.run/{image}"
if os.getenv("CONTENT_GITLAB_CI") and DOCKER_REGISTRY_URL not in image:
return f"{DOCKER_REGISTRY_URL}/{image}"
return image

def get_or_create_test_image(
Expand Down Expand Up @@ -638,7 +637,7 @@ def _get_python_version_from_dockerhub_api(image: str) -> Version:
repo, tag = image.split(":")
if os.getenv("CONTENT_GITLAB_CI"):
# we need to remove the gitlab prefix, as we query the API
repo = repo.replace("docker-io.art.code.pan.run/", "")
repo = repo.replace(f"{DOCKER_REGISTRY_URL}/", "")
try:
token = _get_docker_hub_token(repo)
digest = _get_image_digest(repo, tag, token)
Expand Down
6 changes: 3 additions & 3 deletions demisto_sdk/commands/lint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from demisto_sdk.commands.common.constants import (
API_MODULE_FILE_SUFFIX,
DOCKER_REGISTRY_URL,
FORMATTING_SCRIPT,
INTEGRATIONS_DIR,
NATIVE_IMAGE_FILE_NAME,
Expand Down Expand Up @@ -365,11 +366,10 @@ def _gather_facts(self, modules: dict) -> bool:
return True
self._facts["images"] = [[image, -1] for image in images]

# we want to use the docker-io.art.code.pan.run only if we run in content build (and not CI/CD for example)
# we want to use DOCKER_REGISTRY_URL only if we run in content build (and not CI/CD for example)
if os.getenv("CONTENT_GITLAB_CI", False):
self._facts["images"] = [
[f"docker-io.art.code.pan.run/{image[0]}", -1]
for image in self._facts["images"]
[f"{DOCKER_REGISTRY_URL}/{image[0]}", -1] for image in self._facts["images"]
]
# Gather environment variables for docker execution
self._facts["env_vars"] = {
Expand Down