Skip to content

Commit

Permalink
Merge pull request #130 from atlanhq/DQ-384-contract-impact-analysis
Browse files Browse the repository at this point in the history
DQ-384 feat(contract): add support for contract impact analysis
  • Loading branch information
Jaagrav authored Sep 25, 2024
2 parents f16c1c6 + 2fbf88a commit 67d0b1a
Show file tree
Hide file tree
Showing 18 changed files with 7,341 additions and 876 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/github-actions-pr-jira_yml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: GitHub-Jira Link Action
run-name: ${{ github.actor }} is ensuring Jira ID is present in PR title
on:
pull_request:
types: [opened, edited, synchronize, reopened]
branches: [main, staging, develop]

jobs:
Enforce-GitHub-Jira-Link-Action:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.ref != 'staging' && github.event.pull_request.head.ref != 'develop' && github.event.pull_request.head.ref != 'main' }}
steps:
- name: Enforce Pull Request Title includes Jira Issue Key
uses: ryanvade/[email protected]

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
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(
{
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

0 comments on commit 67d0b1a

Please sign in to comment.