Skip to content

Commit

Permalink
Merge pull request #100 from atlanhq/feat/environment-mapping
Browse files Browse the repository at this point in the history
fix: comment structure and code improvements
  • Loading branch information
Jaagrav authored May 14, 2023
2 parents d087f04 + 8c8b8ea commit 0bcbda8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/api/get-asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import fetch from "node-fetch";
import {sendSegmentEvent} from "./index.js";
import stringify from 'json-stringify-safe';
import {getAPIToken, getInstanceUrl} from "../utils/index.js";
import core from "@actions/core";
import {context} from "@actions/github";
import {getEnvironments} from "../utils/get-environment-variables.js";

const ATLAN_INSTANCE_URL =
getInstanceUrl();
const ATLAN_API_TOKEN =
getAPIToken();

export default async function getAsset({name}) {
const environments = core.getInput('DBT_ENVIRONMENT_BRANCH_MAP') ?
core.getInput('DBT_ENVIRONMENT_BRANCH_MAP').trim()?.split('\n')?.map(i => i.split(':').map(i => i.trim())) : []
const environments = getEnvironments();

let environment = null;
for (const [baseBranchName, environmentName] of environments) {
Expand Down
9 changes: 4 additions & 5 deletions src/utils/create-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ export default async function renderDownstreamAssetsComment(
asset.attributes?.certificateStatus
? getCertificationImage(asset.attributes.certificateStatus)
: ""
}`

const downstreamTable = `<details><summary><b>${downstreamAssets.length} downstream assets 👇</b></summary><br/>
}
Materialised asset: ${getConnectorImage(materialisedAsset.attributes.connectorName)} [${
materialisedAsset.attributes.name
}](${ATLAN_INSTANCE_URL}/assets/${materialisedAsset.guid}/overview?utm_source=dbt_github_action) ${
materialisedAsset.attributes?.certificateStatus
? getCertificationImage(materialisedAsset.attributes.certificateStatus)
: ""
} | Environment Name: \`${materialisedAsset.attributes.assetDbtEnvironmentName}\` | Project Name: \`${materialisedAsset.attributes.assetDbtProjectName}\`
} | Environment Name: \`${materialisedAsset.attributes.assetDbtEnvironmentName}\` | Project Name: \`${materialisedAsset.attributes.assetDbtProjectName}\``

const downstreamTable = `<details><summary><b>${downstreamAssets.length} downstream assets 👇</b></summary><br/>
Name | Type | Description | Owners | Terms | Classifications | Source URL
--- | --- | --- | --- | --- | --- | ---
Expand Down
4 changes: 4 additions & 0 deletions src/utils/get-environment-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ export const getAPIToken = () => {
if (ATLAN_API_TOKEN) return ATLAN_API_TOKEN;
return core.getInput("ATLAN_API_TOKEN");
}
export const getEnvironments = () => {
return core.getInput('DBT_ENVIRONMENT_BRANCH_MAP') ?
core.getInput('DBT_ENVIRONMENT_BRANCH_MAP').trim()?.split('\n')?.map(i => i.split(':').map(i => i.trim())) : []
}
export const isIgnoreModelAliasMatching = () => core.getInput("IGNORE_MODEL_ALIAS_MATCHING") === "true";

0 comments on commit 0bcbda8

Please sign in to comment.