Skip to content

Commit

Permalink
Merge branch 'main' into renovate/registry.access.redhat.com-ubi9-s2i…
Browse files Browse the repository at this point in the history
…-base
  • Loading branch information
rafasdc authored Jun 13, 2024
2 parents 1b9482a + 5210693 commit 6545927
Show file tree
Hide file tree
Showing 9 changed files with 1,045 additions and 542 deletions.
4 changes: 2 additions & 2 deletions .github/actions/feature/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ runs:
# full name override should match db name as it is used in some secret creations
# as well as deployments
- run: |
FEATURE_NAME_LOWER=$(echo "${{ inputs.feature_name }}" | tr '[:upper:]' '[:lower:]')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30)
FEATURE_NAME_LOWER=$(echo "${{ inputs.feature_name }}" | tr '[:upper:]' '[:lower:]' | sed 's/-*$//')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30 | sed 's/-*$//')
chmod +x ./lib/app_deploy_feature.sh
./lib/app_deploy_feature.sh -n ${{ inputs.openshift_app_namespace }} \
--set fullnameOverride="$FEATURE_NAME_LOWER_SHORT" \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ jobs:
- name: Update JIRA Issue
# JIRA_AUTH must be passed pre encoded
run: |
FEATURE_NAME_LOWER=$(echo $FEATURE_NAME | tr '[:upper:]' '[:lower:]')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30)
FEATURE_NAME_LOWER=$(echo $FEATURE_NAME | tr '[:upper:]' '[:lower:]' | sed 's/-*$//')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30 | sed 's/-*$//')
curl -X POST \
-H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \
-H "Content-Type: application/json" \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jira-feat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
- name: Update JIRA Issue
# JIRA_AUTH must be passed pre encoded
run: |
FEATURE_NAME_LOWER=$(echo $FEATURE_NAME | tr '[:upper:]' '[:lower:]')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30)
FEATURE_NAME_LOWER=$(echo $FEATURE_NAME | tr '[:upper:]' '[:lower:]' | sed 's/-*$//')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30 | sed 's/-*$//')
curl -X POST \
-H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \
-H "Content-Type: application/json" \
Expand Down
13 changes: 10 additions & 3 deletions app/backend/lib/awsCommon.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import http from 'https';
import { NodeHttpHandler } from '@aws-sdk/node-http-handler';
import { NodeHttpHandler } from '@smithy/node-http-handler';
import {
fromTemporaryCredentials,
fromEnv,
} from '@aws-sdk/credential-providers';
import { S3ClientConfig } from '@aws-sdk/client-s3';
import { SNSClientConfig } from '@aws-sdk/client-sns';
import config from '../../config';
import CustomHttpsAgent from './CustomHttpsAgent';

Expand All @@ -24,7 +25,7 @@ const nodeHandler = new NodeHttpHandler({
connectionTimeout: 30000,
});

const awsConfig: S3ClientConfig = {
const awsConfig: any = {
region: AWS_S3_REGION,
logger: ENABLE_AWS_LOGS && console,
requestHandler: nodeHandler,
Expand All @@ -40,4 +41,10 @@ const awsConfig: S3ClientConfig = {
}),
};

export default awsConfig;
export const awsS3Config: S3ClientConfig = {
...awsConfig,
};

export const awsSNSConfig: SNSClientConfig = {
...awsConfig,
};
53 changes: 29 additions & 24 deletions app/backend/lib/s3client.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { S3Client, GetObjectCommand, GetObjectTaggingCommand, HeadObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
import {
S3Client,
GetObjectCommand,
GetObjectTaggingCommand,
HeadObjectCommand,
PutObjectCommand,
} from '@aws-sdk/client-s3';

import config from '../../config/index';
import awsConfig from './awsCommon'
import { awsS3Config } from './awsCommon';

const AWS_S3_BUCKET = config.get('AWS_S3_BUCKET');

const s3ClientV3sdk = new S3Client(awsConfig);
const s3ClientV3sdk = new S3Client(awsS3Config);

export const getSignedUrlPromise = async(params) => {
export const getSignedUrlPromise = async (params) => {
const command = new GetObjectCommand(params);
return getSignedUrl(s3ClientV3sdk, command, { expiresIn: 3600 });
}
};

export const getFileFromS3 = async (uuid, filename, res) => {
const params = {
Expand All @@ -30,37 +36,36 @@ export const getFileFromS3 = async (uuid, filename, res) => {
.catch(() => {
res.status(500).end();
});
}
};

export const checkFileExists = async (params) =>{
try {
export const checkFileExists = async (params) => {
try {
const command = new HeadObjectCommand(params);
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return false;
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return false;
} catch (error) {
return false;
}
return true;
}
};

export const getFileTagging = async (params) =>{
const noData={TagSet:[]};
try {
export const getFileTagging = async (params) => {
const noData = { TagSet: [] };
try {
const command = new GetObjectTaggingCommand(params);
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return noData;
return response;
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return noData;
return response;
} catch (error) {
return noData;
}
}
};

export const uploadFileToS3 = async(params) =>
{
const command = new PutObjectCommand(params);
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return false;
export const uploadFileToS3 = async (params) => {
const command = new PutObjectCommand(params);
const response = await s3ClientV3sdk.send(command);
if (response.$metadata?.httpStatusCode !== 200) return false;
return true;
}
};

export const s3ClientV3 = s3ClientV3sdk;
19 changes: 11 additions & 8 deletions app/backend/lib/sns-client.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns";
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';

import awsConfig from './awsCommon'
import { awsSNSConfig } from './awsCommon';

export const snsClient = new SNSClient(awsConfig);
export const snsClient = new SNSClient(awsSNSConfig);

export const pushMessage = async (topic:string, uuid: string, body: string) => {
export const pushMessage = async (
topic: string,
uuid: string,
body: string
) => {
const params = {
Message: body,
Subject: uuid,
TopicArn: topic
TopicArn: topic,
};

const response = {result:''};
const response = { result: '' };
try {
await snsClient.send(new PublishCommand(params));
response.result = 'Success';
} catch (e) {
} catch (e) {
response.result = `Error ${e.stack}`;
}
return Promise.resolve(response);
};

5 changes: 3 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"format": "prettier --write './**/*.tsx' --config ../.prettierrc"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.226.0",
"@aws-sdk/client-s3": "^3.592.0",
"@aws-sdk/client-sns": "^3.245.0",
"@aws-sdk/credential-providers": "^3.515.0",
"@aws-sdk/lib-storage": "^3.226.0",
Expand Down Expand Up @@ -103,6 +103,7 @@
"react-typography": "^0.16.23",
"relay-nextjs": "^0.8.0",
"relay-runtime": "^13.2.0",
"@smithy/node-http-handler": "^3.0.0",
"styled-components": "^5.3.5",
"typography": "^0.16.21",
"url": "^0.11.3",
Expand All @@ -111,7 +112,7 @@
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.226.0",
"@aws-sdk/client-s3": "^3.592.0",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@testing-library/cypress": "^10.0.1",
"@testing-library/jest-dom": "^6.4.5",
Expand Down
Loading

0 comments on commit 6545927

Please sign in to comment.