Skip to content

Commit

Permalink
feat: use environment variables to customize BinName, AppName, and De…
Browse files Browse the repository at this point in the history
…bName
  • Loading branch information
fufuok committed Jul 11, 2024
1 parent 42c4d29 commit be0f9a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ var (
BinName = "ffapp"

AppName = "FF.App"

// DebName !!! 这个变量决定自升级时安装命令, 以及日志中显示的包名称
// 可以在应用程序 func init() { DebName = "your-app" ... }
DebName = "ff-app"

// BinNameEnvName 上面 3 个变量可以在环境变量中设置(优先使用): LOCAL_DEB_NAME=your-web-app
BinNameEnvName = "LOCAL_BIN_NAME"
AppNameEnvName = "LOCAL_APP_NAME"
DebNameEnvName = "LOCAL_DEB_NAME"
)

var (
Expand Down
13 changes: 13 additions & 0 deletions config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ func loadEnvConfig() {
_ = os.Setenv(BaseSecretSaltEnvName, "")
BaseSecretSalt = s
}

if s := os.Getenv(BinNameEnvName); s != "" {
_ = os.Setenv(BinNameEnvName, "")
BinName = s
}
if s := os.Getenv(AppNameEnvName); s != "" {
_ = os.Setenv(AppNameEnvName, "")
AppName = s
}
if s := os.Getenv(DebNameEnvName); s != "" {
_ = os.Setenv(DebNameEnvName, "")
DebName = s
}
}

0 comments on commit be0f9a3

Please sign in to comment.