Skip to content

Specify only the vault name and infer the secret path to point to root #304

@aryanjassal

Description

@aryanjassal

Specification

Currently, we have a parser which parses the input path to ensure valid parameters. In the case of vault paths, the parser check if the path follows the format like vaultName:secretPath. This is not always ideal, as we want to allow specifying the vault's root directory by simply writing vaultName.

This is already partially implemented in the secrets ls command, but this needs to be made a standard. For command which do not operate on directories, like secrets write, this should be another error thrown from within the command, but this shouldn't be an error thrown at the parsing stage.

# Currently this results in Commander reporting a parser error
$ polykey secrets mkdir vaultX
error: command-argument value 'vaultX' is invalid for argument 'secretPath'. vaultX is not of the format <vaultName>:<directoryPath>[=<value>]

Usage: polykey secrets mkdir [options] <secretPath>

Create a Directory within a Vault

Arguments:
  secretPath                   Path to where the directory to be created, specified as <vaultName>:<directoryPath>

Options:
  -np, --node-path <path>      Path to Node State (default: "/home/aryanj/.local/share/polykey", env: PK_NODE_PATH)
  -pf, --password-file <path>  Path to Password
  -f, --format <format>        Output Format (choices: "human", "json", default: "human")
  -v, --verbose                Log Verbose Messages (default: 0)
  -r, --recursive              Create the directory recursively
  -ni, --node-id <id>           (env: PK_NODE_ID)
  -ch, --client-host <host>    Client Host Address (env: PK_CLIENT_HOST)
  -cp, --client-port <port>    Client Port (env: PK_CLIENT_PORT)
  -h, --help                   display help for command
# This should be handled by the command itself
$ polykey secrets mkdir vaultX
ErrorPolykeyCLIDirectoryExists: Directory / already exists

ErrorPolykeyCLIX: Directory / already exists.

Additional context

Tasks

  1. Update parser to allow returning undefined secret paths, which is to refer to the root directory
  2. Raise errors where the command should not accept directories as an argument
  3. Make tests for every single command ensuring regression testing against this behaviour

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions