feat(cli): add --id parameter to templates init command#7116
Merged
Conversation
mafredri
approved these changes
Apr 13, 2023
Member
mafredri
left a comment
There was a problem hiding this comment.
Looks good, pointed out a few small things but nothing critical.
| if !ok { | ||
| ids := values(optsToID) | ||
| sort.Strings(ids) | ||
| return xerrors.Errorf("Template ID %q does not exist!\nValid options are: %q", templateIDArg, ids) |
Member
There was a problem hiding this comment.
Not a biggie, but this was a bit of a brain twister for me since the name/id stored in the map seemed unintuitive. 😅 To me it would make sense to have opts[id] = name.
Member
Author
There was a problem hiding this comment.
Our goal is to have an example template ID that we can pass to examples.Archive. The choices passed to cliui.Select are just literally what gets displayed, so we have to map that back to ID. I'd honestly prefer if cliui.Select took a map[string]string so you could differentiate what gets displayed to what gets returned, but that's a bigger change than I want to make here.
mafredri
reviewed
Apr 13, 2023
mtojek
approved these changes
Apr 13, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
#6849 broke
develop.shin a hard-to-debug manner.To automatically import a working template, we used to run
echo $TEMPLATE_NAME | coder templates init $TEMP_DIR. The assumption was that thecode-servertemplate would stay around. Unfortunately, theecho name | coder templates initis hard to troubleshoot as it has side-effects such as clearing terminal output.This PR makes the following changes:
--idparameter tocoder templates initso that you can non-interactively initialize a specific example template by ID (e.g. folder name)develop.shandlima/coder.yamlto use this parameter to select thedockerexample template.