5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-07 15:16:56 +00:00

update require got to import got

This commit is contained in:
JM Faircloth 2024-03-08 10:11:09 -06:00
parent a727ce205a
commit cd38d43a7a
12 changed files with 34 additions and 21 deletions

View file

@ -48,14 +48,26 @@ jobs:
token: testtoken token: testtoken
secrets: | secrets: |
secret/data/test-json-string jsonString; secret/data/test-json-string jsonString;
secret/data/test-json-data jsonData;
- name: Check Secrets - uses: actions/github-script@v7
run: | with:
touch secrets.json github-token: "foobar"
echo "${{ steps.import-secrets.outputs.jsonString }}" >> secrets.json script: |
const { JSONSTRING, JSONDATA } = process.env
- name: Check json file format console.log(`string ${JSONSTRING}`)
run: | console.log(`data ${JSONDATA}`)
echo const str = JSONDATA
cat secrets.json
jq -c . < secrets.json let valid = true
try {
JSON.parse(str)
} catch (e) {
valid = false
}
if (valid) {
console.log("valid json")
} else {
console.log("not valid json")
}

View file

@ -2,7 +2,7 @@ jest.mock('@actions/core');
jest.mock('@actions/core/lib/command'); jest.mock('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import got from 'got';
const { when } = require('jest-when'); const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action'); const { exportSecrets } = require('../../src/action');

View file

@ -2,7 +2,7 @@ jest.mock('@actions/core');
jest.mock('@actions/core/lib/command'); jest.mock('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import got from 'got';
const { when } = require('jest-when'); const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action'); const { exportSecrets } = require('../../src/action');

View file

@ -8,7 +8,7 @@ const {
publicRsaKey publicRsaKey
} = require('./rsa_keys'); } = require('./rsa_keys');
const got = require('got'); import got from 'got';
const { when } = require('jest-when'); const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action'); const { exportSecrets } = require('../../src/action');

View file

@ -2,7 +2,7 @@ jest.mock('@actions/core');
jest.mock('@actions/core/lib/command'); jest.mock('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import got from 'got';
const { when } = require('jest-when'); const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action'); const { exportSecrets } = require('../../src/action');

View file

@ -1,4 +1,4 @@
const got = require('got'); import got from 'got';
const core = require('@actions/core'); const core = require('@actions/core');
const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`; const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;

View file

@ -1,4 +1,4 @@
const got = require('got'); import got from 'got';
const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`; const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;
const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.VAULT_TOKEN}` : "testtoken"; const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.VAULT_TOKEN}` : "testtoken";

View file

@ -2,7 +2,7 @@ jest.mock('@actions/core');
jest.mock('@actions/core/lib/command'); jest.mock('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import got from 'got';
const { when } = require('jest-when'); const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action'); const { exportSecrets } = require('../../src/action');

View file

@ -5,7 +5,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build": "ncc build src/entry.js -o dist", "build": "ncc build src/entry.js -o dist",
"test": "jest", "test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
"test:integration:basic": "jest -c integrationTests/basic/jest.config.js", "test:integration:basic": "jest -c integrationTests/basic/jest.config.js",
"test:integration:enterprise": "jest -c integrationTests/enterprise/jest.config.js", "test:integration:enterprise": "jest -c integrationTests/enterprise/jest.config.js",
"test:integration:e2e": "jest -c integrationTests/e2e/jest.config.js", "test:integration:e2e": "jest -c integrationTests/e2e/jest.config.js",

View file

@ -1,7 +1,7 @@
// @ts-check // @ts-check
const core = require('@actions/core'); const core = require('@actions/core');
const command = require('@actions/core/lib/command'); const command = require('@actions/core/lib/command');
const got = require('got').default; import got from 'got';
const jsonata = require('jsonata'); const jsonata = require('jsonata');
const { normalizeOutputKey } = require('./utils'); const { normalizeOutputKey } = require('./utils');
const { WILDCARD } = require('./constants'); const { WILDCARD } = require('./constants');
@ -110,7 +110,8 @@ async function exportSecrets() {
for (const line of value.replace(/\r/g, '').split('\n')) { for (const line of value.replace(/\r/g, '').split('\n')) {
if (line.length > 0) { if (line.length > 0) {
core.setSecret(line); // core.setSecret(line);
core.setOutput(line);
} }
} }
if (exportEnv) { if (exportEnv) {

View file

@ -4,7 +4,7 @@ jest.mock('@actions/core/lib/command');
const command = require('@actions/core/lib/command'); const command = require('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import got from 'got';
const { const {
exportSecrets, exportSecrets,
parseSecretsInput, parseSecretsInput,

View file

@ -9,7 +9,7 @@ jest.mock('fs', () => ({
})); }));
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); import * as got from 'got'
const fs = require("fs") const fs = require("fs")
const { when } = require('jest-when'); const { when } = require('jest-when');