mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-04-16 08:45:44 +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,12 +1,13 @@
|
|||
// @ts-check
|
||||
const core = require('@actions/core');
|
||||
const command = require('@actions/core/lib/command');
|
||||
import * as core from '@actions/core';
|
||||
import * as command from '@actions/core/lib/command';
|
||||
import got from 'got';
|
||||
const jsonata = require('jsonata');
|
||||
const { normalizeOutputKey } = require('./utils');
|
||||
const { WILDCARD } = require('./constants');
|
||||
import jsonata from 'jsonata';
|
||||
import { normalizeOutputKey } from './utils.js';
|
||||
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 ENCODING_TYPES = ['base64', 'hex', 'utf8'];
|
||||
|
|
@ -220,9 +221,8 @@ function parseHeadersInput(inputKey, inputOptions) {
|
|||
}, new Map());
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
exportSecrets,
|
||||
parseSecretsInput,
|
||||
parseHeadersInput,
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
import { jest } from '@jest/globals';
|
||||
|
||||
jest.mock('got');
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/core/lib/command');
|
||||
|
||||
const command = require('@actions/core/lib/command');
|
||||
const core = require('@actions/core');
|
||||
import * as command from '@actions/core/lib/command';
|
||||
import * as core from '@actions/core';
|
||||
import got from 'got';
|
||||
const {
|
||||
import {
|
||||
exportSecrets,
|
||||
parseSecretsInput,
|
||||
parseHeadersInput
|
||||
} = require('./action');
|
||||
} from './action.js';
|
||||
|
||||
const { when } = require('jest-when');
|
||||
import { when } from 'jest-when'
|
||||
|
||||
describe('parseSecretsInput', () => {
|
||||
it('parses simple secret', () => {
|
||||
|
|
|
|||
10
src/auth.js
10
src/auth.js
|
|
@ -1,8 +1,8 @@
|
|||
// @ts-check
|
||||
const core = require('@actions/core');
|
||||
const rsasign = require('jsrsasign');
|
||||
const fs = require('fs');
|
||||
const { default: got } = require('got');
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs';
|
||||
import got from 'got';
|
||||
import rsasign from 'jsrsasign';
|
||||
|
||||
const defaultKubernetesTokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
||||
/***
|
||||
|
|
@ -154,6 +154,6 @@ async function getClientToken(client, method, path, payload) {
|
|||
* }} auth
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
retrieveToken,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { jest } from '@jest/globals';
|
||||
|
||||
jest.mock('got');
|
||||
jest.mock('@actions/core');
|
||||
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'
|
||||
const fs = require("fs")
|
||||
const { when } = require('jest-when');
|
||||
import * as fs from 'fs';
|
||||
import { when } from 'jest-when'
|
||||
|
||||
|
||||
const {
|
||||
retrieveToken
|
||||
} = require('./auth');
|
||||
import { retrieveToken } from './auth.js';
|
||||
|
||||
|
||||
function mockInput(name, key) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const WILDCARD = '*';
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
WILDCARD
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const core = require('@actions/core');
|
||||
const { exportSecrets } = require('./action');
|
||||
import * as core from '@actions/core';
|
||||
import { exportSecrets } from './action.js';
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const auth = require('./auth');
|
||||
const secrets = require('./secrets');
|
||||
import auth from './auth.js';
|
||||
import secrets from './secrets.js';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
auth,
|
||||
secrets
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
jest.mock('@actions/core');
|
||||
|
||||
const core = require('@actions/core');
|
||||
const ServerMock = require("mock-http-server");
|
||||
const { exportSecrets } = require("./action");
|
||||
const { when } = require('jest-when');
|
||||
import * as core from '@actions/core';
|
||||
import * as ServerMock from 'mock-http-server';
|
||||
import exportSecrets from './action.js';
|
||||
import { when } from 'jest-when'
|
||||
|
||||
describe('exportSecrets retries', () => {
|
||||
var server = new ServerMock({ host: "127.0.0.1", port: 0 });
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const jsonata = require("jsonata");
|
||||
const { WILDCARD } = require("./constants");
|
||||
const { normalizeOutputKey } = require("./utils");
|
||||
const core = require('@actions/core');
|
||||
import jsonata from 'jsonata';
|
||||
import { WILDCARD } from './constants.js';
|
||||
import { normalizeOutputKey } from './utils.js';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
/**
|
||||
* @typedef {Object} SecretRequest
|
||||
|
|
@ -165,7 +165,7 @@ const selectAndAppendResults = async (
|
|||
];
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
getSecrets,
|
||||
selectData
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ function normalizeOutputKey(dataKey, isEnvVar = false) {
|
|||
return outputKey;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
normalizeOutputKey
|
||||
export {
|
||||
normalizeOutputKey
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue