MatrixAI / Polykey-CLI

Polykey CLI - Open Source Decentralized Secret Sharing System for Zero Trust Workflows
https://polykey.com
GNU General Public License v3.0
6 stars 3 forks source link

Implement `secrets mkdir` command #246

Closed tegefaulkes closed 3 weeks ago

tegefaulkes commented 4 months ago

Specification

secrets mkdir is pretty simple, it will create a directory at the specified paths.

  1. Creates a directory at the specified path.
  2. Can take multiple paths to create multiple directories.
  3. Does not support wildcards or globing
  4. If a parent directory of a path doesn't exist then it will throw ENOENT
  5. If -p is specified then it will create missing parent directories.

Additional context

Related #32

Tasks

  1. Implement secrets mkdir command
  2. Supports multiple paths for creation.
  3. Supports -p flag for recursively creating directories.
  4. Can take either normal paths or secret paths.
linear[bot] commented 4 months ago

ENG-359 Implement `secrets mkdir` command

aryanjassal commented 1 month ago

UNIX mkdir doesn't stop on error. It keeps going, making what directories it can make, leaving what it cannot. I think that instead of returning an ENOENT or other error, it should catch it, and ignore it, returning an error string that can be printed out instead.

Currently, we just return a success message. Instead of that, we can use duplex streaming to return an error message or success flag every time a directory is created, or we can accumulate the errors and return them in one large chunk at the end of the whole process.

I would also need to make a new vaultOps for returning an error string instead of throwing an error, so if one path is invalid in multiple vaults, it won't stop creating more paths, but return an error string instead, and continue. Either this, or I can implement a flag to continue on errors in the existing vaultOps.mkdir.

I need some inputs on this.

tegefaulkes commented 1 month ago

Go with the duplex method then. Keep in mind that you may need to support making directories across multiple vaults at once. And multiple directories in a single vault must be done in a single commit in the vault. That will affect how you implement things.

aryanjassal commented 1 month ago

Go with the duplex method then. Keep in mind that you may need to support making directories across multiple vaults at once. And multiple directories in a single vault must be done in a single commit in the vault. That will affect how you implement things.

Yes, I am taking inspiration from how I handled this in VaultsSecretsRemove to delete files from all vaults in a single commit.