Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Handle canonical_builders_from_upstream (on, off, auto) and invalid v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
locriandev committed Oct 6, 2022
1 parent 7b25335 commit fb2a7c2
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions doozerlib/distgit.py
Expand Up @@ -430,15 +430,6 @@ def __init__(self, metadata, autoclone=True,
self.logger: logging.Logger = metadata.logger
self.source_modifier_factory = source_modifier_factory

# Check if we should try to match upstream
if self.runtime.group_config.canonical_builders_from_upstream == 'auto':
# canonical_builders_from_upstream set to 'auto': rebase according to release schedule
feature_freeze_date = ReleaseSchedule(self.runtime).get_ff_date()
self.should_match_upstream = datetime.now() < feature_freeze_date
else:
# canonical_builders_from_upstream set to either 'false' or 'true'
self.should_match_upstream = self.runtime.group_config.canonical_builders_from_upstream

def clone(self, distgits_root_dir, distgit_branch):
super(ImageDistGitRepo, self).clone(distgits_root_dir, distgit_branch)
self._read_master_data()
Expand Down Expand Up @@ -1639,10 +1630,30 @@ def _mapped_image_for_assembly_build(self, parent_images, i):
unique_pullspec += f':{parent_build_nvr["version"]}-{parent_build_nvr["release"]}'
return unique_pullspec

def _should_match_upstream(self) -> bool:
if self.runtime.group_config.canonical_builders_from_upstream is Missing:
# Default case: override using ART's config
return False
elif self.runtime.group_config.canonical_builders_from_upstream == 'auto':
# canonical_builders_from_upstream set to 'auto': rebase according to release schedule
feature_freeze_date = ReleaseSchedule(self.runtime).get_ff_date()
return datetime.now() < feature_freeze_date
elif self.runtime.group_config.canonical_builders_from_upstream == 'on':
return True
elif self.runtime.group_config.canonical_builders_from_upstream == 'off':
return False
else:
# Invalid value
self.logger.warning(
'Invalid value provided for "canonical_builders_from_upstream": %s',
self.runtime.group_config.canonical_builders_from_upstream
)
return False

def _mapped_image_from_stream(self, image, original_parent, dfp):
stream = self.runtime.resolve_stream(image.stream)

if not self.should_match_upstream:
if not self._should_match_upstream():
# Do typical stream resolution.
return stream.image

Expand Down

0 comments on commit fb2a7c2

Please sign in to comment.