Skip to content

Commit

Permalink
fix: update from opts from param syntax in serverless.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelvesavuori committed Dec 5, 2023
1 parent 696f59b commit e8cd7a5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <guid>`
- `--shortcutIncidentLabelId 1234`
- `--param="shortcutApiToken=<guid>"`
- `--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`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
16 changes: 8 additions & 8 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
40 changes: 20 additions & 20 deletions tests/unit/application/getRequestDTO.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ 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'
});

expect(result).toMatchObject(expected);
});

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'
});
Expand All @@ -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'
});
Expand Down Expand Up @@ -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);
});
Expand All @@ -113,7 +113,7 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
from: '20221201'
from: '20231201'
})
).toThrowError(MissingRequiredInputParamsError);
});
Expand All @@ -122,7 +122,7 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
to: '20221201'
to: '20231201'
})
).toThrowError(MissingRequiredInputParamsError);
});
Expand All @@ -131,7 +131,7 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
from: '20221201',
from: '20231201',
to: '20991231'
})
).toThrowError(OutOfRangeQueryError);
Expand All @@ -141,8 +141,8 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
from: '20221201',
to: '20221231',
from: '20231201',
to: '20231231',
last: '7'
})
).toThrowError(TooManyInputParamsError);
Expand All @@ -152,8 +152,8 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
from: '20221201',
to: '20221231',
from: '20231201',
to: '20231231',
offset: -13
})
).toThrowError(InvalidOffsetError);
Expand All @@ -163,8 +163,8 @@ describe('Failure cases', () => {
expect(() =>
getRequestDTO({
repo: 'SOMEORG/SOMEREPO',
from: '20221201',
to: '20221231',
from: '20231201',
to: '20231231',
offset: 13
})
).toThrowError(InvalidOffsetError);
Expand Down

0 comments on commit e8cd7a5

Please sign in to comment.