Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Update aws-sdk v2 to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-NCSU committed May 10, 2024
1 parent 80724b6 commit 156d076
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 7 additions & 6 deletions src/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ describe.each([[{ storedActionData: false }], [{ storedActionData: true }]])(
mockJiraClient.findIssue = jest.fn().mockResolvedValueOnce(foundIssue);
mockJiraClient.addAttachmentOnIssue = jest.fn().mockResolvedValueOnce({});

mockS3Client.getObject = jest.fn().mockImplementation(() => ({
promise: () =>
Promise.resolve({
Body: JSON.stringify(actionProperties),
}),
}));
mockS3Client.getObject = jest.fn().mockImplementation(() => {
return {
Body: {
transformToString: () => JSON.stringify(actionProperties),
},
};
});

actionProperties = {
classification: 'Task',
Expand Down
14 changes: 6 additions & 8 deletions src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GetObjectCommand, S3, S3Client } from '@aws-sdk/client-s3';
import { S3 } from '@aws-sdk/client-s3';
import {
Issue,
IssueFields,
Expand Down Expand Up @@ -144,18 +144,16 @@ function isValidCreateIssueActionProperties(
}

async function getStoredActionData(
s3Client: S3Client,
s3Client: S3,
actionDataS3Key: string,
): Promise<FullCreateIssueActionProperties> {
if (!jupiteroneEnv) {
throw new Error('Environment variable JUPITERONE_ENVIRONMENT must be set.');
}
const { Body: s3ObjectBody } = await s3Client.send(
new GetObjectCommand({
Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`,
Key: actionDataS3Key,
}),
);
const { Body: s3ObjectBody } = await s3Client.getObject({
Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`,
Key: actionDataS3Key,
});

if (!s3ObjectBody) {
throw new Error('Could not fetch action data.');
Expand Down

0 comments on commit 156d076

Please sign in to comment.