|
11 | 11 | logger = logging.getLogger(__name__) |
12 | 12 |
|
13 | 13 |
|
14 | | -@click.command() |
15 | | -@click.option("-k", "--kubeconfig", "kubeconfig", required=False, type=click.Path(exists=True), help="path/to/kubeconfig_file.yaml",) |
| 14 | +@click.group() |
| 15 | +def cli(): |
| 16 | + pass |
| 17 | + |
| 18 | + |
| 19 | +@cli.command("run") |
| 20 | +@click.option("-k", "--kubeconfig", "kubeconfig", required=True, type=click.Path(exists=True), help="path/to/kubeconfig_file.yaml",) |
16 | 21 | @click.option("-r", "--result_dir_name", "result_dir_name", type=str, default="sonobuoy_results", help="directory name to store results at",) |
17 | 22 | @click.option("-c", "--check", "check_name", type=str, default="sonobuoy_executor", help="this MUST be the same name as the id in 'scs-compatible-kaas.yaml'",) |
18 | | -@click.option("--sonobuoy-config", "sonobuoy_config", type=click.Path(exists=True), default="kaas/sonobuoy-config.yaml", help="Configuration for Sonobuoy (yaml format)") |
19 | | -@click.option("--sonobuoy-result-yaml", "sonobuoy_result_yaml", type=click.Path(exists=True), default="", help="Test the provided sonobuoy result yaml file. Sonobuoy will not be executed!") |
| 23 | +@click.option("--sonobuoy-config", "sonobuoy_config_yaml", type=click.Path(exists=True), default="kaas/sonobuoy-config.yaml", help="Configuration for Sonobuoy (yaml format)") |
20 | 24 | @click.option("-a", "--arg", "args", multiple=True) |
21 | | -def sonobuoy_run(kubeconfig, result_dir_name, check_name, sonobuoy_config, sonobuoy_result_yaml, args): |
22 | | - if sonobuoy_result_yaml: |
23 | | - check_sonobuoy_result(sonobuoy_config, sonobuoy_result_yaml) |
24 | | - sys.exit(0) |
25 | | - if not kubeconfig: |
26 | | - raise click.UsageError("--kubeconfig/-k is required unless --sonobuoy-result-yaml is provided") |
27 | | - sonobuoy_handler = SonobuoyHandler(check_name, kubeconfig, result_dir_name, sonobuoy_config, args) |
| 25 | +def sonobuoy_run(kubeconfig, result_dir_name, check_name, sonobuoy_config_yaml, args): |
| 26 | + sonobuoy_handler = SonobuoyHandler(check_name, kubeconfig, result_dir_name, sonobuoy_config_yaml, args) |
28 | 27 | sys.exit(sonobuoy_handler.run()) |
29 | 28 |
|
30 | 29 |
|
| 30 | +@cli.command("check-results") |
| 31 | +@click.argument("sonobuoy_config_yaml", type=click.Path(exists=True)) |
| 32 | +@click.argument("sonobuoy_result_yaml", type=click.Path(exists=True)) |
| 33 | +def check_results(sonobuoy_config_yaml, sonobuoy_result_yaml): |
| 34 | + check_sonobuoy_result(sonobuoy_config_yaml, sonobuoy_result_yaml) |
| 35 | + sys.exit(0) |
| 36 | + |
| 37 | + |
31 | 38 | if __name__ == "__main__": |
32 | 39 | logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG) |
33 | | - sonobuoy_run() |
| 40 | + cli() |
0 commit comments