secrethub-cli icon indicating copy to clipboard operation
secrethub-cli copied to clipboard

Add `--force` flag to inject command

Open SimonBarendse opened this issue 4 years ago • 5 comments

-f, --force (bool)
  When injecting to an output file and the file already exists, overwrite it.

SimonBarendse avatar Mar 18 '20 21:03 SimonBarendse

Sweet! Should this also be included in the read command, which has an --output-file flag?

And, it's kinda implied, but it may be good to speficy that the --force flag is ignored if --output-file isn't specified?

mackenbach avatar Mar 19 '20 11:03 mackenbach

And thanks for the suggestion @antonbabenko

mackenbach avatar Mar 19 '20 11:03 mackenbach

Sweet! Should this also be included in the read command, which has an --output-file flag?

The read command always overwrites the file. I'm hesitant to change that, as it might break existing workflows if we now require --force to do so.

And, it's kinda implied, but it may be good to speficy that the --force flag is ignored if --output-file isn't specified?

Yes good idea. Can't be too explicit :+1:

SimonBarendse avatar Mar 19 '20 11:03 SimonBarendse

The read command always overwrites the file. I'm hesitant to change that, as it might break existing workflows if we now require --force to do so.

After thinking twice about what you said, do we actually want that, and why? Yes, changing it would be breaking, but I'd like us to be conscious as to why we have this behavior.

And the docs currently don't mention that it always overwrites, so maybe it's good to add that there too to be explicit.

-o, --out-file=OUT-FILE  Write the secret value to this file.

mackenbach avatar Mar 19 '20 18:03 mackenbach

Ideally, the read command should behave similar to the inject command. Also, I think passing a flag to explicitly overwrite the file is better.

I can see the following migration path:

Add --force flag to read to overwrite the file, also, still overwrite if the flag is not supplied as well, but deprecate that. Then, a few versions later, remove support for overwriting the file without passing the --force flag.

This way, we give users that depend on the read command to overwrite the file some time to migrate.

SimonBarendse avatar Mar 23 '20 10:03 SimonBarendse