Skip to content

Commit bb16843

Browse files
authored
[envsec] Allow setting build env to dev or prod (#251)
## Summary TSIA This will allow for better integration testing with devbox ## How was it tested?
1 parent 611b4a4 commit bb16843

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

internal/build/build.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,26 @@ package build
55

66
import (
77
"os"
8-
"strconv"
8+
"strings"
99
)
1010

11-
var forceProd, _ = strconv.ParseBool(os.Getenv("ENVSEC_PROD"))
12-
1311
// These variables are set by the build script.
1412
var (
15-
IsDev = Version == "0.0.0-dev" && !forceProd
13+
IsDev = Version == "0.0.0-dev"
1614
Version = "0.0.0-dev"
1715
Commit = "none"
1816
CommitDate = "unknown"
1917
)
2018

19+
func init() {
20+
buildEnv := strings.ToLower(os.Getenv("ENVSEC_BUILD_ENV"))
21+
if buildEnv == "prod" {
22+
IsDev = false
23+
} else if buildEnv == "dev" {
24+
IsDev = true
25+
}
26+
}
27+
2128
func Issuer() string {
2229
if IsDev {
2330
return "https://laughing-agnesi-vzh2rap9f6.projects.oryapis.com"
@@ -38,3 +45,10 @@ func JetpackAPIHost() string {
3845
}
3946
return "https://api.jetpack.io"
4047
}
48+
49+
func BuildEnv() string {
50+
if IsDev {
51+
return "dev"
52+
}
53+
return "prod"
54+
}

pkg/envcli/version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func versionCmdFunc(cmd *cobra.Command, _ []string, flags versionFlags) error {
3636
w := cmd.OutOrStdout()
3737
if flags.verbose {
3838
fmt.Fprintf(w, "Version: %v\n", build.Version)
39+
fmt.Fprintf(w, "Build Env: %v\n", build.BuildEnv())
3940
fmt.Fprintf(w, "Platform: %v\n", fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH))
4041
fmt.Fprintf(w, "Commit: %v\n", build.Commit)
4142
fmt.Fprintf(w, "Commit Time: %v\n", build.CommitDate)

0 commit comments

Comments
 (0)