Add --dry-run option #686
@ -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("--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-dns", help="eg, crn://laconic/dns")
|
||||||
@click.option("--record-namespace-deployments", help="eg, crn://laconic/deployments")
|
@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
|
@click.pass_context
|
||||||
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir,
|
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir,
|
||||||
request_id, discover, state_file, only_update_state,
|
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:
|
if request_id and discover:
|
||||||
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -196,7 +197,8 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
requests = laconic.app_deployment_requests()
|
requests = laconic.app_deployment_requests()
|
||||||
|
|
||||||
if only_update_state:
|
if only_update_state:
|
||||||
dump_known_requests(state_file, requests)
|
if not dry_run:
|
||||||
|
dump_known_requests(state_file, requests)
|
||||||
return
|
return
|
||||||
|
|
||||||
previous_requests = load_known_requests(state_file)
|
previous_requests = load_known_requests(state_file)
|
||||||
@ -250,18 +252,19 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
|
|
||||||
print("Found %d unsatisfied request(s) to process." % len(requests_to_execute))
|
print("Found %d unsatisfied request(s) to process." % len(requests_to_execute))
|
||||||
|
|
||||||
for r in requests_to_execute:
|
if not dry_run:
|
||||||
try:
|
for r in requests_to_execute:
|
||||||
process_app_deployment_request(
|
try:
|
||||||
ctx,
|
process_app_deployment_request(
|
||||||
laconic,
|
ctx,
|
||||||
r,
|
laconic,
|
||||||
record_namespace_deployments,
|
r,
|
||||||
record_namespace_dns,
|
record_namespace_deployments,
|
||||||
dns_suffix,
|
record_namespace_dns,
|
||||||
deployment_parent_dir,
|
dns_suffix,
|
||||||
kube_config,
|
deployment_parent_dir,
|
||||||
image_registry
|
kube_config,
|
||||||
)
|
image_registry
|
||||||
finally:
|
)
|
||||||
dump_known_requests(state_file, [r])
|
finally:
|
||||||
|
dump_known_requests(state_file, [r])
|
||||||
|
@ -186,8 +186,10 @@ def build_container_image(app_record, tag, extra_build_args=[]):
|
|||||||
|
|
||||||
print(f"Cloning repository {repo} to {clone_dir} ...")
|
print(f"Cloning repository {repo} to {clone_dir} ...")
|
||||||
if ref:
|
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()
|
result.check_returncode()
|
||||||
|
subprocess.check_call(["git", "checkout", ref], cwd=clone_dir)
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir])
|
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir])
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
Loading…
Reference in New Issue
Block a user