Skip to content

Commit 7f07f7e

Browse files
Merge pull request #131 from atlanhq/DQ-384-contract-impact-analysis
DQ-384 feat(contract): add support for contract impact analysis
2 parents 44961be + cbfe6aa commit 7f07f7e

16 files changed

+7293
-862
lines changed

.github/workflows/test-action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Test Action
33
on:
44
pull_request:
55
types: [opened, edited, synchronize, reopened, closed]
6+
paths:
7+
- 'test/**'
68

79
jobs:
810
get-downstream-assets:
@@ -29,3 +31,4 @@ jobs:
2931
beta: Wide World Importers PE1
3032
test-action: Wide World Importers PE1
3133
IGNORE_MODEL_ALIAS_MATCHING: true
34+
ATLAN_CONFIG: .atlan/config.yaml

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
node_modules/
55
event.json
66
.idea
7-
.DS_Store
7+
.DS_Store
8+
.vscode/
9+
contracts/
10+
.atlan/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ After you've completed the configuration above, create a pull request with a cha
6868
| `ATLAN_API_TOKEN` | Needed for authenticating API requests to the user's tenant. https://ask.atlan.com/hc/en-us/articles/8312649180049 | true |
6969
| `DBT_ENVIRONMENT_BRANCH_MAP` | Map Github branch with specific dbt environment, if you do this - Atlan Github action will pick lineage for that specific environment from Atlan.You can provide the mapping like `branch name`: `dbt environment name`. <br><br>main: DBT-DEMO-PROD<br>beta: Wide World Importers PE1<br>test-action: Wide World Importers PE1 | false |
7070
| `IGNORE_MODEL_ALIAS_MATCHING` | By default the action checks if there's an alias defined for a model in the code and looks for the relevant asset in Atlan using that alias. You can turn off matching alias name using this variable. | false | false |
71+
| `ATLAN_CONFIG` | The Atlan CLI configuration file is typically located at `.atlan/config.yaml`. Setting the `ATLAN_CONFIG` environment variable will trigger impact analysis on Atlan Data Contracts, if included in a GitHub pull request. | false | |
7172

7273
## FAQs
7374

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
description: "Ignore model alias matching"
2020
required: false
2121
default: false
22+
ATLAN_CONFIG:
23+
description: "Atlan CLI config file location"
24+
required: false
2225
runs:
2326
using: "node16"
2427
main: "dist/index.js"
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
ATLAN_API_TOKEN,
3+
ATLAN_INSTANCE_URL,
4+
} from "../utils/get-environment-variables.js";
5+
6+
import fetch from "node-fetch";
7+
8+
export default async function getAssetClassifications() {
9+
var myHeaders = {
10+
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
11+
"Content-Type": "application/json",
12+
};
13+
14+
var requestOptions = {
15+
method: "GET",
16+
headers: myHeaders,
17+
redirect: "follow",
18+
};
19+
20+
var response = await fetch(
21+
`${ATLAN_INSTANCE_URL}/api/meta/types/typedefs?type=classification`,
22+
requestOptions
23+
)
24+
.then((e) => e.json())
25+
.catch((err) => {
26+
return {
27+
error: err
28+
}
29+
});
30+
if (response.error) return response
31+
32+
return response?.classificationDefs;
33+
}

adapters/api/get-classifications.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import fetch from "node-fetch";
21
import {
3-
ATLAN_INSTANCE_URL,
42
ATLAN_API_TOKEN,
3+
ATLAN_INSTANCE_URL,
54
} from "../utils/get-environment-variables.js";
65

6+
import fetch from "node-fetch";
7+
78
export default async function getClassifications({
89
sendSegmentEventOfIntegration,
910
}) {
@@ -34,4 +35,4 @@ export default async function getClassifications({
3435
});
3536

3637
return response?.classificationDefs;
37-
}
38+
}

adapters/api/get-contract-asset.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import {
2+
ATLAN_API_TOKEN,
3+
ATLAN_INSTANCE_URL,
4+
} from "../utils/get-environment-variables.js";
5+
6+
import fetch from "node-fetch";
7+
import {
8+
getErrorAssetNotFound,
9+
} from "../templates/atlan.js";
10+
import stringify from "json-stringify-safe";
11+
12+
export default async function getContractAsset({
13+
dataset,
14+
assetQualifiedName,
15+
}) {
16+
var myHeaders = {
17+
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
18+
"Content-Type": "application/json",
19+
};
20+
21+
var raw = stringify(
22+
{
23+
dsl: {
24+
from: 0,
25+
size: 1,
26+
query: {
27+
bool: {
28+
must: [
29+
{
30+
match: {
31+
__state: "ACTIVE"
32+
}
33+
},
34+
{
35+
term: {
36+
qualifiedName: assetQualifiedName
37+
}
38+
},
39+
{
40+
terms: {
41+
"__typeName.keyword": [
42+
"Table",
43+
"MaterialisedView",
44+
"View"
45+
]
46+
}
47+
}
48+
]
49+
}
50+
}
51+
},
52+
attributes: [
53+
"guid",
54+
"name",
55+
"description",
56+
"userDescription",
57+
"sourceURL",
58+
"qualifiedName",
59+
"connectorName",
60+
"certificateStatus",
61+
"certificateUpdatedBy",
62+
"certificateUpdatedAt",
63+
"ownerUsers",
64+
"ownerGroups",
65+
"classificationNames",
66+
"meanings"
67+
],
68+
suppressLogs: true,
69+
showSearchScore: false,
70+
excludeClassifications: true,
71+
includeClassificationNames: true,
72+
excludeMeanings: false
73+
}
74+
);
75+
76+
var requestOptions = {
77+
method: "POST",
78+
headers: myHeaders,
79+
body: raw,
80+
};
81+
82+
var response = await fetch(
83+
`${ATLAN_INSTANCE_URL}/api/meta/search/indexsearch`,
84+
requestOptions
85+
)
86+
.then((e) => e.json())
87+
.catch((err) => {
88+
return {
89+
error: err,
90+
comment: getErrorAssetNotFound(dataset)
91+
}
92+
});
93+
94+
if (!response?.entities?.length) {
95+
return {
96+
error: "asset not found",
97+
comment: getErrorAssetNotFound(dataset),
98+
};
99+
}
100+
101+
return response.entities[0];
102+
}

0 commit comments

Comments
 (0)