Skip to content
Permalink
Browse files
fix(telemetry): repair turn-off telemetry switch
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Sep 7, 2022
1 parent b8efbbd commit f8559e9f3798fcbc553b2b3596ccee637f356dc3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
@@ -13,7 +13,8 @@ import (
)

const (
TracesURL = "https://telemetry.werf.io/v1/traces"
TracesURL = "https://telemetry.werf.io/v1/traces"
TelemetryEnv = "WERF_TELEMETRY"
)

var (
@@ -94,9 +95,15 @@ func GetTraceUrl() string {
}

func IsEnabled() bool {
isDevVersion := werf.Version == "dev" || werf.Version == "0.0.0"
envVal := util.GetBoolEnvironmentDefaultFalse("WERF_TELEMETRY")
return envVal || !isDevVersion
val, isSet := util.LookupBoolEnvironment(TelemetryEnv)
if isSet && val != nil {
return *val
}

if werf.Version == "dev" || werf.Version == "0.0.0" {
return false
}
return true
}

func LogF(f string, args ...interface{}) {
@@ -8,17 +8,26 @@ import (
"strings"
)

func GetBoolEnvironment(environmentName string) *bool {
switch os.Getenv(environmentName) {
func LookupBoolEnvironment(environmentName string) (*bool, bool) {
value, isSet := os.LookupEnv(environmentName)
if !isSet {
return nil, false
}

switch value {
case "1", "true", "yes":
t := true
return &t
return &t, true
case "0", "false", "no":
f := false
return &f
return &f, true
}
return nil, true
}

return nil
func GetBoolEnvironment(environmentName string) *bool {
val, _ := LookupBoolEnvironment(environmentName)
return val
}

func GetBoolEnvironmentDefaultFalse(environmentName string) bool {

0 comments on commit f8559e9

Please sign in to comment.