Skip to content
Merged
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
27 changes: 19 additions & 8 deletions doozer/doozerlib/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import io
import os
import pathlib
import re
import fnmatch
Expand Down Expand Up @@ -676,17 +677,27 @@ def get_component_name(self) -> str:
def resolve_dockerfile_name(self) -> str:
"""
:return: Upstream Dockerfile name
If content.source.dockerfile is not specified, use content.source.dockerfile_fallback
If content.source.dockerfile_fallback is not specified, use "Dockerfile"
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.
"""
dockerfile_name = "Dockerfile"
if self.config.content.source.dockerfile is not Missing:
# Be aware that this attribute sometimes contains path elements
# Be aware that this attribute sometimes contains path elements too.
dockerfile_name = self.config.content.source.dockerfile
elif self.config.content.source.dockerfile_fallback is not Missing:
dockerfile_name = self.config.content.source.dockerfile_fallback
self.logger.info(f"source.dockerfile not found, using source.dockerfile_fallback {dockerfile_name}")
return dockerfile_name

source_dockerfile_path = os.path.join(self.config.content.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:
Expand Down