Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DQ-384 feat(contract): add support for contract impact analysis #131

Merged
merged 10 commits into from
Sep 30, 2024
Merged
1 change: 1 addition & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ jobs:
beta: Wide World Importers PE1
test-action: Wide World Importers PE1
IGNORE_MODEL_ALIAS_MATCHING: true
ATLAN_CONFIG: .atlan/config.yaml
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
node_modules/
event.json
.idea
.DS_Store
.DS_Store
.vscode/
contracts/
.atlan/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ After you've completed the configuration above, create a pull request with a cha
| `ATLAN_API_TOKEN` | Needed for authenticating API requests to the user's tenant. https://ask.atlan.com/hc/en-us/articles/8312649180049 | true |
| `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 |
| `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 |
| `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 | |

## FAQs

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
description: "Ignore model alias matching"
required: false
default: false
ATLAN_CONFIG:
description: "Atlan CLI config file location"
required: false
rittikdasgupta marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: "node16"
main: "dist/index.js"
Expand Down
33 changes: 33 additions & 0 deletions adapters/api/get-asset-classifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";

export default async function getAssetClassifications() {
var myHeaders = {
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
"Content-Type": "application/json",
};

var requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow",
};

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/meta/types/typedefs?type=classification`,
requestOptions
)
.then((e) => e.json())
.catch((err) => {
return {
error: err
}
});
if (response.error) return response

return response?.classificationDefs;
}
7 changes: 4 additions & 3 deletions adapters/api/get-classifications.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fetch from "node-fetch";
import {
ATLAN_INSTANCE_URL,
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";

export default async function getClassifications({
sendSegmentEventOfIntegration,
}) {
Expand Down Expand Up @@ -34,4 +35,4 @@ export default async function getClassifications({
});

return response?.classificationDefs;
}
}
93 changes: 93 additions & 0 deletions adapters/api/get-contract-asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
ATLAN_API_TOKEN,
ATLAN_INSTANCE_URL,
} from "../utils/get-environment-variables.js";

import fetch from "node-fetch";
import {
getErrorAssetNotFound,
} from "../templates/atlan.js";
import stringify from "json-stringify-safe";

export default async function getContractAsset({
dataset,
assetQualifiedName,
}) {
var myHeaders = {
Authorization: `Bearer ${ATLAN_API_TOKEN}`,
"Content-Type": "application/json",
};

var raw = stringify(
rittikdasgupta marked this conversation as resolved.
Show resolved Hide resolved
{
dsl: {
from: 0,
size: 1,
query: {
bool: {
must: [
{
match: {
__state: "ACTIVE"
}
},
{
term: {
qualifiedName: assetQualifiedName
}
}
]
}
}
},
attributes: [
"guid",
"name",
"description",
"userDescription",
"sourceURL",
"qualifiedName",
"connectorName",
"certificateStatus",
"certificateUpdatedBy",
"certificateUpdatedAt",
"ownerUsers",
"ownerGroups",
"classificationNames",
"meanings"
],
suppressLogs: true,
showSearchScore: false,
excludeClassifications: true,
includeClassificationNames: true,
excludeMeanings: false
}
);

var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/meta/search/indexsearch`,
requestOptions
)
.then((e) => e.json())
.catch((err) => {
return {
error: err,
comment: getErrorAssetNotFound(dataset)
}
});

if (!response?.entities?.length) {
return {
error: "asset not found",
comment: getErrorAssetNotFound(dataset),
};
}

return response.entities[0];
}
Loading
Loading