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 read` and `secrets write` commands #242

Open tegefaulkes opened 2 months ago

tegefaulkes commented 2 months ago

Specification

As part of the #32 issue refactoring, we need to implement a secrets read and secrets write command. Theses are the most basic method of accessing secrets.

secrets read

This command needs to read the contents of a secret in a vault. The contents will be outputted to stdout. Pretty much just the existing secrets get command. I don't think any changes need to be made to it.

The command takes the form of pk secrets read [secretPath]. The output can be redirected with pk secrets read [secretPath] > some file and piping into it shouldn't do anything.

secrets write

This command needs to update or create the contents of a file. There will be two ways to provide the secret contents here. Coompared to current implementation, this pretty much is just secrets create but allows you to update a secret as well.

  1. Interactively via stdin. so if you call secrets write secretPath you can type in you contents to the terminal and send EOF (ctrl+d) to finish writing.
  2. Piping data in.

In both cases the behaviour should match cat > file.

Additional context

Tasks

  1. Implement secrets read command.
  2. Implement secret write command.
  3. create tests demonstrating behaviour for read.
  4. create tests demonstrating behaviour for write.
linear[bot] commented 2 months ago

ENG-355 Implement `secrets read` and `secrets write` commands

CMCDragonkai commented 2 months ago

Why not just go straight to Unix commands?

tegefaulkes commented 2 months ago

I'm following the spec you wrote out where Imagine (IN ORDER OF PRIORITY): and read, write were top of the list. I can skip theses then since cat will basically cover that functionality anyway.

CMCDragonkai commented 1 month ago

The read and write commands are not normal unix commands. The historical context for this is https://github.com/MatrixAI/Polykey-CLI/issues/32#issuecomment-1767788230 (which should be added as the specific additional context above).

I would like cat to be an alias of the read command though as it's quite a common thing for shell users to use.