Skip to content

Commit 5904a28

Browse files
committed
refactor: rename wrappers to clients
1 parent 3b50424 commit 5904a28

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

packages/core/src/awsService/ec2/model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Ec2Selection } from './prompter'
88
import { getOrInstallCli } from '../../shared/utilities/cliUtils'
99
import { isCloud9 } from '../../shared/extensionUtilities'
1010
import { ToolkitError } from '../../shared/errors'
11-
import { SSMWrapper } from '../../shared/clients/ssm'
11+
import { SsmClient } from '../../shared/clients/ssm'
1212
import { Ec2Client } from '../../shared/clients/ec2Client'
1313
import {
1414
VscodeRemoteConnection,
@@ -51,7 +51,7 @@ interface RemoteUser {
5151
}
5252

5353
export class Ec2Connecter implements vscode.Disposable {
54-
protected ssm: SSMWrapper
54+
protected ssm: SsmClient
5555
protected ec2Client: Ec2Client
5656
protected iamClient: DefaultIamClient
5757
protected sessionManager: Ec2SessionTracker
@@ -71,8 +71,8 @@ export class Ec2Connecter implements vscode.Disposable {
7171
this.sessionManager = new Ec2SessionTracker(regionCode, this.ssm)
7272
}
7373

74-
protected createSsmSdkClient(): SSMWrapper {
75-
return new SSMWrapper(this.regionCode)
74+
protected createSsmSdkClient(): SsmClient {
75+
return new SsmClient(this.regionCode)
7676
}
7777

7878
protected createEc2SdkClient(): Ec2Client {

packages/core/src/awsService/ec2/remoteSessionManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55

66
import { EC2 } from 'aws-sdk'
7-
import { SSMWrapper } from '../../shared/clients/ssm'
7+
import { SsmClient } from '../../shared/clients/ssm'
88
import { Disposable } from 'vscode'
99

1010
export class Ec2SessionTracker extends Map<EC2.InstanceId, string> implements Disposable {
1111
public constructor(
1212
readonly regionCode: string,
13-
protected ssm: SSMWrapper
13+
protected ssm: SsmClient
1414
) {
1515
super()
1616
}

packages/core/src/shared/clients/wrapper.ts renamed to packages/core/src/shared/clients/clientWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AwsClient, AwsClientConstructor, AwsCommand } from '../awsClientBuilder
88
import { pageableToCollection } from '../utilities/collectionUtils'
99

1010
export abstract class ClientWrapper<C extends AwsClient> implements vscode.Disposable {
11-
protected client: C | undefined
11+
protected client?: C
1212

1313
public constructor(
1414
public readonly regionCode: string,

packages/core/src/shared/clients/ssm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import {
2121
} from '@aws-sdk/client-ssm'
2222
import { WaiterState } from '@smithy/util-waiter'
2323
import { ToolkitError } from '../errors'
24-
import { ClientWrapper } from './wrapper'
24+
import { ClientWrapper } from './clientWrapper'
2525

26-
export class SSMWrapper extends ClientWrapper<SSMClient> {
26+
export class SsmClient extends ClientWrapper<SSMClient> {
2727
public constructor(public override readonly regionCode: string) {
2828
super(regionCode, SSMClient)
2929
}

packages/core/src/test/awsService/ec2/model.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import assert from 'assert'
77
import * as sinon from 'sinon'
88
import { Ec2Connecter, getRemoveLinesCommand } from '../../../awsService/ec2/model'
9-
import { SSMWrapper } from '../../../shared/clients/ssm'
9+
import { SsmClient } from '../../../shared/clients/ssm'
1010
import { Ec2Client } from '../../../shared/clients/ec2Client'
1111
import { Ec2Selection } from '../../../awsService/ec2/prompter'
1212
import { ToolkitError } from '../../../shared/errors'
@@ -115,7 +115,7 @@ describe('Ec2ConnectClient', function () {
115115
sinon.stub(Ec2Connecter.prototype, 'isInstanceRunning').resolves(true)
116116
sinon.stub(Ec2Connecter.prototype, 'getAttachedIamRole').resolves({ Arn: 'testRole' } as IAM.Role)
117117
sinon.stub(Ec2Connecter.prototype, 'hasProperPermissions').resolves(true)
118-
sinon.stub(SSMWrapper.prototype, 'getInstanceAgentPingStatus').resolves('offline')
118+
sinon.stub(SsmClient.prototype, 'getInstanceAgentPingStatus').resolves('offline')
119119

120120
try {
121121
await client.checkForStartSessionError(instanceSelection)
@@ -129,15 +129,15 @@ describe('Ec2ConnectClient', function () {
129129
sinon.stub(Ec2Connecter.prototype, 'isInstanceRunning').resolves(true)
130130
sinon.stub(Ec2Connecter.prototype, 'getAttachedIamRole').resolves({ Arn: 'testRole' } as IAM.Role)
131131
sinon.stub(Ec2Connecter.prototype, 'hasProperPermissions').resolves(true)
132-
sinon.stub(SSMWrapper.prototype, 'getInstanceAgentPingStatus').resolves('Online')
132+
sinon.stub(SsmClient.prototype, 'getInstanceAgentPingStatus').resolves('Online')
133133

134134
assert.doesNotThrow(async () => await client.checkForStartSessionError(instanceSelection))
135135
})
136136
})
137137

138138
describe('sendSshKeysToInstance', async function () {
139139
it('calls the sdk with the proper parameters', async function () {
140-
const sendCommandStub = sinon.stub(SSMWrapper.prototype, 'sendCommandAndWait')
140+
const sendCommandStub = sinon.stub(SsmClient.prototype, 'sendCommandAndWait')
141141

142142
const testSelection = {
143143
instanceId: 'test-id',
@@ -151,7 +151,7 @@ describe('Ec2ConnectClient', function () {
151151
})
152152

153153
it('avoids writing the keys to any telemetry metrics', async function () {
154-
sinon.stub(SSMWrapper.prototype, 'sendCommandAndWait')
154+
sinon.stub(SsmClient.prototype, 'sendCommandAndWait')
155155

156156
const testSelection = {
157157
instanceId: 'test-id',
@@ -173,7 +173,7 @@ describe('Ec2ConnectClient', function () {
173173
let getTargetPlatformNameStub: sinon.SinonStub<[target: string], Promise<string>>
174174

175175
before(async function () {
176-
getTargetPlatformNameStub = sinon.stub(SSMWrapper.prototype, 'getTargetPlatformName')
176+
getTargetPlatformNameStub = sinon.stub(SsmClient.prototype, 'getTargetPlatformName')
177177
})
178178

179179
after(async function () {
@@ -205,7 +205,7 @@ describe('Ec2ConnectClient', function () {
205205

206206
describe('tryCleanKeys', async function () {
207207
it('calls the sdk with the proper parameters', async function () {
208-
const sendCommandStub = sinon.stub(SSMWrapper.prototype, 'sendCommandAndWait')
208+
const sendCommandStub = sinon.stub(SsmClient.prototype, 'sendCommandAndWait')
209209

210210
const testSelection = {
211211
instanceId: 'test-id',
@@ -222,7 +222,7 @@ describe('Ec2ConnectClient', function () {
222222

223223
it('logs warning when sdk call fails', async function () {
224224
const sendCommandStub = sinon
225-
.stub(SSMWrapper.prototype, 'sendCommandAndWait')
225+
.stub(SsmClient.prototype, 'sendCommandAndWait')
226226
.throws(new ToolkitError('error'))
227227

228228
const testSelection = {

packages/core/src/test/awsService/ec2/remoteSessionManager.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import assert from 'assert'
77
import * as sinon from 'sinon'
88
import { Ec2SessionTracker } from '../../../awsService/ec2/remoteSessionManager'
9-
import { SSMWrapper } from '../../../shared/clients/ssm'
9+
import { SsmClient } from '../../../shared/clients/ssm'
1010

1111
describe('Ec2RemoteSessionManager', async function () {
1212
it('maintains connections to instances', async function () {
13-
const envManager = new Ec2SessionTracker('test-region', new SSMWrapper('test-region'))
13+
const envManager = new Ec2SessionTracker('test-region', new SsmClient('test-region'))
1414
await envManager.addSession('test-instance', 'test-env')
1515
await envManager.addSession('test-instance2', 'test-env2')
1616
await envManager.addSession('test-instance3', 'test-env3')
@@ -22,8 +22,8 @@ describe('Ec2RemoteSessionManager', async function () {
2222
})
2323

2424
it('only allows for single connection with any given instance', async function () {
25-
const envManager = new Ec2SessionTracker('test-region', new SSMWrapper('test-region'))
26-
const terminateStub = sinon.stub(SSMWrapper.prototype, 'terminateSessionFromId')
25+
const envManager = new Ec2SessionTracker('test-region', new SsmClient('test-region'))
26+
const terminateStub = sinon.stub(SsmClient.prototype, 'terminateSessionFromId')
2727

2828
await envManager.addSession('test-instance', 'test-env')
2929
sinon.assert.notCalled(terminateStub)
@@ -37,8 +37,8 @@ describe('Ec2RemoteSessionManager', async function () {
3737
})
3838

3939
it('closes all active connections', async function () {
40-
const envManager = new Ec2SessionTracker('test-region', new SSMWrapper('test-region'))
41-
const terminateStub = sinon.stub(SSMWrapper.prototype, 'terminateSessionFromId')
40+
const envManager = new Ec2SessionTracker('test-region', new SsmClient('test-region'))
41+
const terminateStub = sinon.stub(SsmClient.prototype, 'terminateSessionFromId')
4242

4343
await envManager.addSession('test-instance', 'test-env')
4444
await envManager.addSession('test-instance2', 'test-env2')

0 commit comments

Comments
 (0)