From e8cd7a51d18dede60136563bfc9395f13aca5ad3 Mon Sep 17 00:00:00 2001 From: Mikael Vesavuori Date: Tue, 5 Dec 2023 14:12:21 +0100 Subject: [PATCH] fix: update from opts from param syntax in serverless.yml --- README.md | 8 ++-- package-lock.json | 4 +- package.json | 2 +- serverless.yml | 16 ++++---- tests/unit/application/getRequestDTO.test.ts | 40 ++++++++++---------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 40dfa79..997064e 100644 --- a/README.md +++ b/README.md @@ -158,17 +158,17 @@ Note that it will attempt to connect to a database, so deploy the application an ## Deployment -First make sure that you have a fallback value for your AWS account number in `serverless.yml`, for example: `awsAccountNumber: ${opt:awsAccountNumber, '123412341234'}` or that you set the deployment script to use the flag, for example `npx sls deploy --awsAccountNumber 123412341234`. +First make sure that you have a fallback value for your AWS account number in `serverless.yml`, for example: `awsAccountNumber: ${param:awsAccountNumber, '123412341234'}` or that you set the deployment script to use the flag, for example `npx sls deploy --param="awsAccountNumber=123412341234"`. If using Shortcut for ticket managmenet you must pass additional options. [Refer to the Shortcut Configuration section](./README.md#Shortcut.com). -- `--shortcutApiToken ` -- `--shortcutIncidentLabelId 1234` +- `--param="shortcutApiToken="` +- `--param="shortcutIncidentLabelId=1234"` For example: ```cmd -npx sls deploy --awsAccountNumber 123412341234 --shortcutApiToken 1232-1234-1234 --shortcutIncidentLabelId 1234 +npx sls deploy --param="awsAccountNumber=123412341234" --param="shortcutApiToken=1232-1234-1234" --param="shortcutIncidentLabelId=1234" ``` Then you can deploy with `npm run deploy`. diff --git a/package-lock.json b/package-lock.json index 6efa83b..8c558f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dorametrix", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dorametrix", - "version": "3.0.1", + "version": "3.0.2", "license": "MIT", "dependencies": { "@aws-sdk/client-dynamodb": "3", diff --git a/package.json b/package.json index 755e8fd..dec20d6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dorametrix", "description": "Dorametrix is a Node.js-based service that helps you calculate your DORA metrics, by inferring your metrics from events you can create manually or with webhooks", - "version": "3.0.1", + "version": "3.0.2", "author": "Mikael Vesavuori", "license": "MIT", "keywords": [ diff --git a/serverless.yml b/serverless.yml index b8cdd48..ec3cb1a 100644 --- a/serverless.yml +++ b/serverless.yml @@ -8,7 +8,7 @@ provider: region: ${opt:region, 'eu-north-1'} memorySize: ${opt:memory, 1024} timeout: ${opt:timeout, 10} - logRetentionInDays: ${opt:logRetentionInDays, 7} + logRetentionInDays: ${param:logRetentionInDays, 7} versionFunctions: false httpApi: cors: true @@ -49,15 +49,15 @@ package: custom: config: - apiKey: ${opt:apiKey, '82490d5a-1950-4527-ab2f-5c984c861462'} # Add your desired valid API key here or use the default - awsAccountNumber: ${opt:awsAccountNumber, '123412341234'} # Set this to your value if you want to use a fallback value - maxDateRange: ${opt:maxDateRange, '30'} - maxLifeInDays: ${opt:maxLifeInDays, '90'} + apiKey: ${param:apiKey, '82490d5a-1950-4527-ab2f-5c984c861462'} # Add your desired valid API key here or use the default + awsAccountNumber: ${param:awsAccountNumber, '123412341234'} # Set this to your value if you want to use a fallback value + maxDateRange: ${param:maxDateRange, '30'} + maxLifeInDays: ${param:maxLifeInDays, '90'} tableName: ${self:service}-${self:provider.stage} shortcut: - shortcutApiToken: ${opt:shortcutApiToken, ''} # Set this to your value if you want to use a fallback value - shortcutIncidentLabelId: ${opt:shortcutIncidentLabelId, '0'} # Set this to your value if you want to use a fallback value - shortcutRepoName: ${opt:shortcutRepoName, 'unknown'} + shortcutApiToken: ${param:shortcutApiToken, ''} # Set this to your value if you want to use a fallback value + shortcutIncidentLabelId: ${param:shortcutIncidentLabelId, '0'} # Set this to your value if you want to use a fallback value + shortcutRepoName: ${param:shortcutRepoName, 'unknown'} aws: databaseArn: arn:aws:dynamodb:${aws:region}:${self:custom.config.awsAccountNumber}:table/${self:custom.config.tableName} apiGatewayCachingTtl: diff --git a/tests/unit/application/getRequestDTO.test.ts b/tests/unit/application/getRequestDTO.test.ts index e355f18..361a921 100644 --- a/tests/unit/application/getRequestDTO.test.ts +++ b/tests/unit/application/getRequestDTO.test.ts @@ -15,11 +15,11 @@ const getRandomInteger = () => Math.floor(Math.random() * 15) + 1; describe('Success cases', () => { describe('Static set period', () => { test('It should create a request DTO for a set period', () => { - const expected = { repo: 'SOMEORG/SOMEREPO', from: '1669852800', to: '1672531199' }; + const expected = { repo: 'SOMEORG/SOMEREPO', from: '1701388800', to: '1701734399' }; const result = getRequestDTO({ - from: '20221201', - to: '20221231', + from: '20231201', + to: '20231204', repo: 'SOMEORG/SOMEREPO' }); @@ -27,11 +27,11 @@ describe('Success cases', () => { }); test('It should create a request DTO for a set period with a negative offset', () => { - const expected = { repo: 'SOMEORG/SOMEREPO', from: '1669834800', to: '1672513199' }; + const expected = { repo: 'SOMEORG/SOMEREPO', from: '1698778800', to: '1701370799' }; const result = getRequestDTO({ - from: '20221201', - to: '20221231', + from: '20231101', + to: '20231130', offset: '-5', repo: 'SOMEORG/SOMEREPO' }); @@ -40,11 +40,11 @@ describe('Success cases', () => { }); test('It should create a request DTO for a set period with a positive offset', () => { - const expected = { repo: 'SOMEORG/SOMEREPO', from: '1669870800', to: '1672549199' }; + const expected = { repo: 'SOMEORG/SOMEREPO', from: '1700456400', to: '1701406799' }; const result = getRequestDTO({ - from: '20221201', - to: '20221231', + from: '20231120', + to: '20231130', offset: '5', repo: 'SOMEORG/SOMEREPO' }); @@ -103,8 +103,8 @@ describe('Failure cases', () => { test('It should throw a MissingRepoNameError error if no repo name is present', () => { expect(() => getRequestDTO({ - from: '20221201', - to: '20221231' + from: '20231201', + to: '20231231' }) ).toThrowError(MissingRepoNameError); }); @@ -113,7 +113,7 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - from: '20221201' + from: '20231201' }) ).toThrowError(MissingRequiredInputParamsError); }); @@ -122,7 +122,7 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - to: '20221201' + to: '20231201' }) ).toThrowError(MissingRequiredInputParamsError); }); @@ -131,7 +131,7 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - from: '20221201', + from: '20231201', to: '20991231' }) ).toThrowError(OutOfRangeQueryError); @@ -141,8 +141,8 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - from: '20221201', - to: '20221231', + from: '20231201', + to: '20231231', last: '7' }) ).toThrowError(TooManyInputParamsError); @@ -152,8 +152,8 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - from: '20221201', - to: '20221231', + from: '20231201', + to: '20231231', offset: -13 }) ).toThrowError(InvalidOffsetError); @@ -163,8 +163,8 @@ describe('Failure cases', () => { expect(() => getRequestDTO({ repo: 'SOMEORG/SOMEREPO', - from: '20221201', - to: '20221231', + from: '20231201', + to: '20231231', offset: 13 }) ).toThrowError(InvalidOffsetError);