Add --dry-run option #686

Merged
telackey merged 1 commits from telackey/dryrun into main 2023-12-14 04:56:40 +00:00
2 changed files with 325 additions and 320 deletions

View File

@ -164,10 +164,11 @@ def dump_known_requests(filename, requests):
@click.option("--dns-suffix", help="DNS domain to use eg, laconic.servesthe.world")
@click.option("--record-namespace-dns", help="eg, crn://laconic/dns")
@click.option("--record-namespace-deployments", help="eg, crn://laconic/deployments")
@click.option("--dry-run", help="Don't do anything, just report what would be done.", is_flag=True)
@click.pass_context
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir,
request_id, discover, state_file, only_update_state,
dns_suffix, record_namespace_dns, record_namespace_deployments):
dns_suffix, record_namespace_dns, record_namespace_deployments, dry_run):
if request_id and discover:
print("Cannot specify both --request-id and --discover", file=sys.stderr)
sys.exit(2)
@ -196,6 +197,7 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
requests = laconic.app_deployment_requests()
if only_update_state:
if not dry_run:
dump_known_requests(state_file, requests)
return
@ -250,6 +252,7 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
print("Found %d unsatisfied request(s) to process." % len(requests_to_execute))
if not dry_run:
for r in requests_to_execute:
try:
process_app_deployment_request(

View File

@ -186,8 +186,10 @@ def build_container_image(app_record, tag, extra_build_args=[]):
print(f"Cloning repository {repo} to {clone_dir} ...")
if ref:
result = subprocess.run(["git", "clone", "--depth", "1", "--branch", ref, repo, clone_dir])
# TODO: Determing branch or hash, and use depth 1 if we can.
result = subprocess.run(["git", "clone", repo, clone_dir])
result.check_returncode()
subprocess.check_call(["git", "checkout", ref], cwd=clone_dir)
else:
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir])
result.check_returncode()