mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-07-28 17:33:15 +03:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ca76a4465 | |||
| 5b42d37bab | |||
| 124e6eecdb | |||
| 43c4212f70 | |||
| d4487e4dd0 | |||
| c7f47bbfcf | |||
| 11e2f12f99 | |||
| 6c64e41adc | |||
| 2f76ad395b | |||
| 307c9ae581 | |||
| b35ef16370 | |||
| 952d5d48e4 | |||
| 649323229c | |||
| 35be1a3b49 | |||
| d81a7a778d | |||
| 3a8d733522 | |||
| 1db79efc8e | |||
| 488fc1ce12 | |||
| 722353f009 | |||
| 20a8e522c2 | |||
| 35e0a09f2c | |||
| 5cb0f68cdc | |||
| 2977272bf8 | |||
| 2c1083c570 | |||
| 401e08df03 |
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
@@ -2,9 +2,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request_target:
|
||||||
branches:
|
types: [opened, reopened, synchronize]
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, closed, deleted, reopened]
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, closed, reopened]
|
||||||
|
issue_comment: # Also triggers when commenting on a PR from the conversation view
|
||||||
|
types: [created]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
name: Jira Sync
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Jira sync
|
||||||
|
steps:
|
||||||
|
- name: Check if community user
|
||||||
|
if: github.event.action == 'opened'
|
||||||
|
id: vault-team-role
|
||||||
|
run: |
|
||||||
|
TEAM=vault
|
||||||
|
ROLE="$(hub api orgs/hashicorp/teams/${TEAM}/memberships/${{ github.actor }} | jq -r '.role | select(.!=null)')"
|
||||||
|
if [[ -n ${ROLE} ]]; then
|
||||||
|
echo "Actor ${{ github.actor }} is a ${TEAM} team member, skipping ticket creation"
|
||||||
|
else
|
||||||
|
echo "Actor ${{ github.actor }} is not a ${TEAM} team member"
|
||||||
|
fi
|
||||||
|
echo "::set-output name=role::${ROLE}"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login
|
||||||
|
uses: atlassian/gajira-login@v2.0.0
|
||||||
|
env:
|
||||||
|
JIRA_BASE_URL: ${{ secrets.JIRA_SYNC_BASE_URL }}
|
||||||
|
JIRA_USER_EMAIL: ${{ secrets.JIRA_SYNC_USER_EMAIL }}
|
||||||
|
JIRA_API_TOKEN: ${{ secrets.JIRA_SYNC_API_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set ticket type
|
||||||
|
if: github.event.action == 'opened' && !steps.vault-team-role.outputs.role
|
||||||
|
id: set-ticket-type
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
|
||||||
|
echo "::set-output name=type::PR"
|
||||||
|
else
|
||||||
|
echo "::set-output name=type::ISS"
|
||||||
|
fi
|
||||||
|
- name: Create ticket
|
||||||
|
if: github.event.action == 'opened' && !steps.vault-team-role.outputs.role
|
||||||
|
uses: tomhjp/gh-action-jira-create@v0.1.3
|
||||||
|
with:
|
||||||
|
project: VAULT
|
||||||
|
issuetype: "GH Issue"
|
||||||
|
summary: "${{ github.event.repository.name }} [${{ steps.set-ticket-type.outputs.type }} #${{ github.event.issue.number || github.event.pull_request.number }}]: ${{ github.event.issue.title || github.event.pull_request.title }}"
|
||||||
|
description: "${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created from GitHub Action for ${{ github.event.issue.html_url || github.event.pull_request.html_url }} from ${{ github.actor }}_"
|
||||||
|
# customfield_10089 is Issue Link custom field
|
||||||
|
# customfield_10091 is team custom field
|
||||||
|
extraFields: '{"fixVersions": [{"name": "TBD"}], "customfield_10091": ["ecosystem"], "customfield_10089": "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"}'
|
||||||
|
|
||||||
|
- name: Search
|
||||||
|
if: github.event.action != 'opened'
|
||||||
|
id: search
|
||||||
|
uses: tomhjp/gh-action-jira-search@v0.2.1
|
||||||
|
with:
|
||||||
|
# cf[10089] is Issue Link custom field
|
||||||
|
jql: 'project = "VAULT" and issuetype = "GH Issue" and cf[10089]="${{ github.event.issue.html_url || github.event.pull_request.html_url }}"'
|
||||||
|
|
||||||
|
- name: Sync comment
|
||||||
|
if: github.event.action == 'created' && steps.search.outputs.issue
|
||||||
|
uses: tomhjp/gh-action-jira-comment@v0.1.0
|
||||||
|
with:
|
||||||
|
issue: ${{ steps.search.outputs.issue }}
|
||||||
|
comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}"
|
||||||
|
|
||||||
|
- name: Close ticket
|
||||||
|
if: (github.event.action == 'closed' || github.event.action == 'deleted') && steps.search.outputs.issue
|
||||||
|
uses: atlassian/gajira-transition@v2.0.1
|
||||||
|
with:
|
||||||
|
issue: ${{ steps.search.outputs.issue }}
|
||||||
|
transition: Done
|
||||||
|
|
||||||
|
- name: Reopen ticket
|
||||||
|
if: github.event.action == 'reopened' && steps.search.outputs.issue
|
||||||
|
uses: atlassian/gajira-transition@v2.0.1
|
||||||
|
with:
|
||||||
|
issue: ${{ steps.search.outputs.issue }}
|
||||||
|
transition: "To Do"
|
||||||
@@ -1,5 +1,27 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 2.1.0 (October 6th, 2020)
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Added `exportToken` to share the Vault token as an environment variable [GH-127](https://github.com/hashicorp/vault-action/pull/127)
|
||||||
|
|
||||||
|
Security:
|
||||||
|
* `action/core` updated to 1.2.6 to address minor CVE [GH-130](https://github.com/hashicorp/vault-action/pull/130)
|
||||||
|
|
||||||
|
## 2.0.1 (September 15th, 2020)
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
* bump node-fetch from 2.6.0 to 2.6.1 [GH-110](https://github.com/hashicorp/vault-action/pull/110)
|
||||||
|
* bump lodash from 4.17.15 to 4.17.20 [GH-111](https://github.com/hashicorp/vault-action/pull/111)
|
||||||
|
* bump npm from 6.14.4 to 6.14.8 [GH-112](https://github.com/hashicorp/vault-action/pull/112)
|
||||||
|
* bump @types/jest from 25.1.5 to 26.0.13 [GH-114](https://github.com/hashicorp/vault-action/pull/114)
|
||||||
|
* bump @actions/core from 1.2.3 to 1.2.5 [GH-115](https://github.com/hashicorp/vault-action/pull/115)
|
||||||
|
* bump jest from 25.2.7 to 26.4.2 [GH-116](https://github.com/hashicorp/vault-action/pull/116)
|
||||||
|
* bump got from 11.5.1 to 11.6.2 [GH-117](https://github.com/hashicorp/vault-action/pull/117)
|
||||||
|
* update jsonata to version 1.8.3 [GH-118](https://github.com/hashicorp/vault-action/pull/118)
|
||||||
|
* update dev dependencies [GH-119](https://github.com/hashicorp/vault-action/pull/119)
|
||||||
|
* update kind-of to version 6.0.3 [GH-120](https://github.com/hashicorp/vault-action/pull/120)
|
||||||
|
|
||||||
## 2.0.0 (August 24th, 2020)
|
## 2.0.0 (August 24th, 2020)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# ...
|
# ...
|
||||||
- name: Import Secrets
|
- name: Import Secrets
|
||||||
uses: hashicorp/vault-action
|
uses: hashicorp/vault-action@v2.0.1
|
||||||
with:
|
with:
|
||||||
url: https://vault.mycompany.com:8200
|
url: https://vault.mycompany.com:8200
|
||||||
token: ${{ secrets.VaultToken }}
|
token: ${{ secrets.VaultToken }}
|
||||||
@@ -250,6 +250,7 @@ Here are all the inputs available through `with`:
|
|||||||
| `authPayload` | The JSON payload to be sent to Vault when using a custom authentication method. | | |
|
| `authPayload` | The JSON payload to be sent to Vault when using a custom authentication method. | | |
|
||||||
| `extraHeaders` | A string of newline separated extra headers to include on every request. | | |
|
| `extraHeaders` | A string of newline separated extra headers to include on every request. | | |
|
||||||
| `exportEnv` | Whether or not export secrets as environment variables. | `true` | |
|
| `exportEnv` | Whether or not export secrets as environment variables. | `true` | |
|
||||||
|
| `exportToken` | Whether or not export Vault token as environment variables (i.e VAULT_TOKEN). | `false` | |
|
||||||
| `caCertificate` | Base64 encoded CA certificate the server certificate was signed with. | | |
|
| `caCertificate` | Base64 encoded CA certificate the server certificate was signed with. | | |
|
||||||
| `clientCertificate` | Base64 encoded client certificate the action uses to authenticate with Vault when mTLS is enabled. | | |
|
| `clientCertificate` | Base64 encoded client certificate the action uses to authenticate with Vault when mTLS is enabled. | | |
|
||||||
| `clientKey` | Base64 encoded client key the action uses to authenticate with Vault when mTLS is enabled. | | |
|
| `clientKey` | Base64 encoded client key the action uses to authenticate with Vault when mTLS is enabled. | | |
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ inputs:
|
|||||||
description: 'Whether or not export secrets as environment variables.'
|
description: 'Whether or not export secrets as environment variables.'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
exportToken:
|
||||||
|
description: 'Whether or not export Vault token as environment variables.'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
caCertificate:
|
caCertificate:
|
||||||
description: 'Base64 encoded CA certificate to verify the Vault server certificate.'
|
description: 'Base64 encoded CA certificate to verify the Vault server certificate.'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
Vendored
+704
-417
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@ describe('integration', () => {
|
|||||||
},
|
},
|
||||||
json: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
otherSecret: 'OTHERSUPERSECRET',
|
"other-Secret-dash": 'OTHERSUPERSECRET',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -100,7 +100,7 @@ describe('integration', () => {
|
|||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
json: {
|
json: {
|
||||||
otherSecret: 'OTHERCUSTOMSECRET',
|
"other-Secret-dash": 'OTHERCUSTOMSECRET',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -140,18 +140,18 @@ describe('integration', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('get nested secret', async () => {
|
it('get nested secret', async () => {
|
||||||
mockInput('secret/data/nested/test otherSecret');
|
mockInput(`secret/data/nested/test "other-Secret-dash"`);
|
||||||
|
|
||||||
await exportSecrets();
|
await exportSecrets();
|
||||||
|
|
||||||
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET');
|
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERSUPERSECRET');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('get multiple secrets', async () => {
|
it('get multiple secrets', async () => {
|
||||||
mockInput(`
|
mockInput(`
|
||||||
secret/data/test secret ;
|
secret/data/test secret ;
|
||||||
secret/data/test secret | NAMED_SECRET ;
|
secret/data/test secret | NAMED_SECRET ;
|
||||||
secret/data/nested/test otherSecret ;`);
|
secret/data/nested/test "other-Secret-dash" ;`);
|
||||||
|
|
||||||
await exportSecrets();
|
await exportSecrets();
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ describe('integration', () => {
|
|||||||
|
|
||||||
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
|
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
|
||||||
expect(core.exportVariable).toBeCalledWith('NAMED_SECRET', 'SUPERSECRET');
|
expect(core.exportVariable).toBeCalledWith('NAMED_SECRET', 'SUPERSECRET');
|
||||||
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET');
|
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERSUPERSECRET');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('leading slash kvv2', async () => {
|
it('leading slash kvv2', async () => {
|
||||||
@@ -179,11 +179,11 @@ describe('integration', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('get nested secret from K/V v1', async () => {
|
it('get nested secret from K/V v1', async () => {
|
||||||
mockInput('secret-kv1/nested/test otherSecret');
|
mockInput('secret-kv1/nested/test "other-Secret-dash"');
|
||||||
|
|
||||||
await exportSecrets();
|
await exportSecrets();
|
||||||
|
|
||||||
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERCUSTOMSECRET');
|
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('leading slash kvv1', async () => {
|
it('leading slash kvv1', async () => {
|
||||||
|
|||||||
Generated
+3283
-2438
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -52,11 +52,11 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.2.3",
|
||||||
"@types/got": "^9.6.9",
|
"@types/got": "^9.6.11",
|
||||||
"@types/jest": "^25.1.3",
|
"@types/jest": "^26.0.13",
|
||||||
"@zeit/ncc": "^0.22.0",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"jest": "^25.1.0",
|
"jest": "^26.4.2",
|
||||||
"jest-when": "^2.7.0",
|
"jest-when": "^2.7.2",
|
||||||
"semantic-release": "^17.0.4"
|
"semantic-release": "^17.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-4
@@ -12,6 +12,7 @@ async function exportSecrets() {
|
|||||||
const vaultNamespace = core.getInput('namespace', { required: false });
|
const vaultNamespace = core.getInput('namespace', { required: false });
|
||||||
const extraHeaders = parseHeadersInput('extraHeaders', { required: false });
|
const extraHeaders = parseHeadersInput('extraHeaders', { required: false });
|
||||||
const exportEnv = core.getInput('exportEnv', { required: false }) != 'false';
|
const exportEnv = core.getInput('exportEnv', { required: false }) != 'false';
|
||||||
|
const exportToken = (core.getInput('exportToken', { required: false }) || 'false').toLowerCase() != 'false';
|
||||||
|
|
||||||
const secretsInput = core.getInput('secrets', { required: true });
|
const secretsInput = core.getInput('secrets', { required: true });
|
||||||
const secretRequests = parseSecretsInput(secretsInput);
|
const secretRequests = parseSecretsInput(secretsInput);
|
||||||
@@ -60,6 +61,11 @@ async function exportSecrets() {
|
|||||||
defaultOptions.headers['X-Vault-Token'] = vaultToken;
|
defaultOptions.headers['X-Vault-Token'] = vaultToken;
|
||||||
const client = got.extend(defaultOptions);
|
const client = got.extend(defaultOptions);
|
||||||
|
|
||||||
|
if (exportToken === true) {
|
||||||
|
command.issue('add-mask', vaultToken);
|
||||||
|
core.exportVariable('VAULT_TOKEN', `${vaultToken}`);
|
||||||
|
}
|
||||||
|
|
||||||
const requests = secretRequests.map(request => {
|
const requests = secretRequests.map(request => {
|
||||||
const { path, selector } = request;
|
const { path, selector } = request;
|
||||||
return request;
|
return request;
|
||||||
@@ -124,12 +130,13 @@ function parseSecretsInput(secretsInput) {
|
|||||||
throw Error(`You must provide a valid path and key. Input: "${secret}"`);
|
throw Error(`You must provide a valid path and key. Input: "${secret}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [path, selector] = pathParts;
|
const [path, selectorQuoted] = pathParts;
|
||||||
|
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
const selectorAst = jsonata(selector).ast();
|
const selectorAst = jsonata(selectorQuoted).ast();
|
||||||
|
const selector = selectorQuoted.replace(new RegExp('"', 'g'), '');
|
||||||
|
|
||||||
if ((selectorAst.type !== "path" || selectorAst.steps[0].stages) && !outputVarName) {
|
if ((selectorAst.type !== "path" || selectorAst.steps[0].stages) && selectorAst.type !== "string" && !outputVarName) {
|
||||||
throw Error(`You must provide a name for the output key when using json selectors. Input: "${secret}"`);
|
throw Error(`You must provide a name for the output key when using json selectors. Input: "${secret}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +163,7 @@ function parseSecretsInput(secretsInput) {
|
|||||||
*/
|
*/
|
||||||
function normalizeOutputKey(dataKey, isEnvVar = false) {
|
function normalizeOutputKey(dataKey, isEnvVar = false) {
|
||||||
let outputKey = dataKey
|
let outputKey = dataKey
|
||||||
.replace('.', '__').replace(/[^\p{L}\p{N}_-]/gu, '');
|
.replace('.', '__').replace(new RegExp('-', 'g'), '').replace(/[^\p{L}\p{N}_-]/gu, '');
|
||||||
if (isEnvVar) {
|
if (isEnvVar) {
|
||||||
outputKey = outputKey.toUpperCase();
|
outputKey = outputKey.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,12 @@ describe('exportSecrets', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mockExportToken(doExport) {
|
||||||
|
when(core.getInput)
|
||||||
|
.calledWith('exportToken')
|
||||||
|
.mockReturnValueOnce(doExport);
|
||||||
|
}
|
||||||
|
|
||||||
it('simple secret retrieval', async () => {
|
it('simple secret retrieval', async () => {
|
||||||
mockInput('test key');
|
mockInput('test key');
|
||||||
mockVaultData({
|
mockVaultData({
|
||||||
@@ -257,4 +263,35 @@ describe('exportSecrets', () => {
|
|||||||
expect(core.exportVariable).toBeCalledWith('KEY__VALUE', '1');
|
expect(core.exportVariable).toBeCalledWith('KEY__VALUE', '1');
|
||||||
expect(core.setOutput).toBeCalledWith('key__value', '1');
|
expect(core.setOutput).toBeCalledWith('key__value', '1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('export Vault token', async () => {
|
||||||
|
mockInput('test key');
|
||||||
|
mockVaultData({
|
||||||
|
key: 1
|
||||||
|
});
|
||||||
|
mockExportToken("true")
|
||||||
|
|
||||||
|
await exportSecrets();
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledWith('VAULT_TOKEN', 'EXAMPLE');
|
||||||
|
expect(core.exportVariable).toBeCalledWith('KEY', '1');
|
||||||
|
expect(core.setOutput).toBeCalledWith('key', '1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('not export Vault token', async () => {
|
||||||
|
mockInput('test key');
|
||||||
|
mockVaultData({
|
||||||
|
key: 1
|
||||||
|
});
|
||||||
|
mockExportToken("false")
|
||||||
|
|
||||||
|
await exportSecrets();
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledTimes(1);
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledWith('KEY', '1');
|
||||||
|
expect(core.setOutput).toBeCalledWith('key', '1');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-2
@@ -38,7 +38,9 @@ async function getSecrets(secretRequests, client) {
|
|||||||
body = result.body;
|
body = result.body;
|
||||||
responseCache.set(requestPath, body);
|
responseCache.set(requestPath, body);
|
||||||
}
|
}
|
||||||
|
if (!selector.match(/.*[\.].*/)) {
|
||||||
|
selector = '"' + selector + '"'
|
||||||
|
}
|
||||||
selector = "data." + selector
|
selector = "data." + selector
|
||||||
body = JSON.parse(body)
|
body = JSON.parse(body)
|
||||||
if (body.data["data"] != undefined) {
|
if (body.data["data"] != undefined) {
|
||||||
@@ -64,7 +66,7 @@ function selectData(data, selector) {
|
|||||||
const ata = jsonata(selector);
|
const ata = jsonata(selector);
|
||||||
let result = JSON.stringify(ata.evaluate(data));
|
let result = JSON.stringify(ata.evaluate(data));
|
||||||
// Compat for custom engines
|
// Compat for custom engines
|
||||||
if (!result && ata.ast().type === "path" && ata.ast()['steps'].length === 1 && selector !== 'data' && 'data' in data) {
|
if (!result && ((ata.ast().type === "path" && ata.ast()['steps'].length === 1) || ata.ast().type === "string") && selector !== 'data' && 'data' in data) {
|
||||||
result = JSON.stringify(jsonata(`data.${selector}`).evaluate(data));
|
result = JSON.stringify(jsonata(`data.${selector}`).evaluate(data));
|
||||||
} else if (!result) {
|
} else if (!result) {
|
||||||
throw Error(`Unable to retrieve result for ${selector}. No match data was found. Double check your Key or Selector.`);
|
throw Error(`Unable to retrieve result for ${selector}. No match data was found. Double check your Key or Selector.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user