diff options
author | James Fargher <proglottis@gmail.com> | 2021-06-09 23:58:10 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2021-06-15 08:30:30 +0300 |
commit | 07048ea21953131d5022ab3289ec695e0cce4af7 (patch) | |
tree | 5290e378a8c07027cba466f1884c2702f59979fb /cmd | |
parent | b541a391a9eebc7a0b85e37fcf12e8c5bf1be5e1 (diff) |
Extract typed environment variable helpers
These helpers should make parsing typed environment variables more
consistent.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-hooks/hooks.go | 4 | ||||
-rw-r--r-- | cmd/gitaly-wrapper/main.go | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go index 897ce30a8..03b33ddb8 100644 --- a/cmd/gitaly-hooks/hooks.go +++ b/cmd/gitaly-hooks/hooks.go @@ -7,7 +7,6 @@ import ( "io" "log" "os" - "strconv" "strings" "github.com/sirupsen/logrus" @@ -18,6 +17,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/prometheus" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/v14/internal/gitlab" + "gitlab.com/gitlab-org/gitaly/v14/internal/helper/env" gitalylog "gitlab.com/gitlab-org/gitaly/v14/internal/log" "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/v14/internal/stream" @@ -163,7 +163,7 @@ func dialGitaly(payload git.HooksPayload) (*grpc.ClientConn, error) { func gitPushOptions() []string { var gitPushOptions []string - gitPushOptionCount, err := strconv.Atoi(os.Getenv("GIT_PUSH_OPTION_COUNT")) + gitPushOptionCount, err := env.GetInt("GIT_PUSH_OPTION_COUNT", 0) if err != nil { return gitPushOptions } diff --git a/cmd/gitaly-wrapper/main.go b/cmd/gitaly-wrapper/main.go index 1239d4503..3ac422070 100644 --- a/cmd/gitaly-wrapper/main.go +++ b/cmd/gitaly-wrapper/main.go @@ -13,6 +13,7 @@ import ( "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v14/internal/bootstrap" + "gitlab.com/gitlab-org/gitaly/v14/internal/helper/env" "gitlab.com/gitlab-org/gitaly/v14/internal/log" "gitlab.com/gitlab-org/gitaly/v14/internal/ps" "golang.org/x/sys/unix" @@ -177,5 +178,6 @@ func pidFile() string { } func jsonLogging() bool { - return os.Getenv(envJSONLogging) == "true" + enabled, _ := env.GetBool(envJSONLogging, false) + return enabled } |