Skip to content

Commit e72d016

Browse files
authored
Merge pull request #4771 from aws/jpinkney-aws/cc-fix
fix: User is able to create a dev environment inside of a dev environment
2 parents 2862695 + 686595e commit e72d016

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Codecatalyst: User can create a dev environment inside a dev environment"
4+
}

packages/core/src/codecatalyst/commands.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { CreateDevEnvironmentRequest, UpdateDevEnvironmentRequest } from 'aws-sd
2626
import { Auth } from '../auth/auth'
2727
import { SsoConnection } from '../auth/connection'
2828
import { showManageConnections } from '../auth/ui/vue/show'
29+
import { isInDevEnv } from '../shared/vscode/env'
2930

3031
/** "List CodeCatalyst Commands" command. */
3132
export async function listCommands(): Promise<void> {
@@ -205,6 +206,14 @@ type Inject<T, U> = T extends (...args: infer P) => infer R
205206

206207
type WithClient<T> = Parameters<Inject<T, CodeCatalystClient>>
207208

209+
class RemoteContextError extends ToolkitError {
210+
constructor() {
211+
super('Cannot connect from a remote context. Try again from a local VS Code instance.', {
212+
code: 'ConnectedToRemote',
213+
})
214+
}
215+
}
216+
208217
export class CodeCatalystCommands {
209218
public readonly withClient: ClientInjector
210219
public readonly bindClient = createCommandDecorator(this)
@@ -222,6 +231,9 @@ export class CodeCatalystCommands {
222231
}
223232

224233
public createDevEnv(): Promise<void> {
234+
if (vscode.env.remoteName === 'ssh-remote' && isInDevEnv()) {
235+
throw new RemoteContextError()
236+
}
225237
return this.withClient(showCreateDevEnv, globals.context, CodeCatalystCommands.declared)
226238
}
227239

@@ -268,10 +280,8 @@ export class CodeCatalystCommands {
268280
targetPath?: string,
269281
connection?: { startUrl: string; region: string }
270282
): Promise<void> {
271-
if (vscode.env.remoteName === 'ssh-remote') {
272-
throw new ToolkitError('Cannot connect from a remote context. Try again from a local VS Code instance.', {
273-
code: 'ConnectedToRemote',
274-
})
283+
if (vscode.env.remoteName === 'ssh-remote' && isInDevEnv()) {
284+
throw new RemoteContextError()
275285
}
276286

277287
const devenv = id ?? (await this.selectDevEnv())

0 commit comments

Comments
 (0)