Skip to content

Commit 4f6574c

Browse files
committed
fix: remove fetch override for octokit and versions
1 parent 3ca0bb0 commit 4f6574c

File tree

9 files changed

+246
-105
lines changed

9 files changed

+246
-105
lines changed

lambdas/functions/control-plane/jest.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const config: Config = {
66
...defaultConfig,
77
coverageThreshold: {
88
global: {
9-
statements: 98.01,
10-
branches: 97.28,
11-
functions: 95.6,
12-
lines: 97.94,
9+
statements: 97.99,
10+
branches: 97.26,
11+
functions: 95.45,
12+
lines: 97.92,
1313
},
1414
},
1515
};

lambdas/functions/control-plane/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@
4444
"@octokit/auth-app": "6.1.1",
4545
"@octokit/core": "5.2.0",
4646
"@octokit/plugin-throttling": "8.2.0",
47-
"@octokit/rest": "20.0.2",
47+
"@octokit/rest": "20.1.1",
4848
"@octokit/types": "^13.5.0",
4949
"@terraform-aws-github-runner/aws-powertools-util": "*",
5050
"@terraform-aws-github-runner/aws-ssm-util": "*",
51-
"axios": "^1.7.2",
5251
"cron-parser": "^4.9.0",
5352
"typescript": "^5.5.4"
5453
},

lambdas/functions/control-plane/src/axios/fetch-override.test.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

lambdas/functions/control-plane/src/axios/fetch-override.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

lambdas/functions/control-plane/src/gh-auth/gh-auth.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ${decryptedValue}`,
9595

9696
// Assert
9797
expect(mockedCreatAppAuth).toBeCalledTimes(1);
98-
expect(mockedCreatAppAuth).toBeCalledWith({ ...authOptions, request: expect.anything() });
98+
expect(mockedCreatAppAuth).toBeCalledWith({ ...authOptions });
9999
});
100100

101101
test('Creates auth object for public GitHub', async () => {
@@ -121,7 +121,7 @@ ${decryptedValue}`,
121121
expect(getParameter).toBeCalledWith(PARAMETER_GITHUB_APP_KEY_BASE64_NAME);
122122

123123
expect(mockedCreatAppAuth).toBeCalledTimes(1);
124-
expect(mockedCreatAppAuth).toBeCalledWith({ ...authOptions, request: expect.anything() });
124+
expect(mockedCreatAppAuth).toBeCalledWith({ ...authOptions });
125125
expect(mockedAuth).toBeCalledWith({ type: authType });
126126
expect(result.token).toBe(token);
127127
});

lambdas/functions/control-plane/src/gh-auth/gh-auth.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ import { Octokit } from '@octokit/rest';
1313
import { throttling } from '@octokit/plugin-throttling';
1414
import { createChildLogger } from '@terraform-aws-github-runner/aws-powertools-util';
1515
import { getParameter } from '@terraform-aws-github-runner/aws-ssm-util';
16-
17-
import { axiosFetch } from '../axios/fetch-override';
16+
import { EndpointDefaults } from '@octokit/types';
1817

1918
const logger = createChildLogger('gh-auth');
2019

2120
export async function createOctoClient(token: string, ghesApiUrl = ''): Promise<Octokit> {
2221
const CustomOctokit = Octokit.plugin(throttling);
2322
const ocktokitOptions: OctokitOptions = {
2423
auth: token,
25-
request: { fetch: axiosFetch },
2624
};
2725
if (ghesApiUrl) {
2826
ocktokitOptions.baseUrl = ghesApiUrl;
@@ -32,12 +30,12 @@ export async function createOctoClient(token: string, ghesApiUrl = ''): Promise<
3230
return new CustomOctokit({
3331
...ocktokitOptions,
3432
throttle: {
35-
onRateLimit: (options: { method: string; url: string }) => {
33+
onRateLimit: (retryAfter: number, options: Required<EndpointDefaults>) => {
3634
logger.warn(
3735
`GitHub rate limit: Request quota exhausted for request ${options.method} ${options.url}. Requested `,
3836
);
3937
},
40-
onSecondaryRateLimit: (options: { method: string; url: string }) => {
38+
onSecondaryRateLimit: (retryAfter: number, options: Required<EndpointDefaults>) => {
4139
logger.warn(`GitHub rate limit: SecondaryRateLimit detected for request ${options.method} ${options.url}`);
4240
},
4341
},
@@ -82,12 +80,7 @@ async function createAuth(installationId: number | undefined, ghesApiUrl: string
8280
if (ghesApiUrl) {
8381
authOptions.request = request.defaults({
8482
baseUrl: ghesApiUrl,
85-
request: {
86-
fetch: axiosFetch,
87-
},
8883
});
89-
} else {
90-
authOptions.request = request.defaults({ request: { fetch: axiosFetch } });
9184
}
9285
return createAppAuth(authOptions);
9386
}

lambdas/functions/gh-agent-syncer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@aws-sdk/lib-storage": "^3.623.0",
4141
"@aws-sdk/types": "^3.609.0",
4242
"@middy/core": "^4.7.0",
43-
"@octokit/rest": "20.0.2",
43+
"@octokit/rest": "20.1.1",
4444
"@terraform-aws-github-runner/aws-powertools-util": "*",
4545
"axios": "^1.7.2"
4646
},

lambdas/functions/webhook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"dependencies": {
4040
"@aws-sdk/client-sqs": "^3.623.0",
4141
"@middy/core": "^4.7.0",
42-
"@octokit/rest": "20.0.2",
42+
"@octokit/rest": "20.1.1",
4343
"@octokit/types": "^13.5.0",
4444
"@octokit/webhooks": "^12.2.0",
4545
"@terraform-aws-github-runner/aws-powertools-util": "*",

0 commit comments

Comments
 (0)