Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: undefined args in `server_frontend_embed.go` (#4187)

boojack5c2990c4cb31
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go
index 5bb7054586..a5d8a34ab8 100644
--- a/bin/server/cmd/root.go
+++ b/bin/server/cmd/root.go
@@ -56,8 +56,6 @@ ________________________________________________________________________________
╚═════╝ ╚═╝ ╚══════╝
`
- // The placeholder page to instruct user how to configure --external-url.
- externalURLPlaceholder = "https://www.bytebase.com/docs/get-started/install/external-url"
)
// -----------------------------------Global constant END------------------------------------------
@@ -120,7 +118,7 @@ func init() {
// 1. Constructing the correct callback URL when configuring the VCS provider. The callback URL points to the frontend.
// 2. Creating the correct webhook endpoint when configuring the project GitOps workflow. The webhook endpoint points to the backend.
// Since frontend and backend are bundled and run on the same address in the release build, thus we just need to specify a single external URL.
- rootCmd.PersistentFlags().StringVar(&flags.externalURL, "external-url", externalURLPlaceholder, "the external URL where user visits Bytebase, must start with http:// or https://")
+ rootCmd.PersistentFlags().StringVar(&flags.externalURL, "external-url", common.ExternalURLDocsLink, "the external URL where user visits Bytebase, must start with http:// or https://")
rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", ".", "directory where Bytebase stores data. If relative path is supplied, then the path is relative to the directory where Bytebase is under")
rootCmd.PersistentFlags().BoolVar(&flags.readonly, "readonly", false, "whether to run in read-only mode")
rootCmd.PersistentFlags().BoolVar(&flags.demo, "demo", false, "whether to run using demo data")
@@ -284,8 +282,8 @@ func start() {
}
externalAddr := profile.ExternalURL
- if profile.ExternalURL == externalURLPlaceholder {
- externalAddr = fmt.Sprintf("!!! You have not set --external-url. If you want to make Bytebase\n!!! externally accessible, follow:\n\n%s", externalURLPlaceholder)
+ if profile.ExternalURL == common.ExternalURLDocsLink {
+ externalAddr = fmt.Sprintf("!!! You have not set --external-url. If you want to make Bytebase\n!!! externally accessible, follow:\n\n%s", common.ExternalURLDocsLink)
}
fmt.Printf(greetingBanner, fmt.Sprintf("Version %s has started on port %d", profile.Version, flags.port), externalAddr)
diff --git a/common/docs.go b/common/docs.go
index 1cf0812cd5..9a64faa2e0 100644
--- a/common/docs.go
+++ b/common/docs.go
@@ -1,2 +1,7 @@
// Package common provides common libraries for the service.
package common
+
+const (
+ // ExternalURLDocsLink is the docs link to configure --external-url.
+ ExternalURLDocsLink = "https://www.bytebase.com/docs/get-started/install/external-url"
+)
diff --git a/server/server_frontend_embed.go b/server/server_frontend_embed.go
index 98549e3e05..d694826e1a 100644
--- a/server/server_frontend_embed.go
+++ b/server/server_frontend_embed.go
@@ -11,6 +11,8 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
+
+ "github.com/bytebase/bytebase/common"
)
//go:embed dist/assets/*
@@ -52,8 +54,8 @@ func oauthRedirectURL(externalURL string) string {
}
func oauthErrorMessage(externalURL string) string {
- if profile.ExternalURL == externalURLPlaceholder {
- return fmt.Sprintf("Failed to exchange OAuth token. You have not configured --external-url, please follow %s", externalURLPlaceholder)
+ if externalURL == common.ExternalURLDocsLink {
+ return fmt.Sprintf("Failed to exchange OAuth token. You have not configured --external-url, please follow %s", common.ExternalURLDocsLink)
}
return fmt.Sprintf("Failed to exchange OAuth token. Make sure --external-url %s matches your browser host. Note that if you are not using port 80 or 443, you should also specify the port such as --external-url=http://host:port", externalURL)
}