Issue/#114 cli editor support#121
Conversation
|
Is there a better way to structure this for testing? |
ddgenome
left a comment
There was a problem hiding this comment.
It seems the edit capability is neither part of kube-encrypt or kube-decrypt, since what you really want is a round trip, decrypt-edit-encrypt. Maybe it should be its own command, kube-edit.
Co-Authored-By: David Dooling <dooling@gmail.com>
|
Regarding test, for starters you could set the editor to |
ok, let me rework as it's own command and see how that looks. |
|
@ddgenome do you mind having a look and seeing if this is heading in the right direction? |
ddgenome
left a comment
There was a problem hiding this comment.
It looks like a good start. I couple guiding questions that may make the implementation easier.
With regard to the questions about the cli options, would it then make sense to introduce a |
|
When would you not want to save? I am thinking the This pattern is useful for GitOps users, so you can always recover the original contents of the secret spec from the Git history. |
|
ah ok, I missed that initially - thought we would just be writing to std out. |
|
@ddgenome mind having a look when you have a chance? |
ddgenome
left a comment
There was a problem hiding this comment.
This is looking good. Great tests. A few minor things. Thanks for sticking with it!
| parameterName: "file", | ||
| describe: "Edit Kubernetes secret data values from secret spec file", | ||
| type: "string", | ||
| required: true, |
There was a problem hiding this comment.
Sorry I was not clearer on this before. I think having a required option is an oxymoron. If people have to provide it, why make them type --file=? Just grab it from argv._ and complain if it is not there.
There was a problem hiding this comment.
I've changed this to use a positional argument, which seems to work pretty well
| try { | ||
| secret = await handleSecretParameter(opts); | ||
| } catch (e) { | ||
| print.error(`Failed to load secret spec from file '${opts.file}': ${e.message}`); |
There was a problem hiding this comment.
This error message is not accurate anymore. Perhaps all the try/catch should be in the handleSecretParameter functions.
There was a problem hiding this comment.
That try/catch is used more for exit handling than anything else, would then need to move exit (code) handling into the handleSecretParameter function, which feels a little inconsistent as the crypt method also uses the same pattern for exit code handling
There was a problem hiding this comment.
Since only the reading of the file can throw an error, it seems to make sense to handle that issue there and use a different mechanism, e.g., returning undefined, to signal a failure of the function that then results in exit status handling.
There was a problem hiding this comment.
ah ok, that makes sense. Will update accordingly
Co-Authored-By: David Dooling <dooling@gmail.com>
…rg/cli into issue/#114-cli-editor-support
|
@ddgenome do you mind reviewing again? |
| try { | ||
| secret = await handleSecretParameter(opts); | ||
| } catch (e) { | ||
| print.error(`Failed to load secret spec from ${opts.file ? `'${opts.file}'` : "--file or --literal"}: ${e.message}`); |
There was a problem hiding this comment.
If opts.file is not truthy, why would you say "--file or --literal"?
| try { | ||
| secret = await handleSecretParameter(opts); | ||
| } catch (e) { | ||
| print.error(`Failed to load secret spec from file '${opts.file}': ${e.message}`); |
There was a problem hiding this comment.
Since only the reading of the file can throw an error, it seems to make sense to handle that issue there and use a different mechanism, e.g., returning undefined, to signal a failure of the function that then results in exit status handling.
ddgenome
left a comment
There was a problem hiding this comment.
I'm still not sold on the file error handling, but if you feel strongly that it should be this way, I'm okay with merging.
|
I've updated the PR with the latest changes:
I would really like to add some interactive cli testing ( the |
Resolves #114