mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix(scripts/develop): allow empty access-url for devtunnel (#23166)
This commit is contained in:
committed by
GitHub
parent
cd163d404b
commit
c2243addce
@@ -42,6 +42,7 @@ const (
|
||||
defaultAPIPort = "3000"
|
||||
defaultWebPort = "8080"
|
||||
defaultProxyPort = "3010"
|
||||
defaultAccessURL = "http://127.0.0.1:%d"
|
||||
defaultPassword = "SomeSecurePassword!"
|
||||
defaultStarterTemplate = "docker"
|
||||
healthTimeout = 60 * time.Second
|
||||
@@ -85,7 +86,8 @@ func main() {
|
||||
{
|
||||
Flag: "access-url",
|
||||
Env: "CODER_DEV_ACCESS_URL",
|
||||
Description: "Override access URL.",
|
||||
Default: defaultAccessURL,
|
||||
Description: "Override access URL. The %d placeholder will be replaced with the API port. Set to empty to enable devtunnel (pit-1.try.coder.app).",
|
||||
Value: serpent.StringOf(&cfg.accessURL),
|
||||
},
|
||||
{
|
||||
@@ -192,8 +194,8 @@ func (c *devConfig) validate() error {
|
||||
// resolveEnv sets defaults, unsets leaked credentials, resolves
|
||||
// filesystem paths, and computes the child process environment.
|
||||
func (c *devConfig) resolveEnv() error {
|
||||
if c.accessURL == "" {
|
||||
c.accessURL = fmt.Sprintf("http://127.0.0.1:%d", c.apiPort)
|
||||
if strings.Contains(c.accessURL, "%d") {
|
||||
c.accessURL = fmt.Sprintf(c.accessURL, c.apiPort)
|
||||
}
|
||||
|
||||
// Prevent inherited credentials from leaking into child
|
||||
|
||||
@@ -289,7 +289,7 @@ func TestDevConfigResolveEnv(t *testing.T) {
|
||||
t.Setenv("CODER_SESSION_TOKEN", "leaked")
|
||||
t.Setenv("CODER_URL", "https://leaked.example.com")
|
||||
|
||||
cfg := &devConfig{apiPort: 3000}
|
||||
cfg := &devConfig{apiPort: 3000, accessURL: defaultAccessURL}
|
||||
require.NoError(t, cfg.resolveEnv())
|
||||
|
||||
wd, _ := os.Getwd()
|
||||
|
||||
Reference in New Issue
Block a user