Skip to content

Commit f506b47

Browse files
committed
add comments and remove half-supported features
1 parent 36c2c75 commit f506b47

File tree

2 files changed

+6
-49
lines changed

2 files changed

+6
-49
lines changed

packages/core/src/shared/awsClientBuilderV3.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { HttpResponse } from '@aws-sdk/protocol-http'
2121
import { telemetry } from './telemetry'
2222
import { getRequestId } from './errors'
23-
import { getLogger } from '.'
23+
import { extensionVersion, getLogger } from '.'
2424

2525
export type AwsClient = IClient<any, any, any>
2626
interface AwsConfigOptions {
@@ -69,17 +69,9 @@ export class DefaultAWSClientBuilderV3 implements AWSClientBuilderV3 {
6969
}
7070

7171
if (!opt.customUserAgent && userAgent) {
72-
opt.customUserAgent = [[getUserAgent({ includePlatform: true, includeClientId: true })]]
73-
}
74-
75-
const apiConfig = (opt as { apiConfig?: { metadata?: Record<string, string> } } | undefined)?.apiConfig
76-
const serviceName =
77-
apiConfig?.metadata?.serviceId?.toLowerCase() ??
78-
(type as unknown as { serviceIdentifier?: string }).serviceIdentifier
79-
80-
if (serviceName) {
81-
opt.endpoint = settings?.get('endpoints', {})[serviceName] ?? opt.endpoint
72+
opt.customUserAgent = [[getUserAgent({ includePlatform: true, includeClientId: true }), extensionVersion]]
8273
}
74+
// TODO: add tests for refresh logic.
8375
opt.credentials = async () => {
8476
const creds = await shim.get()
8577
if (creds.expiration && creds.expiration.getTime() < Date.now()) {
@@ -89,6 +81,7 @@ export class DefaultAWSClientBuilderV3 implements AWSClientBuilderV3 {
8981
}
9082

9183
const service = new type(opt)
84+
// TODO: add middleware for logging, telemetry, endpoints.
9285
service.middlewareStack.add(telemetryMiddleware, { step: 'deserialize' } as DeserializeHandlerOptions)
9386
return service
9487
}

packages/core/src/test/shared/defaultAwsClientBuilderV3.test.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
import assert from 'assert'
77
import { version } from 'vscode'
8-
import { DevSettings } from '../../shared/settings'
98
import { getClientId } from '../../shared/telemetry/util'
109
import { FakeMemento } from '../fakeExtensionContext'
1110
import { FakeAwsContext } from '../utilities/fakeAwsContext'
12-
import { TestSettings } from '../utilities/testSettingsConfiguration'
1311
import { GlobalState } from '../../shared/globalState'
1412
import { AWSClientBuilderV3, DefaultAWSClientBuilderV3 } from '../../shared/awsClientBuilderV3'
1513
import { Client } from '@aws-sdk/smithy-client'
14+
import { extensionVersion } from '../../shared'
1615

1716
describe('DefaultAwsClientBuilderV3', function () {
1817
let builder: AWSClientBuilderV3
@@ -31,6 +30,7 @@ describe('DefaultAwsClientBuilderV3', function () {
3130
service.config.customUserAgent![0][0].replace('---Insiders', ''),
3231
`AWS-Toolkit-For-VSCode/testPluginVersion Visual-Studio-Code/${version} ClientId/${clientId}`
3332
)
33+
assert.strictEqual(service.config.customUserAgent![0][1], extensionVersion)
3434
})
3535

3636
it('adds region to client', async function () {
@@ -54,41 +54,5 @@ describe('DefaultAwsClientBuilderV3', function () {
5454

5555
assert.strictEqual(service.config.customUserAgent[0][0], 'CUSTOM USER AGENT')
5656
})
57-
58-
it('can use endpoint override', async function () {
59-
const settings = new TestSettings()
60-
await settings.update('aws.dev.endpoints', { foo: 'http://example.com' })
61-
62-
const service = await builder.createAwsService(
63-
Client as any,
64-
{
65-
customUserAgent: [['CUSTOM USER AGENT']],
66-
apiConfig: { metadata: { serviceId: 'foo' } },
67-
} as any,
68-
undefined,
69-
undefined,
70-
new DevSettings(settings)
71-
)
72-
73-
assert.strictEqual(service.config.endpoint, 'http://example.com')
74-
})
75-
76-
it('does not clobber endpoint setting if no override is present', async function () {
77-
const settings = new TestSettings()
78-
79-
const service = await builder.createAwsService(
80-
Client as any,
81-
{
82-
customUserAgent: 'CUSTOM USER AGENT',
83-
apiConfig: { metadata: { serviceId: 'foo' } },
84-
endpoint: 'http://example.com',
85-
} as any,
86-
undefined,
87-
undefined,
88-
new DevSettings(settings)
89-
)
90-
91-
assert.strictEqual(service.config.endpoint, 'http://example.com')
92-
})
9357
})
9458
})

0 commit comments

Comments
 (0)