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

Commit3e64aab

Browse files
committed
fix: Improve develop script to start tunnel by default
This allows for running the development script to actuallybuild workspaces!
1 parentf581724 commit3e64aab

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
@@ -79,7 +79,7 @@ func server() *cobra.Command {
7979
tlsKeyFilestring
8080
tlsMinVersionstring
8181
turnRelayAddressstring
82-
skipTunnelbool
82+
tunnelbool
8383
stunServers []string
8484
traceDatadogbool
8585
secureAuthCookiebool
@@ -138,7 +138,7 @@ func server() *cobra.Command {
138138
accessURL=localURL.String()
139139
}else {
140140
// If an access URL is specified, always skip tunneling.
141-
skipTunnel=true
141+
tunnel=false
142142
}
143143

144144
var (
@@ -149,20 +149,23 @@ func server() *cobra.Command {
149149

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

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

421-
ifdev&&!skipTunnel {
424+
ifdev&&tunnel {
422425
_,_=fmt.Fprintf(cmd.OutOrStdout(),cliui.Styles.Prompt.String()+"Waiting for dev tunnel to close...\n")
423426
closeTunnel()
424427
<-tunnelErrChan
@@ -466,8 +469,8 @@ func server() *cobra.Command {
466469
"Specifies the path to the private key for the certificate. It requires a PEM-encoded file")
467470
cliflag.StringVarP(root.Flags(),&tlsMinVersion,"tls-min-version","","CODER_TLS_MIN_VERSION","tls12",
468471
`Specifies the minimum supported version of TLS. Accepted values are "tls10", "tls11", "tls12" or "tls13"`)
469-
cliflag.BoolVarP(root.Flags(),&skipTunnel,"skip-tunnel","","CODER_DEV_SKIP_TUNNEL",false,"Skip serving dev mode through an exposed tunnel for simple setup.")
470-
_=root.Flags().MarkHidden("skip-tunnel")
472+
cliflag.BoolVarP(root.Flags(),&tunnel,"tunnel","","CODER_DEV_TUNNEL",true,
473+
"Specifies whether the dev tunnel will be enabled or not. If specified, the interactive prompt will not display.")
471474
cliflag.StringArrayVarP(root.Flags(),&stunServers,"stun-server","","CODER_STUN_SERVERS", []string{
472475
"stun:stun.l.google.com:19302",
473476
},"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