Skip to content

Commit

Permalink
Merge 0d6e701 into e343ac8
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-dagan committed Jan 31, 2024
2 parents e343ac8 + 0d6e701 commit 8c24173
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
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_IO", "docker.io")


# 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
5 changes: 3 additions & 2 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,10 +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]
[f"{DOCKER_REGISTRY_URL}/{image[0]}", -1]
for image in self._facts["images"]
]
# Gather environment variables for docker execution
Expand Down

0 comments on commit 8c24173

Please sign in to comment.