-
Notifications
You must be signed in to change notification settings - Fork 887
chore: Refactor common server cli components for reusability #7103
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
Workspace-proxy cmd needs to redo all of this, better to be shared
|
||
// SetupServerCmd sets up the common elements of starting a server daemon. | ||
// This is used by both coderd and workspace proxies. | ||
func SetupServerCmd(inv *clibase.Invocation, cfg *codersdk.DeploymentValues) (_ *CommonServerCmd, err error) { |
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 think this is too broad of a function name. Is there a reason this needs to be abstracted together and can't just be duplicated? I'm having a difficult time understanding why I'd put something here, and whether it would break workspace proxies or not.
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 can duplicate it, and maybe that's the way to go. I was just trying not to duplicate all this logic across the Coderd and workspace proxy.
I'm just afraid of regressions when things are not properly done in both places.
My other idea was to refactor this into as many functions as I can so at least the shared code is a bit less LOC
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.
If we don't share the shared code we will start seeing devs do something in server.go and not do it in proxy.go just like we did in V1. Code duplication is off the table IMO because of this.
Just using functions and not a big "CommonServerCmd" struct would also work
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 can whip up the making common functions option. It's not as nice since I have to export a lot of things from this cli package, and new things still have be copied into 2 locations.
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.
@kylecarbs I need this PR where I reuse the code, or I need this PR #7118.
The second PR just exports all the functions that I need to make the workspace proxy command act the same.
closed for #7118 |
Workspace-proxy cmd needs to redo all of this, better to be shared.
See the workspace-proxy cmd (WIP):
coder/enterprise/cli/workspaceproxy.go
Lines 98 to 131 in a425487