-
Notifications
You must be signed in to change notification settings - Fork 887
chore: Add workspace proxy enterprise cli commands #7176
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
Add primary access url Include app security key Add output formats for registering a proxy Fix formats Add cli cmd to get app security key Add deleting proxies feat: Allow workspace proxy spawn in develop.sh Make gen Import ordeR Quote shell var Imports Fix lint Tabs vs spaces remove unused command Fix compile and make gen Fix slim cmd to include extra proxy cmds Import order Import order Fix comment Fix compile with name
cli/server.go
Outdated
if cfg.Dangerous.DevAppSecurityKey.Value() != "" { | ||
_, err := workspaceapps.KeyFromString(cfg.Dangerous.DevAppSecurityKey.Value()) | ||
if err != nil { | ||
return xerrors.Errorf("invalid dev app security key: %w", err) | ||
} | ||
err = tx.UpsertAppSecurityKey(ctx, cfg.Dangerous.DevAppSecurityKey.Value()) | ||
if err != nil { | ||
return xerrors.Errorf("Insert dev app security key: %w", err) | ||
} | ||
} |
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.
This will be removed when we do this over an authenticated api
enterprise/cli/proxyserver.go
Outdated
opts.Add( | ||
// Options only for external workspace proxies | ||
|
||
clibase.Option{ | ||
Name: "Proxy Session Token", | ||
Description: "Authentication token for the workspace proxy to communicate with coderd.", | ||
Flag: "proxy-session-token", | ||
Env: "CODER_PROXY_SESSION_TOKEN", | ||
YAML: "proxySessionToken", | ||
Default: "", | ||
Value: &proxySessionToken, | ||
Group: &externalProxyOptionGroup, | ||
Hidden: false, | ||
}, | ||
|
||
clibase.Option{ | ||
Name: "Coderd (Primary) Access URL", | ||
Description: "URL to communicate with coderd. This should match the access URL of the Coder deployment.", | ||
Flag: "primary-access-url", | ||
Env: "CODER_PRIMARY_ACCESS_URL", | ||
YAML: "primaryAccessURL", | ||
Default: "", | ||
Value: &primaryAccessURL, | ||
Group: &externalProxyOptionGroup, | ||
Hidden: false, | ||
}, | ||
|
||
// TODO: Make sure this is kept secret. Idk if a flag is the best option | ||
clibase.Option{ | ||
Name: "App Security Key", | ||
Description: "App security key used for decrypting/verifying app tokens sent from coderd.", | ||
Flag: "app-security-key", | ||
Env: "CODER_APP_SECURITY_KEY", | ||
YAML: "appSecurityKey", | ||
Default: "", | ||
Value: &appSecuritYKey, | ||
Group: &externalProxyOptionGroup, | ||
Hidden: false, | ||
Annotations: clibase.Annotations{}.Mark("secret", "true"), | ||
}, | ||
) | ||
|
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.
Until we have a better way, this is how I add options that are only for workspace proxies.
r.InitClient(client), | ||
), | ||
Handler: func(inv *clibase.Invocation) error { | ||
if !(primaryAccessURL.Scheme == "http" || primaryAccessURL.Scheme == "https") { |
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.
it'd be nice if deployment options can be validated in the option definition but alas
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.
Interesting idea... @ammario ? Is a "Validate" func field on an option reasonable?
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 that idea
clibase.Option{ | ||
Flag: "only-token", | ||
Description: "Only print the token. This is useful for scripting.", | ||
Value: clibase.BoolOf(&onlyToken), | ||
}, |
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.
Honestly seems unnecessary given you support JSON output.
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.
This is so easy:
proxy_session_token=$(coder proxy create --only-token)
Otherwise I need to chain with jq. This is just nice imo.
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.
Honestly LGTM 👍
What this does
Makes a cli command to spin up external workspace proxies!
This is just the start to get an external workspace proxy up for manual testing/verification. All commands are hidden right now by default.
Future work
Testing/Development
This gives
develop.sh
an option--use-proxy
which will spin up the devserver with an external workspace proxy. This should allow easier manual validation.Features added to make this work
clibase.Optionset
filter to filter out options that do not pertain to the workspace proxy.app-security-key
Logs
Run
./develop.sh --use-proxy
Video
Peek.2023-04-18.10-02.webm