Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions envsec/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ package build

import (
"os"
"strconv"
"strings"
)

var forceProd, _ = strconv.ParseBool(os.Getenv("ENVSEC_PROD"))

// These variables are set by the build script.
var (
IsDev = Version == "0.0.0-dev" && !forceProd
IsDev = Version == "0.0.0-dev"
Version = "0.0.0-dev"
Commit = "none"
CommitDate = "unknown"
)

func init() {
buildEnv := strings.ToLower(os.Getenv("ENVSEC_BUILD_ENV"))
if buildEnv == "prod" {
IsDev = false
} else if buildEnv == "dev" {
IsDev = true
}
}

func Issuer() string {
if IsDev {
return "https://laughing-agnesi-vzh2rap9f6.projects.oryapis.com"
Expand All @@ -38,3 +45,10 @@ func JetpackAPIHost() string {
}
return "https://api.jetpack.io"
}

func BuildEnv() string {
if IsDev {
return "dev"
}
return "prod"
}
1 change: 1 addition & 0 deletions envsec/pkg/envcli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func versionCmdFunc(cmd *cobra.Command, _ []string, flags versionFlags) error {
w := cmd.OutOrStdout()
if flags.verbose {
fmt.Fprintf(w, "Version: %v\n", build.Version)
fmt.Fprintf(w, "Build Env: %v\n", build.BuildEnv())
fmt.Fprintf(w, "Platform: %v\n", fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH))
fmt.Fprintf(w, "Commit: %v\n", build.Commit)
fmt.Fprintf(w, "Commit Time: %v\n", build.CommitDate)
Expand Down
11 changes: 11 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moA
github.com/chzyer/logex v1.2.0 h1:+eqR0HfOetur4tgnC8ftU5imRnhi4te+BadWS95c5AM=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=