-
Notifications
You must be signed in to change notification settings - Fork 592
[CLI] feat: add image selection and fix tests #5024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| import sys | ||
| from typing import Any | ||
| from typing import Dict | ||
| from typing import Tuple | ||
|
|
||
| from casp.utils import config | ||
| from casp.utils import docker_utils | ||
|
|
@@ -82,19 +83,30 @@ def _setup_custom_config(cfg: Dict[str, Any]): | |
| click.secho(f'Custom config path set to: {custom_config_path}', fg='green') | ||
|
|
||
|
|
||
| def _pull_image(): | ||
| """Pulls the docker image.""" | ||
| click.echo(f'Pulling Docker image: {docker_utils.DOCKER_IMAGE}...') | ||
| if not docker_utils.pull_image(): | ||
| def _pull_image_for_project(project: str = 'internal'): | ||
| """Pulls the docker image for the given project.""" | ||
| if not docker_utils.pull_image(docker_utils.PROJECT_TO_IMAGE[project]): | ||
| click.secho( | ||
| f'\nError: Failed to pull Docker image {docker_utils.DOCKER_IMAGE}.', | ||
| (f'\nError: Failed to pull Docker image: ' | ||
| f'{docker_utils.PROJECT_TO_IMAGE[project]}.'), | ||
| fg='red') | ||
| click.secho('Initialization failed.', fg='red') | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| @click.command(name='init', help='Initializes the CLI') | ||
| def cli(): | ||
| @click.option( | ||
| '--projects', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Maybe the name project is not very clear for external users. I think
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressing in future PR. |
||
| '--project', | ||
| '-p', | ||
| help=('The ClusterFuzz project to use. You can specify multiple projects.' | ||
| 'Ex.: -p dev -p internal'), | ||
| required=False, | ||
| default=('internal',), | ||
| type=click.Choice( | ||
| docker_utils.PROJECT_TO_IMAGE.keys(), case_sensitive=False), | ||
| multiple=True) | ||
| def cli(projects: Tuple[str, ...]): | ||
|
||
| """Initializes the CASP CLI. | ||
|
|
||
| This is done by: | ||
|
|
@@ -117,5 +129,7 @@ def cli(): | |
| config.save_config(cfg) | ||
| click.secho(f'Configuration saved to {config.CONFIG_FILE}.', fg='green') | ||
|
|
||
| _pull_image() | ||
| for project in projects: | ||
| _pull_image_for_project(project) | ||
|
|
||
| click.secho('Initialization complete.', fg='green') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this method should not have a default value for
project. It should always expect it as an arg.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing in future PR.