|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import argparse |
1 | 4 | import html |
2 | 5 | import json |
3 | 6 | import logging |
|
48 | 51 | UI_THEMES_UPDATE_SET, |
49 | 52 | ) |
50 | 53 | from .api.user import set_user_preference |
51 | | -from .instance import SNowInstance |
| 54 | +from .instance import SNowInstance as _BaseSNowInstance |
52 | 55 | from .utils import url_login |
53 | 56 |
|
54 | 57 |
|
| 58 | +_CLI_INSTANCE_URL: str | None = None |
| 59 | +_CLI_INSTANCE_PASSWORD: str | None = None |
| 60 | + |
| 61 | + |
| 62 | +def SNowInstance(): |
| 63 | + """ |
| 64 | + Wrapper around the standard SNowInstance that always uses CLI-provided credentials. |
| 65 | + """ |
| 66 | + if not _CLI_INSTANCE_URL or not _CLI_INSTANCE_PASSWORD: |
| 67 | + raise RuntimeError( |
| 68 | + "Installer requires --instance-url and --instance-password arguments." |
| 69 | + ) |
| 70 | + return _BaseSNowInstance( |
| 71 | + snow_url=_CLI_INSTANCE_URL, |
| 72 | + snow_credentials=("admin", _CLI_INSTANCE_PASSWORD), |
| 73 | + ) |
| 74 | + |
| 75 | + |
55 | 76 | def _is_dev_portal_instance() -> bool: |
56 | 77 | """ |
57 | 78 | Check if the instance is a ServiceNow Developer Portal instance. |
@@ -1105,6 +1126,19 @@ def main(): |
1105 | 1126 | Entrypoint for package CLI installation command |
1106 | 1127 |
|
1107 | 1128 | """ |
| 1129 | + parser = argparse.ArgumentParser(description="Install WorkArena artifacts on a ServiceNow instance.") |
| 1130 | + parser.add_argument("--instance-url", required=True, help="URL of the target ServiceNow instance.") |
| 1131 | + parser.add_argument( |
| 1132 | + "--instance-password", |
| 1133 | + required=True, |
| 1134 | + help="Password for the admin user on the target ServiceNow instance.", |
| 1135 | + ) |
| 1136 | + args = parser.parse_args() |
| 1137 | + |
| 1138 | + global _CLI_INSTANCE_URL, _CLI_INSTANCE_PASSWORD |
| 1139 | + _CLI_INSTANCE_URL = args.instance_url |
| 1140 | + _CLI_INSTANCE_PASSWORD = args.instance_password |
| 1141 | + |
1108 | 1142 | logging.basicConfig(level=logging.INFO) |
1109 | 1143 |
|
1110 | 1144 | try: |
|
0 commit comments