Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding secrets rm command #279

Merged
merged 1 commit into from
Sep 16, 2024
Merged

Adding secrets rm command #279

merged 1 commit into from
Sep 16, 2024

Conversation

aryanjassal
Copy link
Member

@aryanjassal aryanjassal commented Sep 10, 2024

Description

Implement secrets rm command following the behaviour of UNIX. For example, passing the -r flag would recursively delete a directory and it's contents, and we can supply multiple secret paths to the command.

Issues Fixed

Tasks

  • 1. Add new secrets rm command (functionally similar to secrets del)
  • 2. Add support for specifying and deleting multiple files
  • 3. Supply --recursive to delete directories and their contents
  • 4. Add tests

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@aryanjassal aryanjassal self-assigned this Sep 10, 2024
Copy link

linear bot commented Sep 10, 2024

@aryanjassal aryanjassal force-pushed the feature-unix-rm branch 2 times, most recently from 64d3e9c to 150040e Compare September 10, 2024 08:15
@aryanjassal aryanjassal marked this pull request as ready for review September 10, 2024 08:26
@aryanjassal aryanjassal changed the title wip: working on secrets rm command Adding secrets rm command Sep 10, 2024
Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

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

I've found some small problems.

src/utils/options.ts Outdated Show resolved Hide resolved
tests/secrets/remove.test.ts Outdated Show resolved Hide resolved
tests/secrets/remove.test.ts Show resolved Hide resolved
src/secrets/CommandRemove.ts Outdated Show resolved Hide resolved
@CMCDragonkai
Copy link
Member

CMCDragonkai commented Sep 11, 2024 via email

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Sep 11, 2024 via email

@aryanjassal
Copy link
Member Author

command = [
'secrets',
'stat',
'-np',
dataDir,
`${vaultName}:MySecret`,
'--format',
'json',
];
const result = await testUtils.pkStdio([...command], {
env: { PK_PASSWORD: password },
cwd: dataDir,
});

I've noticed something interesting. In almost every test, we define command as a list of commands. But, for some reason, we unwrap the list, then wrap the contents into an array again, like [...command]. It can all be simplified to simply passing in the array directly, like this:

const command = ['secrets', 'rm', '-np', dataDir, `${vaultName}:secret`];

const result = await testUtils.pkStdio(command, {
  env: { PK_PASSWORD: password },
  cwd: dataDir,
});

This would have the result of making the tests slightly faster and more readable. I have also noticed that in some tests, command is defined globally, and in others, it is defined as a const for each test (see file linked above for this behaviour). I think we should define it in each test to ensure the command remains scoped to that test.

feat: adding secrets rm

feat: added tests

chore: added tests

fix: lint

fix: lint

chore: updated package.json
@aryanjassal
Copy link
Member Author

All the tasks have been finished for this PR and approval has also been granted. Merging.

@aryanjassal aryanjassal merged commit 6f77c68 into staging Sep 16, 2024
22 checks passed
@CMCDragonkai
Copy link
Member

command = [
'secrets',
'stat',
'-np',
dataDir,
`${vaultName}:MySecret`,
'--format',
'json',
];
const result = await testUtils.pkStdio([...command], {
env: { PK_PASSWORD: password },
cwd: dataDir,
});

I've noticed something interesting. In almost every test, we define command as a list of commands. But, for some reason, we unwrap the list, then wrap the contents into an array again, like [...command]. It can all be simplified to simply passing in the array directly, like this:

const command = ['secrets', 'rm', '-np', dataDir, `${vaultName}:secret`];

const result = await testUtils.pkStdio(command, {
  env: { PK_PASSWORD: password },
  cwd: dataDir,
});

This would have the result of making the tests slightly faster and more readable. I have also noticed that in some tests, command is defined globally, and in others, it is defined as a const for each test (see file linked above for this behaviour). I think we should define it in each test to ensure the command remains scoped to that test.

Spreading is usually intended for shallow copies. Not sure what that's for.

@aryanjassal
Copy link
Member Author

rm

@CMCDragonkai
Copy link
Member

Interesting it's 1 commit message.

Do note to use ls not list in order to be consistent in our messaging.

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

Successfully merging this pull request may close these issues.

3 participants