Skip to content
Merged
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
10 changes: 9 additions & 1 deletion doozer/doozerlib/cli/images_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,8 +1031,16 @@ def check_if_upstream_image_exists(upstream_image):
exectools.cmd_assert(f'git remote add fork {convert_remote_git_to_ssh(fork_repo.git_url)}')
exectools.cmd_assert('git fetch --all', retries=3)

# The path to the Dockerfile in the target branch
if image_meta.config.content.source.dockerfile is not Missing:
# Be aware that this attribute sometimes contains path elements too.
dockerfile_name = image_meta.config.content.source.dockerfile
else:
dockerfile_name = "Dockerfile"

df_path = Dir.getpath()
dockerfile_name = image_meta.resolve_dockerfile_name()
if image_meta.config.content.source.path:
dockerfile_name = os.path.join(image_meta.config.content.source.path, dockerfile_name)

df_path = df_path.joinpath(dockerfile_name).resolve()
ci_operator_config_path = Dir.getpath().joinpath('.ci-operator.yaml').resolve() # https://docs.ci.openshift.org/docs/architecture/ci-operator/#build-root-image
Expand Down
12 changes: 10 additions & 2 deletions doozer/doozerlib/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,9 @@ def _determine_upstream_rhel_version(self, source_path) -> Optional[int]:

Return either an integer representing the RHEL major version, or None if something went wrong.
"""
df_name = self.metadata.resolve_dockerfile_name()
df_name = self.config.content.source.dockerfile
if not df_name:
df_name = 'Dockerfile'
subdir = self.config.content.source.path
if not subdir:
subdir = '.'
Expand Down Expand Up @@ -2502,7 +2504,13 @@ def _merge_source(self):

self.env_vars_from_source.update(self.metadata.extract_kube_env_vars())

dockerfile_name = self.metadata.resolve_dockerfile_name()
# See if the config is telling us a file other than "Dockerfile" defines the
# distgit image content.
if self.config.content.source.dockerfile is not Missing:
# Be aware that this attribute sometimes contains path elements too.
dockerfile_name = self.config.content.source.dockerfile
else:
dockerfile_name = "Dockerfile"

# The path to the source Dockerfile we are reconciling against.
source_dockerfile_path = os.path.join(self.source_path(), dockerfile_name)
Expand Down
41 changes: 0 additions & 41 deletions doozer/doozerlib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,6 @@ def hotfix_brew_tags(self):
"""
return [self.hotfix_brew_tag()]

def source_path(self):
"""
:return: Returns the directory containing the source which should be used to populate distgit. This includes
the source.path subdirectory if the metadata includes one.
"""

source_root = self.runtime.resolve_source(self)
sub_path = self.config.content.source.path

path = source_root
if sub_path is not Missing:
path = os.path.join(source_root, sub_path)

assertion.isdir(path, "Unable to find path for source [%s] for config: %s" % (path, self.config_filename))
return path

def get_arches(self):
"""
:return: Returns the list of architecture this image/rpm should build for. This is an intersection
Expand Down Expand Up @@ -690,31 +674,6 @@ def get_component_name(self) -> str:
"""
return self._component_name

def resolve_dockerfile_name(self) -> str:
"""
:return: Upstream Dockerfile name
Resolve the Dockerfile name of upstream. If file specified in content.source.dockerfile doesn't exist,
try looking at the one specified in content.source.dockerfile_fallback as well.
"""
if self.config.content.source.dockerfile is not Missing:
# Be aware that this attribute sometimes contains path elements too.
dockerfile_name = self.config.content.source.dockerfile

source_dockerfile_path = os.path.join(self.source_path(), dockerfile_name)

if not os.path.isfile(source_dockerfile_path):
dockerfile_name_fallback = self.config.content.source.dockerfile_fallback
if dockerfile_name_fallback is not Missing:
self.logger.info(
f"Could not find source dockerfile at {dockerfile_name}, using fallback {dockerfile_name_fallback}")
return dockerfile_name_fallback
raise IOError(
f"Fallback dockerfile {dockerfile_name_fallback} is Missing and source dockerfile {source_dockerfile_path} doesn't exist")
else:
return dockerfile_name
else:
return "Dockerfile"

def needs_rebuild(self):
if self.config.targets:
# If this meta has multiple build targets, check currency of each
Expand Down