Skip to content

Commit ffa0076

Browse files
AFDudleyclaude
andcommitted
Add extra_args support to deploy create command
- Add @click.argument for generic args passthrough to stack commands - Keep explicit --network-dir and --initial-peers options - Add DeploymentContext.get_compose_file() helper - Add DeploymentContext.modify_yaml() helper for stack commands - Update init() to use absolute paths This allows stack-specific create commands to receive arbitrary arguments via: laconic-so deploy create ... -- --custom-arg value Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 86462c9 commit ffa0076

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

stack_orchestrator/deploy/deployment_context.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,28 @@ def get_deployment_file(self):
4444
def get_compose_dir(self):
4545
return self.deployment_dir.joinpath(constants.compose_dir_name)
4646

47+
def get_compose_file(self, name: str):
48+
return self.get_compose_dir() / f"docker-compose-{name}.yml"
49+
50+
def modify_yaml(self, file_path: Path, modifier_func):
51+
"""Load a YAML from the deployment, apply a modifier, and write back."""
52+
if not file_path.absolute().is_relative_to(self.deployment_dir):
53+
raise ValueError(f"File is not inside deployment directory: {file_path}")
54+
55+
yaml = get_yaml()
56+
with open(file_path, "r") as f:
57+
yaml_data = yaml.load(f)
58+
59+
modifier_func(yaml_data)
60+
61+
with open(file_path, "w") as f:
62+
yaml.dump(yaml_data, f)
63+
4764
def get_cluster_id(self):
4865
return self.id
4966

50-
def init(self, dir):
51-
self.deployment_dir = dir
67+
def init(self, dir: Path):
68+
self.deployment_dir = dir.absolute()
5269
self.spec = Spec()
5370
self.spec.init_from_file(self.get_spec_file())
5471
self.stack = Stack(self.spec.obj["stack"])

stack_orchestrator/deploy/deployment_create.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,11 @@ def _check_volume_definitions(spec):
533533
# TODO: Hack
534534
@click.option("--network-dir", help="Network configuration supplied in this directory")
535535
@click.option("--initial-peers", help="Initial set of persistent peers")
536+
@click.argument("extra_args", nargs=-1, type=click.UNPROCESSED)
536537
@click.pass_context
537-
def create(ctx, spec_file, deployment_dir, helm_chart, network_dir, initial_peers):
538+
def create(
539+
ctx, spec_file, deployment_dir, helm_chart, network_dir, initial_peers, extra_args
540+
):
538541
deployment_command_context = ctx.obj
539542
return create_operation(
540543
deployment_command_context,
@@ -543,6 +546,7 @@ def create(ctx, spec_file, deployment_dir, helm_chart, network_dir, initial_peer
543546
helm_chart,
544547
network_dir,
545548
initial_peers,
549+
extra_args,
546550
)
547551

548552

@@ -555,6 +559,7 @@ def create_operation(
555559
helm_chart,
556560
network_dir,
557561
initial_peers,
562+
extra_args=(),
558563
):
559564
parsed_spec = Spec(
560565
os.path.abspath(spec_file), get_parsed_deployment_spec(spec_file)
@@ -703,7 +708,7 @@ def create_operation(
703708
if deployer_config_generator is not None:
704709
deployer_config_generator.generate(deployment_dir_path)
705710
call_stack_deploy_create(
706-
deployment_context, [network_dir, initial_peers, deployment_command_context]
711+
deployment_context, [network_dir, initial_peers, *extra_args]
707712
)
708713

709714

0 commit comments

Comments
 (0)