|
9 | 9 | SSH_DEFAULT_ENCODING, read_ssh |
10 | 10 | from azure.cli.core.commands.client_factory import get_subscription_id |
11 | 11 |
|
| 12 | +import urllib |
12 | 13 | from knack.log import get_logger |
13 | 14 |
|
14 | 15 | logger = get_logger(__name__) |
15 | 16 |
|
16 | 17 |
|
17 | 18 | class DebugWebSocketConnection(WebSocketConnection): |
18 | | - def __init__(self, cmd, resource_group_name, name, revision, replica, container): |
| 19 | + def __init__(self, cmd, resource_group_name, name, revision, replica, container, command): |
19 | 20 | super(DebugWebSocketConnection, self).__init__(cmd, resource_group_name, name, revision, replica, container, "") |
| 21 | + self.command = urllib.parse.quote_plus(command) if command else None |
20 | 22 |
|
21 | 23 | def _get_url(self, cmd, resource_group_name, name, revision, replica, container, startup_command): |
22 | 24 | sub = get_subscription_id(cmd.cli_ctx) |
23 | 25 | base_url = self._logstream_endpoint |
24 | 26 | proxy_api_url = base_url[:base_url.index("/subscriptions/")].replace("https://", "") |
25 | 27 |
|
26 | | - return (f"wss://{proxy_api_url}/subscriptions/{sub}/resourceGroups/{resource_group_name}/containerApps/{name}" |
| 28 | + debug_url = (f"wss://{proxy_api_url}/subscriptions/{sub}/resourceGroups/{resource_group_name}/containerApps/{name}" |
27 | 29 | f"/revisions/{revision}/replicas/{replica}/debug" |
28 | 30 | f"?targetContainer={container}") |
| 31 | + if self.command: |
| 32 | + debug_url += f"&command={self.command}" |
| 33 | + return debug_url |
29 | 34 |
|
30 | 35 |
|
31 | 36 | def read_debug_ssh(connection: WebSocketConnection, response_encodings): |
|
0 commit comments