-
Notifications
You must be signed in to change notification settings - Fork 887
feat: Refactor CLI config-ssh to improve UX #1900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Just noticed we need to place the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the approach so far! The --diff
option is really cool!
Some observations:
- We should keep the configs under
~/.ssh
because that's where they always go. - We should check that we "own"
~/.ssh/coder
(maybe by checking for a magic string) before writing it
@johnstcn great observations, I've made the necessary changes.
|
cli/configssh.go
Outdated
# | ||
# To remove this blob, run: | ||
# You should not hand-edit this file, all changes will be lost upon workspace | ||
# creation, deletion or when running "coder config-ssh".` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really would love to see this feature. (i.e. running coder create
will automatically update the config). But I suggest we rewrite this comment to not include it, open up a ticket for this functionality, and leave it for a follow-up PR. (PS. This is one reason we write the used options to the config file.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: rewrite comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this locally, but looks good to me. I appreciate the thorough tests!
I do think there's still scope for refactoring; a lot of the code related to reading and writing SSH configs seems like it could be ripped out to its own module. This should probably done in a separate PR however!
cli/configssh.go
Outdated
# | ||
# To remove this blob, run: | ||
# You should not hand-edit this file, all changes will be lost upon workspace | ||
# creation, deletion or when running "coder config-ssh".` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: rewrite comment
af23128
to
142683b
Compare
- Magic block is replaced by Include statement - Writes are only done on changes - Inform user of changes via prompt - Allow displaying changes via `--diff` - Remove magic block if present TODO: - [ ] Parse previous `config-ssh` options and suggest re-using them - [ ] Auto-update `~/.ssh/coder` on `coder create` and `coder delete` - [ ] Tests for the new functionality Fixes #1326
This reverts commit f2f4a83.
142683b
to
e084a73
Compare
e084a73
to
f1be4c6
Compare
- Magic block is replaced by Include statement - Writes are only done on changes - Inform user of changes via prompt - Allow displaying changes via `--diff` - Remove magic block if present - Safer config writing via tmp-file + rename - Parse previous `config-ssh` options, compare to new options and ask to use new (otherwise old ones are used) - Tests the new functionality Fixes #1326
This PR improves the UX of
coder config-ssh
with multiple QoL improvements. Replaces #1848.--diff
config-ssh
options, compare to new options and ask to use new (otherwise old ones are used)Fixes #1326
TODO:
~/.ssh/coder
oncoder create
andcoder delete
Examples:
New config:
Options changed:
Options would change => select no (no changes):
Diff: