Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit919af64

Browse files
committed
fix: Improve develop script to start tunnel by default (#1409)
This allows for running the development script to actuallybuild workspaces!
1 parent88b396a commit919af64

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

‎cli/server.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func server() *cobra.Command {
8080
tlsKeyFilestring
8181
tlsMinVersionstring
8282
turnRelayAddressstring
83-
skipTunnelbool
83+
tunnelbool
8484
stunServers []string
8585
traceDatadogbool
8686
secureAuthCookiebool
@@ -139,7 +139,7 @@ func server() *cobra.Command {
139139
accessURL=localURL.String()
140140
}else {
141141
// If an access URL is specified, always skip tunneling.
142-
skipTunnel=true
142+
tunnel=false
143143
}
144144

145145
var (
@@ -150,20 +150,23 @@ func server() *cobra.Command {
150150

151151
// If we're attempting to tunnel in dev-mode, the access URL
152152
// needs to be changed to use the tunnel.
153-
ifdev&&!skipTunnel {
153+
ifdev&&tunnel {
154154
_,_=fmt.Fprintln(cmd.ErrOrStderr(),cliui.Styles.Wrap.Render(
155155
"Coder requires a URL accessible by workspaces you provision. "+
156156
"A free tunnel can be created for simple setup. This will "+
157157
"expose your Coder deployment to a publicly accessible URL. "+
158158
cliui.Styles.Field.Render("--access-url")+" can be specified instead.\n",
159159
))
160160

161-
_,err=cliui.Prompt(cmd, cliui.PromptOptions{
162-
Text:"Would you like to start a tunnel for simple setup?",
163-
IsConfirm:true,
164-
})
165-
iferrors.Is(err,cliui.Canceled) {
166-
returnerr
161+
// This skips the prompt if the flag is explicitly specified.
162+
if!cmd.Flags().Changed("tunnel") {
163+
_,err=cliui.Prompt(cmd, cliui.PromptOptions{
164+
Text:"Would you like to start a tunnel for simple setup?",
165+
IsConfirm:true,
166+
})
167+
iferrors.Is(err,cliui.Canceled) {
168+
returnerr
169+
}
167170
}
168171
iferr==nil {
169172
accessURL,tunnelErrChan,err=devtunnel.New(ctxTunnel,localURL)
@@ -424,7 +427,7 @@ func server() *cobra.Command {
424427
spin.Stop()
425428
}
426429

427-
ifdev&&!skipTunnel {
430+
ifdev&&tunnel {
428431
_,_=fmt.Fprintf(cmd.OutOrStdout(),cliui.Styles.Prompt.String()+"Waiting for dev tunnel to close...\n")
429432
closeTunnel()
430433
<-tunnelErrChan
@@ -472,8 +475,8 @@ func server() *cobra.Command {
472475
"Specifies the path to the private key for the certificate. It requires a PEM-encoded file")
473476
cliflag.StringVarP(root.Flags(),&tlsMinVersion,"tls-min-version","","CODER_TLS_MIN_VERSION","tls12",
474477
`Specifies the minimum supported version of TLS. Accepted values are "tls10", "tls11", "tls12" or "tls13"`)
475-
cliflag.BoolVarP(root.Flags(),&skipTunnel,"skip-tunnel","","CODER_DEV_SKIP_TUNNEL",false,"Skip serving dev mode through an exposed tunnel for simple setup.")
476-
_=root.Flags().MarkHidden("skip-tunnel")
478+
cliflag.BoolVarP(root.Flags(),&tunnel,"tunnel","","CODER_DEV_TUNNEL",true,
479+
"Specifies whether the dev tunnel will be enabled or not. If specified, the interactive prompt will not display.")
477480
cliflag.StringArrayVarP(root.Flags(),&stunServers,"stun-server","","CODER_STUN_SERVERS", []string{
478481
"stun:stun.l.google.com:19302",
479482
},"Specify URLs for STUN servers to enable P2P connections.")

‎cli/server_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestServer(t *testing.T) {
7979

8080
wantEmail:="admin@coder.com"
8181

82-
root,cfg:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0")
82+
root,cfg:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0")
8383
varbuf strings.Builder
8484
root.SetOutput(&buf)
8585
varwg sync.WaitGroup
@@ -132,7 +132,7 @@ func TestServer(t *testing.T) {
132132
t.Setenv("CODER_DEV_ADMIN_EMAIL",wantEmail)
133133
t.Setenv("CODER_DEV_ADMIN_PASSWORD",wantPassword)
134134

135-
root,cfg:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0")
135+
root,cfg:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0")
136136
varbuf strings.Builder
137137
root.SetOutput(&buf)
138138
varwg sync.WaitGroup
@@ -170,7 +170,7 @@ func TestServer(t *testing.T) {
170170
t.Parallel()
171171
ctx,cancelFunc:=context.WithCancel(context.Background())
172172
defercancelFunc()
173-
root,_:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0",
173+
root,_:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0",
174174
"--tls-enable","--tls-min-version","tls9")
175175
err:=root.ExecuteContext(ctx)
176176
require.Error(t,err)
@@ -179,7 +179,7 @@ func TestServer(t *testing.T) {
179179
t.Parallel()
180180
ctx,cancelFunc:=context.WithCancel(context.Background())
181181
defercancelFunc()
182-
root,_:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0",
182+
root,_:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0",
183183
"--tls-enable","--tls-client-auth","something")
184184
err:=root.ExecuteContext(ctx)
185185
require.Error(t,err)
@@ -188,7 +188,7 @@ func TestServer(t *testing.T) {
188188
t.Parallel()
189189
ctx,cancelFunc:=context.WithCancel(context.Background())
190190
defercancelFunc()
191-
root,_:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0",
191+
root,_:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0",
192192
"--tls-enable")
193193
err:=root.ExecuteContext(ctx)
194194
require.Error(t,err)
@@ -199,7 +199,7 @@ func TestServer(t *testing.T) {
199199
defercancelFunc()
200200

201201
certPath,keyPath:=generateTLSCertificate(t)
202-
root,cfg:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0",
202+
root,cfg:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0",
203203
"--tls-enable","--tls-cert-file",certPath,"--tls-key-file",keyPath)
204204
gofunc() {
205205
err:=root.ExecuteContext(ctx)
@@ -235,7 +235,7 @@ func TestServer(t *testing.T) {
235235
}
236236
ctx,cancelFunc:=context.WithCancel(context.Background())
237237
defercancelFunc()
238-
root,cfg:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0","--provisioner-daemons","0")
238+
root,cfg:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0","--provisioner-daemons","0")
239239
done:=make(chanstruct{})
240240
gofunc() {
241241
deferclose(done)
@@ -283,7 +283,7 @@ func TestServer(t *testing.T) {
283283
t.Parallel()
284284
ctx,cancelFunc:=context.WithCancel(context.Background())
285285
defercancelFunc()
286-
root,_:=clitest.New(t,"server","--dev","--skip-tunnel","--address",":0","--trace-datadog=true")
286+
root,_:=clitest.New(t,"server","--dev","--tunnel=false","--address",":0","--trace-datadog=true")
287287
done:=make(chanstruct{})
288288
gofunc() {
289289
deferclose(done)

‎develop.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -euo pipefail
55
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
66
cd"${PROJECT_ROOT}"
77

8+
echo'== Run "make build" before running this command to build binaries.'
9+
echo'== Without these binaries, workspaces will fail to start!'
10+
811
# Run yarn install, to make sure node_modules are ready to go
912
"$PROJECT_ROOT/scripts/yarn_install.sh"
1013

@@ -18,6 +21,6 @@ export CODER_DEV_ADMIN_PASSWORD=password
1821
(
1922
trap'kill 0' SIGINT
2023
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev&
21-
go run cmd/coder/main.go server --dev --skip-tunnel&
24+
go run-tags embedcmd/coder/main.go server --dev --tunnel=true&
2225
wait
2326
)

‎go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,6 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA
960960
github.com/hashicorp/golang-lruv0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
961961
github.com/hashicorp/golang-lruv0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
962962
github.com/hashicorp/golang-lruv0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
963-
github.com/hashicorp/hc-installv0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk=
964963
github.com/hashicorp/hc-installv0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
965964
github.com/hashicorp/hc-installv0.3.2 h1:oiQdJZvXmkNcRcEOOfM5n+VTsvNjWQeOjfAoO6dKSH8=
966965
github.com/hashicorp/hc-installv0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs=

‎site/e2e/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const config: PlaywrightTestConfig = {
2121
command:`go run -tags embed${path.join(
2222
__dirname,
2323
"../../cmd/coder/main.go",
24-
)} server --dev --skip-tunnel --dev-admin-email${constants.email} --dev-admin-password${constants.password}`,
24+
)} server --dev --tunnel=false --dev-admin-email${constants.email} --dev-admin-password${constants.password}`,
2525
port:3000,
2626
timeout:120*10000,
2727
reuseExistingServer:false,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp