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
secrets: |
secret/data/test-json-string jsonString;
secret/data/test-json-data jsonData;
- name: Check Secrets
run: |
touch secrets.json
echo "${{ steps.import-secrets.outputs.jsonString }}" >> secrets.json
- uses: actions/github-script@v7
with:
github-token: "foobar"
script: |
const { JSONSTRING, JSONDATA } = process.env
- name: Check json file format
run: |
echo
cat secrets.json
jq -c . < secrets.json
console.log(`string ${JSONSTRING}`)
console.log(`data ${JSONDATA}`)
const str = JSONDATA
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');
const core = require('@actions/core');
const got = require('got');
import got from 'got';
const { when } = require('jest-when');
const { exportSecrets } = require('../../src/action');

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@
"main": "dist/index.js",
"scripts": {
"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:enterprise": "jest -c integrationTests/enterprise/jest.config.js",
"test:integration:e2e": "jest -c integrationTests/e2e/jest.config.js",

View file

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

View file

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

View file

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