Skip to content

Commit d9bd529

Browse files
author
Shivam Kumar
committed
Adding command param in debug command
1 parent a34da44 commit d9bd529

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/containerapp/azext_containerapp/_ssh_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@
99
SSH_DEFAULT_ENCODING, read_ssh
1010
from azure.cli.core.commands.client_factory import get_subscription_id
1111

12+
import urllib
1213
from knack.log import get_logger
1314

1415
logger = get_logger(__name__)
1516

1617

1718
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):
1920
super(DebugWebSocketConnection, self).__init__(cmd, resource_group_name, name, revision, replica, container, "")
21+
self.command = urllib.parse.quote_plus(command) if command else None
2022

2123
def _get_url(self, cmd, resource_group_name, name, revision, replica, container, startup_command):
2224
sub = get_subscription_id(cmd.cli_ctx)
2325
base_url = self._logstream_endpoint
2426
proxy_api_url = base_url[:base_url.index("/subscriptions/")].replace("https://", "")
2527

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}"
2729
f"/revisions/{revision}/replicas/{replica}/debug"
2830
f"?targetContainer={container}")
31+
if self.command:
32+
debug_url += f"&command={self.command}"
33+
return debug_url
2934

3035

3136
def read_debug_ssh(connection: WebSocketConnection, response_encodings):

src/containerapp/azext_containerapp/custom.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,15 +3591,16 @@ def list_maintenance_config(cmd, resource_group_name, env_name):
35913591
return r
35923592

35933593

3594-
def containerapp_debug(cmd, resource_group_name, name, container=None, revision=None, replica=None):
3594+
def containerapp_debug(cmd, resource_group_name, name, container=None, revision=None, replica=None, command=None):
35953595
logger.warning("Connecting...")
35963596
conn = DebugWebSocketConnection(
35973597
cmd=cmd,
35983598
resource_group_name=resource_group_name,
35993599
name=name,
36003600
revision=revision,
36013601
replica=replica,
3602-
container=container
3602+
container=container,
3603+
command=command
36033604
)
36043605

36053606
encodings = [SSH_DEFAULT_ENCODING, SSH_BACKUP_ENCODING]

0 commit comments

Comments
 (0)