Skip to content

Commit

Permalink
squash: switch erratum to one release only
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Feb 15, 2024
1 parent 9d205c3 commit e9802b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions newa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Event(Serializable):
class Erratum(Cloneable, Serializable):
""" An eratum """

releases: list[str] = field(factory=list)
release: str
# builds: list[...] = ...

def fetch_details(self) -> None:
Expand Down Expand Up @@ -126,4 +126,4 @@ class ErratumJob(Job):

@property
def id(self) -> str:
return f'{self.event.id} @ {"+".join(self.erratum.releases)}'
return f'{self.event.id} @ {self.erratum.release}'
36 changes: 10 additions & 26 deletions newa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import click
from attrs import define

from . import Erratum, ErratumJob, Event, EventType
from . import ErratumJob

logging.basicConfig(
format='%(asctime)s %(message)s',
Expand Down Expand Up @@ -43,10 +43,8 @@ def load_erratum_jobs(self, filename_prefix: str) -> Iterator[ErratumJob]:
yield self.load_erratum_job(self.state_dirpath / child)

def save_erratum_job(self, filename_prefix: str, job: ErratumJob) -> None:
assert len(job.erratum.releases) == 1

filepath = self.state_dirpath / \
f'{filename_prefix}{job.event.id}-{job.erratum.releases[0]}.yaml'
f'{filename_prefix}{job.event.id}-{job.erratum.release}.yaml'

job.to_yaml_file(filepath)
self.logger.info(f'Erratum job {job.id} written to {filepath}')
Expand Down Expand Up @@ -75,32 +73,18 @@ def main(click_context: click.Context, state_dir: str) -> None:


@main.command(name='event')
@click.option(
'-e', '--erratum', 'errata_ids',
multiple=True,
required=True,
)
# @click.option(
# '-e', '--erratum', 'errata_ids',
# multiple=True,
# required=True,
# )
@click.pass_obj
def cmd_event(ctx: CLIContext, errata_ids: tuple[str, ...]) -> None:
def cmd_event(ctx: CLIContext) -> None:
ctx.enter_command('event')

erratum_jobs: list[ErratumJob] = []

for erratum_id in errata_ids:
event = Event(type_=EventType.ERRATUM, id=erratum_id)
job = ErratumJob(event=event, erratum=Erratum())

# TODO: job.erratum.fetch_details()
# TODO: populate releases
job.erratum.releases += ['RHEL-8.10.0', 'RHEL-9.4.0']

for release in job.erratum.releases:
job_erratum = job.erratum.clone()
job_erratum.releases = [release]

erratum_jobs.append(ErratumJob(event=event, erratum=job_erratum))
for erratum_job in ctx.load_erratum_jobs('erratum-'):

ctx.save_erratum_jobs('event-', erratum_jobs)
ctx.save_erratum_job('event-', erratum_job)


@main.command(name='jira')
Expand Down

0 comments on commit e9802b4

Please sign in to comment.