mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-09 16:16:55 +00:00
convert remaining to esm
This commit is contained in:
parent
cd38d43a7a
commit
b379e88781
22 changed files with 77 additions and 68 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
const { exportSecrets } = require('../../src/action');
|
import exportSecrets from '../../src/action.js';
|
||||||
|
|
||||||
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
||||||
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
const { exportSecrets } = require('../../src/action');
|
import exportSecrets from '../../src/action.js';
|
||||||
|
|
||||||
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
||||||
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const rsasign = require('jsrsasign');
|
import rsasign from 'jsrsasign';
|
||||||
const {
|
import {
|
||||||
privateRsaKey,
|
privateRsaKey,
|
||||||
privateRsaKeyBase64,
|
privateRsaKeyBase64,
|
||||||
publicRsaKey
|
publicRsaKey
|
||||||
} = require('./rsa_keys');
|
} from './rsa_keys.js');
|
||||||
|
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
const { exportSecrets } = require('../../src/action');
|
import exportSecrets from '../../src/action.js';
|
||||||
|
|
||||||
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
||||||
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ LrJEY9tZaRF8xraMZiOcBcyAt6S/TS29HttJ6+zlhcWx34fItEZ8jA5gzhTmspOY
|
||||||
-----END PUBLIC KEY-----
|
-----END PUBLIC KEY-----
|
||||||
`;
|
`;
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
privateRsaKey,
|
privateRsaKey,
|
||||||
privateRsaKeyBase64,
|
privateRsaKeyBase64,
|
||||||
publicRsaKey
|
publicRsaKey
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
const { exportSecrets } = require('../../src/action');
|
import exportSecrets from '../../src/action.js';
|
||||||
|
|
||||||
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
|
||||||
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;
|
const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;
|
||||||
const caCertificateRaw = `${process.env.VAULTCA}`;
|
const caCertificateRaw = `${process.env.VAULTCA}`;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
const { exportSecrets } = require('../../src/action');
|
import exportSecrets from '../../src/action.js';
|
||||||
|
|
||||||
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8201'}`;
|
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8201'}`;
|
||||||
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
module.exports = {
|
// module.exports = {
|
||||||
|
// transform: {},
|
||||||
|
// testPathIgnorePatterns: ['/node_modules/', '<rootDir>/integrationTests/'],
|
||||||
|
// };
|
||||||
|
|
||||||
|
export default {
|
||||||
|
transform: {},
|
||||||
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/integrationTests/'],
|
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/integrationTests/'],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2018"
|
"target": "es2018"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
package-lock.json
generated
1
package-lock.json
generated
|
|
@ -3,6 +3,7 @@
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
"type": "module",
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "vault-action",
|
"name": "vault-action",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"name": "vault-action",
|
"name": "vault-action",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "A Github Action that allows you to consume vault secrets as secure environment variables.",
|
"description": "A Github Action that allows you to consume vault secrets as secure environment variables.",
|
||||||
|
"type": "module",
|
||||||
"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",
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const command = require('@actions/core/lib/command');
|
import * as command from '@actions/core/lib/command';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const jsonata = require('jsonata');
|
import jsonata from 'jsonata';
|
||||||
const { normalizeOutputKey } = require('./utils');
|
import { normalizeOutputKey } from './utils.js';
|
||||||
const { WILDCARD } = require('./constants');
|
import { WILDCARD } from './constants.js';
|
||||||
|
|
||||||
const { auth: { retrieveToken }, secrets: { getSecrets } } = require('./index');
|
import { retrieveToken } from './auth.js';
|
||||||
|
import { getSecrets } from './secrets.js';
|
||||||
|
|
||||||
const AUTH_METHODS = ['approle', 'token', 'github', 'jwt', 'kubernetes', 'ldap', 'userpass'];
|
const AUTH_METHODS = ['approle', 'token', 'github', 'jwt', 'kubernetes', 'ldap', 'userpass'];
|
||||||
const ENCODING_TYPES = ['base64', 'hex', 'utf8'];
|
const ENCODING_TYPES = ['base64', 'hex', 'utf8'];
|
||||||
|
|
@ -220,9 +221,8 @@ function parseHeadersInput(inputKey, inputOptions) {
|
||||||
}, new Map());
|
}, new Map());
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
exportSecrets,
|
exportSecrets,
|
||||||
parseSecretsInput,
|
parseSecretsInput,
|
||||||
parseHeadersInput,
|
parseHeadersInput,
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
|
import { jest } from '@jest/globals';
|
||||||
|
|
||||||
jest.mock('got');
|
jest.mock('got');
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
|
|
||||||
const command = require('@actions/core/lib/command');
|
import * as command from '@actions/core/lib/command';
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
const {
|
import {
|
||||||
exportSecrets,
|
exportSecrets,
|
||||||
parseSecretsInput,
|
parseSecretsInput,
|
||||||
parseHeadersInput
|
parseHeadersInput
|
||||||
} = require('./action');
|
} from './action.js';
|
||||||
|
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
describe('parseSecretsInput', () => {
|
describe('parseSecretsInput', () => {
|
||||||
it('parses simple secret', () => {
|
it('parses simple secret', () => {
|
||||||
|
|
|
||||||
10
src/auth.js
10
src/auth.js
|
|
@ -1,8 +1,8 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const rsasign = require('jsrsasign');
|
import * as fs from 'fs';
|
||||||
const fs = require('fs');
|
import got from 'got';
|
||||||
const { default: got } = require('got');
|
import rsasign from 'jsrsasign';
|
||||||
|
|
||||||
const defaultKubernetesTokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
const defaultKubernetesTokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
||||||
/***
|
/***
|
||||||
|
|
@ -154,6 +154,6 @@ async function getClientToken(client, method, path, payload) {
|
||||||
* }} auth
|
* }} auth
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
retrieveToken,
|
retrieveToken,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { jest } from '@jest/globals';
|
||||||
|
|
||||||
jest.mock('got');
|
jest.mock('got');
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/core/lib/command');
|
jest.mock('@actions/core/lib/command');
|
||||||
|
|
@ -8,15 +10,12 @@ jest.mock('fs', () => ({
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
import * as got from 'got'
|
import * as got from 'got'
|
||||||
const fs = require("fs")
|
import * as fs from 'fs';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
|
import { retrieveToken } from './auth.js';
|
||||||
const {
|
|
||||||
retrieveToken
|
|
||||||
} = require('./auth');
|
|
||||||
|
|
||||||
|
|
||||||
function mockInput(name, key) {
|
function mockInput(name, key) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const WILDCARD = '*';
|
const WILDCARD = '*';
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
WILDCARD
|
WILDCARD
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const { exportSecrets } = require('./action');
|
import { exportSecrets } from './action.js';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const auth = require('./auth');
|
import auth from './auth.js';
|
||||||
const secrets = require('./secrets');
|
import secrets from './secrets.js';
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
auth,
|
auth,
|
||||||
secrets
|
secrets
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
|
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const ServerMock = require("mock-http-server");
|
import * as ServerMock from 'mock-http-server';
|
||||||
const { exportSecrets } = require("./action");
|
import exportSecrets from './action.js';
|
||||||
const { when } = require('jest-when');
|
import { when } from 'jest-when'
|
||||||
|
|
||||||
describe('exportSecrets retries', () => {
|
describe('exportSecrets retries', () => {
|
||||||
var server = new ServerMock({ host: "127.0.0.1", port: 0 });
|
var server = new ServerMock({ host: "127.0.0.1", port: 0 });
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const jsonata = require("jsonata");
|
import jsonata from 'jsonata';
|
||||||
const { WILDCARD } = require("./constants");
|
import { WILDCARD } from './constants.js';
|
||||||
const { normalizeOutputKey } = require("./utils");
|
import { normalizeOutputKey } from './utils.js';
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} SecretRequest
|
* @typedef {Object} SecretRequest
|
||||||
|
|
@ -165,7 +165,7 @@ const selectAndAppendResults = async (
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
getSecrets,
|
getSecrets,
|
||||||
selectData
|
selectData
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@ function normalizeOutputKey(dataKey, isEnvVar = false) {
|
||||||
return outputKey;
|
return outputKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export {
|
||||||
normalizeOutputKey
|
normalizeOutputKey
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue