From 600eb93b4da5e7647ea318912556d6966d97c4da Mon Sep 17 00:00:00 2001 From: "A. F. Dudley" Date: Mon, 2 Feb 2026 22:48:19 -0500 Subject: [PATCH] Add --spec-file option to restart and auto-detect GitOps spec - Add --spec-file option to specify spec location in repo - Auto-detect deployment/spec.yml in repo as GitOps location - Fall back to deployment dir if no repo spec found Co-Authored-By: Claude Opus 4.5 --- stack_orchestrator/deploy/deployment.py | 28 +++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/deploy/deployment.py b/stack_orchestrator/deploy/deployment.py index 2500d0d5..54f8377a 100644 --- a/stack_orchestrator/deploy/deployment.py +++ b/stack_orchestrator/deploy/deployment.py @@ -234,6 +234,9 @@ def run_job(ctx, job_name, helm_release): @command.command() @click.option("--stack-path", help="Path to stack git repo (overrides stored path)") +@click.option( + "--spec-file", help="Path to GitOps spec.yml in repo (e.g., deployment/spec.yml)" +) @click.option("--config-file", help="Config file to pass to deploy init") @click.option( "--force", @@ -246,7 +249,7 @@ def run_job(ctx, job_name, helm_release): help="Expected IP for DNS verification (if different from egress)", ) @click.pass_context -def restart(ctx, stack_path, config_file, force, expected_ip): +def restart(ctx, stack_path, spec_file, config_file, force, expected_ip): """Pull latest code and restart deployment using git-tracked spec. GitOps workflow: @@ -317,13 +320,30 @@ def restart(ctx, stack_path, config_file, force, expected_ip): sys.exit(1) print(f"Git pull: {git_result.stdout.strip()}") - # Use the spec.yml from the deployment directory (updated by git pull if tracked) - spec_file_path = deployment_context.deployment_dir / "spec.yml" + # Determine spec file location + # Priority: --spec-file argument > repo's deployment/spec.yml > deployment dir + if spec_file: + # Spec file relative to repo root + repo_root = stack_source.parent.parent.parent # Go up from stack path + spec_file_path = repo_root / spec_file + else: + # Try standard GitOps location in repo + repo_root = stack_source.parent.parent.parent + gitops_spec = repo_root / "deployment" / "spec.yml" + if gitops_spec.exists(): + spec_file_path = gitops_spec + else: + # Fall back to deployment directory + spec_file_path = deployment_context.deployment_dir / "spec.yml" + if not spec_file_path.exists(): print(f"Error: spec.yml not found at {spec_file_path}") - print("Ensure spec.yml exists in the deployment directory.") + print("For GitOps, add spec.yml to your repo at deployment/spec.yml") + print("Or specify --spec-file with path relative to repo root") sys.exit(1) + print(f"Using spec: {spec_file_path}") + # Parse spec to check for hostname changes new_spec_obj = get_parsed_deployment_spec(str(spec_file_path)) new_http_proxy = new_spec_obj.get("network", {}).get("http-proxy", [])