def _filter_out_inviable_builds(kind, results, errata): unshipped_builds = [] errata_version_cache = { } # avoid reloading the same errata for multiple builds for b in results: # check if build is attached to any existing advisory for this version in_same_version = False for eid in [e['id'] for e in b.all_errata]: if eid not in errata_version_cache: metadata_comments_json = errata.get_metadata_comments_json(eid) if not metadata_comments_json: # Does not contain ART metadata; consider it unversioned red_print( "Errata {} Does not contain ART metadata\n".format( eid)) errata_version_cache[eid] = '' continue # it's possible for an advisory to have multiple metadata comments, # though not very useful (there's a command for adding them, # but not much point in doing it). just looking at the first one is fine. errata_version_cache[eid] = metadata_comments_json[0][ 'release'] if errata_version_cache[eid] == get_release_version( b.product_version): in_same_version = True break if not in_same_version: unshipped_builds.append(b) return unshipped_builds
def advisory_impetus_cli(runtime, advisory, default_advisory_type): """Get advisory impetus. $ elliott advisory-impetus --advisory 48465 or $ elliott -g openshift-4.2 advisory-impetus --use-default-advisory extras """ if advisory and default_advisory_type: raise click.BadParameter( 'Use only one of --use-default-advisory or --advisory') runtime.initialize(no_group=(advisory is not None)) if advisory is None: advisory = find_default_advisory(runtime, default_advisory_type) comments = errata.get_metadata_comments_json(advisory) if not comments or 'impetus' not in comments[0]: print('Error! impetus not found for advisory {}'.format(advisory), file=sys.stderr) print(comments, file=sys.stderr) exit(1) print(comments[0]['impetus'])