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

Commit

Permalink
Refactor assembly_type to be of type AssemblyType
Browse files Browse the repository at this point in the history
  • Loading branch information
joepvd committed Jul 14, 2022
1 parent a6c63ce commit 980ed59
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions doozerlib/cli/release_gen_assembly.py
Expand Up @@ -8,6 +8,7 @@
import yaml

from doozerlib import util
from doozerlib.assembly import AssemblyTypes
from doozerlib.cli import cli, pass_runtime
from doozerlib import exectools
from doozerlib.model import Model
Expand Down Expand Up @@ -70,27 +71,27 @@ def exit_with_error(msg):
if auto_previous and previous_list:
exit_with_error('Cannot use `--previous` and `--auto-previous` at the same time.')

assembly_type = 'standard'
assembly_type: AssemblyTypes = AssemblyTypes.STANDARD
if custom:
assembly_type = 'custom'
assembly_type = AssemblyTypes.CUSTOM
elif re.search(r'^[fr]c\.[0-9]+$', gen_assembly_name):
assembly_type = 'candidate'
assembly_type = AssemblyTypes.CANDIDATE
elif re.search(r'^ec\.[0-9]+$', gen_assembly_name):
assembly_type = 'preview'
assembly_type = AssemblyTypes.PREVIEW

if custom or assembly_type == 'preview':
if assembly_type in [AssemblyTypes.CUSTOM, AssemblyTypes.PREVIEW]:
if auto_previous or previous_list or in_flight:
exit_with_error("Custom release doesn't have previous list.")
exit_with_error("Custom and preview release doesn't have previous list.")

# Calculate previous list
final_previous_list: Set[VersionInfo] = set()
if in_flight:
final_previous_list.add(VersionInfo.parse(in_flight))
if previous_list:
final_previous_list |= set(map(VersionInfo.parse, previous_list))
elif auto_previous and assembly_type != 'custom':
elif auto_previous:
# gen_assembly_name should be in the form of `fc.0`, `rc.1`, or `4.10.1`
if assembly_type == 'candidate':
if assembly_type == AssemblyTypes.CUSTOM:
major_minor = runtime.get_minor_version() # x.y
version = f"{major_minor}.0-{gen_assembly_name}"
else:
Expand Down Expand Up @@ -356,7 +357,7 @@ def exit_with_error(msg):
group_info = {
'arches!': list(mosc_by_arch.keys())
}
if not (custom or assembly_type == 'preview'):
if assembly_type not in [AssemblyTypes.CUSTOM, AssemblyTypes.PREVIEW]:
# Add placeholder advisory numbers and JIRA key.
# Those values will be replaced with real values by pyartcd when preparing a release.
group_info['advisories'] = {
Expand All @@ -374,7 +375,7 @@ def exit_with_error(msg):
'releases': {
gen_assembly_name: {
"assembly": {
'type': assembly_type,
'type': assembly_type.value,
'basis': {
'brew_event': basis_event,
'reference_releases': reference_releases_by_arch,
Expand Down

0 comments on commit 980ed59

Please sign in to comment.