feat: edit pod command (#35) #226
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add edit pod command
Modify existing pods without having to remove the pod and reprovision new machines as a result. This is a CLI version of the same functionality in the web console, where one can change container images, ports etc without releasing the machine.
Same caveat to the web console applies; the container disk may be wiped if the backend decides it has to re-launch the container for the pod, even if on the same machine.
Closes #35
How I tested it
Reviewer notes
This is a rather large commit. It is large because it expands the scope of the CLI in three dimensions:
editedit pod.The second reason it's large is because it tries to avoid the pitfalls of other commands that unfortunately mutate the backend in ways the user did not intend. For instance, by confusing template variables with CLI defaults and user specified options. For that reason a new "option binding" scaffolding was added that overcomes the main issue with Cobra; no clean way to determine if an option was set by the user or if it was a result of a default value.
The third reason is because this is a delta handling problem, and getting it wrong will may cause data-loss for users. That is unacceptable. Other than a lot of unit tests the new edit command also has a dry-run flag, which allows the user to inspect exactly what will be sent to the backend, if ever in doubt. That should minimize the risk of data loss as the user has complete visibility into precisely what a given command invocation will result in before sending it.
The PR contains a good deal of documentation (comments) on the binding machinery, so with a bit of squinting, I hope it makes sense after a minute or so. If not, please ask and I'll be happy to clarify, as well as revise, if a better solution can be found to "parsing and acting on the user provided options only".