Skip to content

feat: add -a, --active-only to export secrets#119

Open
brycentrivir wants to merge 2 commits into
mainfrom
feature/active-only-flag-addition
Open

feat: add -a, --active-only to export secrets#119
brycentrivir wants to merge 2 commits into
mainfrom
feature/active-only-flag-addition

Conversation

@brycentrivir

Copy link
Copy Markdown

Adds the -a flag to config-manager pull secrets.
Changes within file:

  • Removed getFrConfigSecrets function as it only added the valueBase64 property which is never used again and rewritten again later in cleanSecret.
  • Implemented use of helper function esvToEnv from utils/FrConfig
  • Original FR-CM code simply counts versions from 1 up to versions.length which may be a bug. I change it to match the response with highest version count first and counts down, not including any destroyed versions.
  • Original FR-CM has an environment variable 'ACTIVE_ONLY_SECRETS' set to true, so the -a flag is defaulted on. Frodo's version of CM will not include that but rely on usage of the flag. Users default exported JSON will now be different than previously.

@phalestrivir phalestrivir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to run npm run lint:fix (that's how I caught the console.log that you left in)

Also, I would update the config-manager-export-all test's mock and snapshot. This is because, if the test was passing under normal circumstances, it would be failing now as a result of your change since you changed how the ESV secrets get exported to now include versions. The tests are failing due to other changes too, so fixing the test would fix both those issues as well as the issue caused by updating the ESV secrets. You should be able to just re-record the mock for it and update the snapshot and then it will pass.

Comment thread src/configManagerOps/FrConfigSecretOps.ts Outdated
Comment thread src/configManagerOps/FrConfigSecretOps.ts Outdated
Comment thread src/configManagerOps/FrConfigSecretOps.ts Outdated
Comment on lines 20 to 37
type FrConfigSecret = SecretSkeleton & {
valueBase64: string;
};

async function getFrConfigSecrets(): Promise<FrConfigSecret[]> {
const originalSecrets = await readSecrets();
return originalSecrets.map((secret) => ({
...secret,
valueBase64: `\${${secret._id.toUpperCase().replace(/-/g, '_')}}`,
}));
interface CleanSecretVersionInterface {
version: string;
status: VersionOfSecretStatus;
valueBase64: string;
}

interface CleanSecretInterface {
_id: string;
description: string;
encoding: SecretEncodingType;
useInPlaceholders: boolean;
valueBase64?: string;
versions?: CleanSecretVersionInterface[];
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would delete these interfaces/types as they are not necessary (see my other comment)

Comment thread test/e2e/__snapshots__/config-manager-export-all.e2e.test.js.snap Outdated
@brycentrivir
brycentrivir force-pushed the feature/active-only-flag-addition branch from 7c94222 to 5c7cb8c Compare July 14, 2026 21:55

@phalestrivir phalestrivir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor changes needed

.addOption(
new Option(
'-a, --active-only',
'Exports only active secrets, otherwise exports all secrets and their versions.'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only have it say Export only active secret versions. It's implied that if it's not provided all secret versions will be exported.

});
test('"frodo config-manager pull secrets -aD secretTestDir2": should export all the active only secrets in fr-config-manager style"', async () => {
const dirName = 'secretTestDir2';
const CMD = `frodo config-manager pull secrets -D ${dirName}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is wrong, it should have -aD here.

test('"frodo config-manager pull all -F test/e2e/fr-config-manager-pull-config -D allDir1": should export all config in fr-config-manager style"', async () => {
const dirName = 'allDir1';
const CMD = `frodo config-manager pull all -F test/e2e/fr-config-manager-pull-config -D ${dirName}`;
const fileName= 'test/e2e/fr-config-manager-pull-config';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is a directory name, not a file name, so I'd change the name of this variable to reflect that. It's the directory (or folder) which contains all the config-manager configurations for pulling.

Note in the future I think we are going to have to change how the export all works, since we should be able to specify where each of the individual configuration files are when doing a pull rather than a directory, especially since that's how config-manager does it, so this is only going to be a temporary thing.

Comment on lines 16 to 19
type FrConfigSecret = SecretSkeleton & {
valueBase64: string;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this type either, so I would just remove it. If you delete all the places we are using it you shouldn't run into any errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants