Skip to content

Commit 35a5475

Browse files
chore: add site flag to buildinfo (coder#14868)
1 parent 2a3a00c commit 35a5475

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

buildinfo/buildinfo.go

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ var (
2424
// Updated by buildinfo_slim.go on start.
2525
slim bool
2626

27+
// Updated by buildinfo_site.go on start.
28+
site bool
29+
2730
// Injected with ldflags at build, see scripts/build_go.sh
2831
tag string
2932
agpl string // either "true" or "false", ldflags does not support bools
@@ -95,6 +98,11 @@ func IsSlim() bool {
9598
return slim
9699
}
97100

101+
// HasSite returns true if the frontend is embedded in the build.
102+
func HasSite() bool {
103+
return site
104+
}
105+
98106
// IsAGPL returns true if this is an AGPL build.
99107
func IsAGPL() bool {
100108
return strings.Contains(agpl, "t")

buildinfo/buildinfo_site.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build embed
2+
3+
package buildinfo
4+
5+
func init() {
6+
site = true
7+
}

cli/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, err
411411
{
412412
Flag: varNoOpen,
413413
Env: "CODER_NO_OPEN",
414-
Description: "Suppress opening the browser after logging in.",
414+
Description: "Suppress opening the browser when logging in, or starting the server.",
415415
Value: serpent.BoolOf(&r.noOpen),
416416
Hidden: true,
417417
Group: globalGroup,

cli/server.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,12 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
492492
BorderForeground(lipgloss.Color("12")).
493493
Render(fmt.Sprintf("View the Web UI:\n%s",
494494
pretty.Sprint(cliui.DefaultStyles.Hyperlink, accessURL))))
495-
_ = openURL(inv, accessURL)
495+
if buildinfo.HasSite() {
496+
err = openURL(inv, accessURL)
497+
if err == nil {
498+
cliui.Infof(inv.Stdout, "Opening local browser... You can disable this by passing --no-open.\n")
499+
}
500+
}
496501

497502
// Used for zero-trust instance identity with Google Cloud.
498503
googleTokenValidator, err := idtoken.NewValidator(ctx, option.WithoutAuthentication())

0 commit comments

Comments
 (0)