Skip to content

Commit bd8494b

Browse files
authored
Upgrade 0.15 (#8)
Update to use data caterer 0.15.2, add in HTTP example using OpenAPI spec, update JSON schema with new options
1 parent 5b54228 commit bd8494b

16 files changed

Lines changed: 860 additions & 236 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ can be found below.
271271
| configuration_file | File path to configuration file | `insta-integration.yaml` |
272272
| insta_infra_folder | Folder path to insta-infra ([this repository](https://github.com/data-catering/insta-infra)) | `${HOME}/.insta-integration/insta-infra` |
273273
| base_folder | Folder path to use for execution files | `${HOME}/.insta-integration` |
274-
| data_caterer_version | Version of data-caterer Docker image | `0.14.5` |
274+
| data_caterer_version | Version of data-caterer Docker image | `0.15.2` |
275275
| data_caterer_user | User for data-caterer. If you don't have one yet, [create one here](https://data.catering/latest/get-started/quick-start/#get-token) | <empty> |
276276
| data_caterer_token | Token for data-caterer. If you don't have one yet, [create one here](https://data.catering/latest/get-started/quick-start/#get-token) | <empty> |
277277

@@ -295,7 +295,7 @@ jobs:
295295
configuration_file: my/custom/folder/insta-integration.yaml
296296
insta_infra_folder: insta-infra/folder
297297
base_folder: execution/folder
298-
data_caterer_version: 0.14.5
298+
data_caterer_version: 0.15.2
299299
data_caterer_user: ${{ secrets.DATA_CATERER_USER }}
300300
data_caterer_token: ${{ secrets.DATA_CATERER_TOKEN }}
301301
```

__tests__/insta-integration.test.js

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ describe('extractRelationships', () => {
373373
currentPlan
374374
)
375375
}).toThrow(
376-
'Relationship should follow pattern: <generation name>.<field name>'
376+
'Relationship should follow pattern: <generation name>||<fields> or <data source>||<generation name>||<fields>, relationship=c'
377377
)
378378
})
379379

380380
it('should throw an error when relationship is defined without generation', () => {
381381
testConfig = {
382382
relationship: {
383-
'service.field': ['child.field']
383+
'service||field': ['child||field']
384384
}
385385
}
386386
expect(() => {
@@ -395,7 +395,7 @@ describe('extractRelationships', () => {
395395
it('should correctly extract relationships and update currentPlan', () => {
396396
testConfig = {
397397
relationship: {
398-
'parentTask.id': ['child1Task.parent_id', 'child2Task.parent_id']
398+
'parentTask||id': ['child1Task||parent_id', 'child2Task||parent_id']
399399
},
400400
generation: {
401401
parent: [{ name: 'parentTask' }],
@@ -438,11 +438,56 @@ describe('extractRelationships', () => {
438438
])
439439
})
440440

441+
it('should correctly extract relationships with 3 part format and update currentPlan', () => {
442+
testConfig = {
443+
relationship: {
444+
'http||POST/pet||body.id': [
445+
'http||GET/pet/{id}||pathParamid',
446+
'http||DELETE/pet/{id}||pathParamid'
447+
]
448+
},
449+
generation: {
450+
http: [{ name: 'parentTask' }]
451+
}
452+
}
453+
generationTaskToServiceMapping = {
454+
parentTask: 'http'
455+
}
456+
457+
extractRelationships(
458+
testConfig,
459+
generationTaskToServiceMapping,
460+
currentPlan
461+
)
462+
463+
expect(currentPlan.sinkOptions.foreignKeys).toEqual([
464+
{
465+
source: {
466+
dataSource: 'http',
467+
step: 'POST/pet',
468+
fields: ['body.id']
469+
},
470+
generate: [
471+
{
472+
dataSource: 'http',
473+
step: 'GET/pet/{id}',
474+
fields: ['pathParamid']
475+
},
476+
{
477+
dataSource: 'http',
478+
step: 'DELETE/pet/{id}',
479+
fields: ['pathParamid']
480+
}
481+
]
482+
}
483+
])
484+
})
485+
441486
it('should handle multiple relationships', () => {
442487
testConfig = {
443488
relationship: {
444-
'userTask.id': ['orderTask.user_id'],
445-
'productTask.id': ['orderTask.product_id']
489+
'userTask||id': ['orderTask||user_id'],
490+
'productTask||id': ['orderTask||product_id']
446491
},
447492
generation: {
448493
user: [{ name: 'userTask' }],

__tests__/main.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('getDataCatererVersion', () => {
3636
})
3737

3838
it('returns the default data caterer version if not provided', () => {
39-
expect(getDataCatererVersion('')).toBe('0.14.5')
39+
expect(getDataCatererVersion('')).toBe('0.15.2')
4040
})
4141
})
4242

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ inputs:
1818
default: '/home/runner/work'
1919
data_caterer_version:
2020
description: 'Version of data-caterer Docker image'
21-
default: '0.14.5'
21+
default: '0.15.2'
2222
data_caterer_user:
2323
description: 'User for data-caterer'
2424
default: ''

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 39 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/http.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
- name: httpbin
3+
run:
4+
- command: echo hello
5+
test:
6+
env:
7+
ENABLE_GENERATE_PLAN_AND_TASKS: 'true'
8+
relationship:
9+
http||POST/pets||body.id:
10+
- http||GET/pets/{id}||pathParamid
11+
- http||DELETE/pets/{id}||pathParamid
12+
generation:
13+
http:
14+
- options:
15+
metadataSourceType: openApi
16+
schemaLocation: https://raw.githubusercontent.com/data-catering/data-caterer-example/refs/heads/main/docker/mount/http/petstore.json
17+
count:
18+
records: 5

example/postgres-to-csv.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ run:
99
mount:
1010
- ${PWD}/example/my-app/shared/generated:/opt/app/shared/generated
1111
relationship:
12-
postgres_balance.account_number:
13-
- postgres_transaction.account_number
12+
postgres_balance||account_number:
13+
- postgres_transaction||account_number
1414
generation:
1515
postgres:
1616
- name: postgres_transaction
@@ -48,6 +48,10 @@ run:
4848
path: /opt/app/shared/generated/balances.csv
4949
header: true
5050
validations:
51+
- field: account_number
52+
validation:
53+
- type: 'null'
54+
negate: true
5155
- expr: ISNOTNULL(account_number)
5256
- aggType: count
5357
aggExpr: count == 1000

example/sample-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ run: #how to run your app/job, can run multiple, run in order
1010
APP_VERSION: 1.3.1
1111
test: #using data-caterer, generate and validate data
1212
relationship:
13-
kafka_accounts.account_id:
14-
- kafka_transactions.account_id
13+
kafka_accounts||account_id:
14+
- kafka_transactions||account_id
1515
generation:
1616
kafka: #name matches with service from above or could point to application (i.e. REST API)
1717
- name: kafka_accounts

0 commit comments

Comments
 (0)