Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weathertop: Add --language flag to deploy.py runner. #6967

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .tools/test/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ python -m venv .venv && source .venv/bin/activate && pip install -r requirements
#### Command Syntax

```bash
python stacks/deploy.py --type <deployment_type>
cd stacks ; python deploy.py <stack>
```

Replace `<deployment_type>` with one of the supported types:
Replace `<stack>` with one of the supported stacks:

- `admin`: Deploys admin-specific resources.
- `images`: Deploys image-related resources.
- `plugin`: Deploys plugin-specific resources.
- To deploy only a specific language's plugin, pass `--language <language>` where language is an account in ./stacks/config/targets.yaml.
DavidSouther marked this conversation as resolved.
Show resolved Hide resolved

#### Additional Notes

Expand Down
21 changes: 17 additions & 4 deletions .tools/test/stacks/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import yaml
import time
import logging
import re


Expand All @@ -31,9 +30,12 @@ def run_shell_command(command, env_vars=None):
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT, env=env)
print(f"Command output: {output.decode()}")
except Exception as e:
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e.output.decode()}")
raise
except Exception as e:
print(f"Exception executing command: {e!r}")
DavidSouther marked this conversation as resolved.
Show resolved Hide resolved
raise


def validate_alphanumeric(value, name):
Expand Down Expand Up @@ -96,10 +98,13 @@ def deploy_resources(account_id, account_name, dir, lang="typescript"):


def main():
parser = argparse.ArgumentParser(description="admin, images, or plugin flag.")
parser = argparse.ArgumentParser(description="admin, images, or plugin stack.")
parser.add_argument("type", choices=["admin", "images", "plugin"])
parser.add_argument("--language")
args = parser.parse_args()

accounts = None

if args.type in {"admin", "images"}:
try:
with open("config/resources.yaml", "r") as file:
Expand All @@ -118,8 +123,16 @@ def main():
accounts = yaml.safe_load(file)
except Exception as e:
print(f"Failed to read config data: \n{e}")

if accounts is None:
raise ValueError(f"Could not load accounts for stack {args.type}")

if args.language:
items = [(args.language, accounts[args.language])]
else:
items = accounts.items()

for account_name, account_info in accounts.items():
for account_name, account_info in items:
print(
f"Reading from account {account_name} with ID {account_info['account_id']}"
)
Expand Down
Loading