-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a skeleton for the verifier module to allow multiple people to work on it later. Signed-off-by: Yftach Herzog <[email protected]>
- Loading branch information
1 parent
5e9a7c7
commit aab0633
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from typing import Callable | ||
|
||
import click | ||
|
||
|
||
def get_rpmdb(container_image: str) -> Path: | ||
raise NotImplementedError() | ||
|
||
|
||
def get_rpms(rpmdb: Path) -> list[str]: | ||
raise NotImplementedError() | ||
|
||
|
||
def get_unsigned_rpms(rpms: list[str], verifier: Callable[[str], bool]) -> list[str]: | ||
return [rpm for rpm in rpms if verifier(rpm)] | ||
|
||
|
||
def is_rpm_unsigned(rpm: str) -> bool: | ||
raise NotImplementedError() | ||
|
||
|
||
def generate_output(unsigned_rpms: dict[str, list[str]]) -> bool: | ||
raise NotImplementedError() | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
"--container-image", | ||
help="Reference to container image", | ||
type=str, | ||
multiple=True, | ||
) | ||
def main(container_image: list[str]): | ||
rpms_dbs: dict[str, Path] = {img: get_rpmdb(img) for img in container_image} | ||
rpms_list: dict[str, list[str]] = { | ||
img: get_rpms(rpmdb) for (img, rpmdb) in rpms_dbs.items() | ||
} | ||
unsigned_rpms: dict[str, list[str]] = { | ||
img: get_unsigned_rpms(rpms, is_rpm_unsigned) | ||
for (img, rpms) in rpms_list.items() | ||
} | ||
generate_output(unsigned_rpms) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() # pylint: disable=no-value-for-parameter |