#1284 Clean up skipping phases
Merged 4 years ago by lsedlar. Opened 4 years ago by hlin.
hlin/pungi master  into  master

file modified
+2
@@ -226,6 +226,8 @@ 

      if not pungi.checks.check(conf):

          sys.exit(1)

      pungi.checks.check_umask(logger)

+     if not pungi.checks.check_skip_phases(logger, opts.skip_phase):

+         sys.exit(1)

      errors, warnings = pungi.checks.validate(conf)

      if not opts.quiet:

          for warning in warnings:

file modified
+20
@@ -135,6 +135,26 @@ 

                         'expect files with broken permissions.', mask)

  

  

+ def check_skip_phases(logger, skip_phases):

+     """Check if skipped phases are needed by other phase.

+ 

+     :param logger: logger instance for reporting error

+     :param skip_phases: list of skipped phases

+     :returns: True if checking passed else False

+     """

+     needed_by = {

+         'pkgset': 'gather',

+         'gather': 'createrepo',

+     }

+     fail = False

+     for k, v in needed_by.items():

+         if k in skip_phases and needed_by[k] not in skip_phases:

+             fail = True

+             logger.error("%s phase is skipped but it's needed by %s phase" % (k, v))

+ 

+     return not fail

+ 

+ 

  def _validate_requires(schema, conf, valid_options):

      """

      Check if all requires and conflicts are ok in configuration.

It makes no sense to only skip phases needed by other phase.

Fixes: https://pagure.io/pungi/issue/1274
JIRA: COMPOSE-3871
Signed-off-by: Haibo Lin hlin@redhat.com

This is interesting solution. I was thinking it might fit into validate method of the phases.

If the purpose is stop running when needed phase skipped, I prefer to do it earlier other than in the validate method of the phases.

Pull-Request has been merged by lsedlar

4 years ago