From 420b1c292b8cd5683b367c143c902aae11a1f43a Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 10 Oct 2023 16:13:29 -0600 Subject: [PATCH] Force the stack to be specified (#571) * Force the stack to be specified * Fix up test * Remove test for legacy non-stack deploy --- app/deploy.py | 9 ++++++++- tests/deploy/run-deploy-test.sh | 2 +- tests/smoke-test/run-smoke-test.sh | 4 ---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/deploy.py b/app/deploy.py index 9298148a..0ebcfe18 100644 --- a/app/deploy.py +++ b/app/deploy.py @@ -41,9 +41,16 @@ from app.deployment_create import setup as deployment_setup def command(ctx, include, exclude, env_file, cluster): '''deploy a stack''' + # Although in theory for some subcommands (e.g. deploy create) the stack can be inferred, + # Click doesn't allow us to know that here, so we make providing the stack mandatory + stack = global_options2(ctx).stack + if not stack: + print("Error: --stack option is required") + sys.exit(1) + if ctx.parent.obj.debug: print(f"ctx.parent.obj: {ctx.parent.obj}") - ctx.obj = create_deploy_context(global_options2(ctx), global_options2(ctx).stack, include, exclude, cluster, env_file) + ctx.obj = create_deploy_context(global_options2(ctx), stack, include, exclude, cluster, env_file) # Subcommand is executed now, by the magic of click diff --git a/tests/deploy/run-deploy-test.sh b/tests/deploy/run-deploy-test.sh index 86f4b689..4456c28d 100755 --- a/tests/deploy/run-deploy-test.sh +++ b/tests/deploy/run-deploy-test.sh @@ -85,7 +85,7 @@ if [ ! -f "$test_deployment_spec" ]; then exit 1 fi echo "deploy init test: passed" -$TEST_TARGET_SO deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir +$TEST_TARGET_SO --stack test deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir # Check the deployment dir exists if [ ! -d "$test_deployment_dir" ]; then echo "deploy create test: deployment directory not present" diff --git a/tests/smoke-test/run-smoke-test.sh b/tests/smoke-test/run-smoke-test.sh index 0ee258ce..2fb4d322 100755 --- a/tests/smoke-test/run-smoke-test.sh +++ b/tests/smoke-test/run-smoke-test.sh @@ -37,8 +37,4 @@ $TEST_TARGET_SO --stack test deploy-system down # Run same test but not using the stack definition # Test building the a stack container $TEST_TARGET_SO build-containers --include cerc/test-container -# Deploy the test container -$TEST_TARGET_SO deploy-system --include test up -# Clean up -$TEST_TARGET_SO deploy-system --include test down echo "Test passed"