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 cp` command #249

Open tegefaulkes opened 3 months ago

tegefaulkes commented 3 months ago

Specification

The secrets cp command is very similar to the secrets mv command. It will copy the provided paths to the provided destination.

  1. copy a file to a destination directory
  2. Multiple source paths can be specified. The last argument is the destination.
  3. Globing and wildcards are supported.
  4. Globing is supported for the destination. but only the last of the list is the destination. I say we don't support it.

There are two main differences between the mv command.

  1. The source files are left unchanged the copied. The Inode of the source and destination are different.
  2. The destination files are always created fresh and overwrite the destination.

So there are no subtle behaviours with the moving the file vs copying them between filesystems.

Additional context

Related #32

Tasks

  1. Implement a secrets cp command
  2. Supports copying a file from source path to destination.
  3. And take a variable number of source paths with the last path being the destination.
  4. Supports globing and wild cards.
  5. Supports copying directories with contents.
linear[bot] commented 3 months ago

ENG-362 Implement `secrets cp` command

CMCDragonkai commented 3 months ago

I want to point out that cp here is going to be one of the most complex commands and most used commands probably.

You have consider these scenarios:

Then imagine that all works also recursively.

tegefaulkes commented 3 months ago

Yeah, it's a complex and I've considered most of that already.

I think the most complex part of this is the recursive walking and globing of the file paths. I've already completed a utility for this in https://github.com/MatrixAI/Polykey/issues/767 which works on real fs along with our fs. It supports the whole glob standard using minimatch which is what NPM uses to check glob patterns.

Along with that there's sending the file tree across the network so we can write it between the real FS locally and the node's efs. I'm half way through this now with https://github.com/MatrixAI/Polykey/pull/774.

Besides that I still need to work out how I want to structure the RPC commands. If we say, want a specilized RPC for CP, or more generalised RPC for plumbing. I need to do some prototyping to get an idea of the constraints. The plumbing style might require the ability to lock and hold transactions between RPC calls.