Skip to content

Commit

Permalink
Add ability to skip listing validations (#362)
Browse files Browse the repository at this point in the history
* show db updates

Signed-off-by: Alex Goodman <[email protected]>

* show listing contents

Signed-off-by: Alex Goodman <[email protected]>

* roll back pin of importlib

Signed-off-by: Alex Goodman <[email protected]>

* skip listing valiadtion

Signed-off-by: Alex Goodman <[email protected]>

* use yardstick version from main

Signed-off-by: Alex Goodman <[email protected]>

* restore aws creds check

Signed-off-by: Alex Goodman <[email protected]>

---------

Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman authored Aug 17, 2024
1 parent bbfefd7 commit c8265fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions manager/src/grype_db_manager/cli/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ def upload_listing(cfg: config.Application, listing_file: str, ttl_seconds: int)

@group.command(name="update", help="recreate a listing based off of S3 state, validate it, and upload it")
@click.option("--dry-run", "-d", default=False, help="do not upload the listing file to S3", is_flag=True)
@click.option("--skip-validate", default=False, help="skip validation of the listing file", is_flag=True)
@click.pass_obj
@click.pass_context
@error.handle_exception(handle=(ValueError, s3utils.CredentialsError))
def update_listing(ctx: click.core.Context, cfg: config.Application, dry_run: bool) -> None:
def update_listing(ctx: click.core.Context, cfg: config.Application, dry_run: bool, skip_validate: bool) -> None:
if dry_run:
click.echo(f"{Format.ITALIC}Dry run! Will skip uploading the listing file to S3{Format.RESET}")
elif cfg.assert_aws_credentials:
Expand All @@ -185,8 +186,11 @@ def update_listing(ctx: click.core.Context, cfg: config.Application, dry_run: bo
click.echo(f"{Format.BOLD}Creating listing file from S3 state{Format.RESET}")
listing_file_name = ctx.invoke(create_listing)

click.echo(f"{Format.BOLD}Validating listing file {listing_file_name!r}{Format.RESET}")
ctx.invoke(validate_listing, listing_file=listing_file_name)
if not skip_validate:
click.echo(f"{Format.BOLD}Validating listing file {listing_file_name!r}{Format.RESET}")
ctx.invoke(validate_listing, listing_file=listing_file_name)
else:
click.echo(f"{Format.ITALIC}Skipping the validation of the listing file{Format.RESET}")

if not dry_run:
click.echo(f"{Format.BOLD}Uploading listing file {listing_file_name!r}{Format.RESET}")
Expand Down
2 changes: 1 addition & 1 deletion manager/src/grype_db_manager/db/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def smoke_test(
installation_path = os.path.join(tempdir, "grype-install")

# way too verbose!
# logging.info(listing_contents)
logging.info(listing_contents)
with open(os.path.join(tempdir, LISTING_FILENAME), "w") as f:
f.write(listing_contents)

Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ zstandard = ">=0.21.0, <1"
colorlog = "^6.7.0"
mergedeep = "^1.3.4"
pyyaml = ">=5.0.1, <7"
yardstick = {git = "https://github.com/anchore/yardstick", rev = "8d86e14af1ecb6ffb72ced28a1f7cdea629319cc"}
yardstick = {git = "https://github.com/anchore/yardstick", rev = "8ef84656c6618292110c47fbb8805d78fc7b235d"}
#yardstick = {path = "../yardstick", develop = true}
colr = "^0.9.1"
pyyaml-include = "^1.3.1"
Expand Down

0 comments on commit c8265fb

Please sign in to comment.