feat: add -a, --active-only to export secrets#119
Conversation
There was a problem hiding this comment.
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.
| const [secretKey] = Object.keys(exportData.secret); | ||
| const fullSecret = exportData.secret[secretKey] as FrConfigSecret; | ||
| const cleanSecret = { | ||
| const cleanSecret: CleanSecretInterface = { |
There was a problem hiding this comment.
Instead of using your own interfaces, I would do Partial<SecretSkeleton>, this will avoid typechecker errors, and it's correct in that it is a partial implementation of the SecretSkeleton interface
| 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[]; | ||
| } |
There was a problem hiding this comment.
I would delete these interfaces/types as they are not necessary (see my other comment)
There was a problem hiding this comment.
You need to do a full re-recording of the pull all mock, not just update the snapshot. Yes, the test is "passing" now, but you see it deleted all ESV secrets from the snapshot. That's because it's erroring out due to missing mock recordings, so it's not actually testing ESV secrets anymore as it should. If you try running the command for this test using FRODO_MOCK=1 you'd start seeing all the recording errors.
7c94222 to
5c7cb8c
Compare
Adds the -a flag to config-manager pull secrets.
Changes within file: