Skip to content

Commit e0cb161

Browse files
authored
Merge pull request kubernetes#78357 from sbueringer/fix-golint-pkg-util
Fix golint issues in pkg/util/env
2 parents 00096d8 + fa36b19 commit e0cb161

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ pkg/serviceaccount
230230
pkg/ssh
231231
pkg/util/config
232232
pkg/util/ebtables
233-
pkg/util/env
234233
pkg/util/goroutinemap/exponentialbackoff
235234
pkg/util/iptables
236235
pkg/util/iptables/testing

pkg/util/env/env.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ import (
2121
"strconv"
2222
)
2323

24+
// GetEnvAsStringOrFallback returns the env variable for the given key
25+
// and falls back to the given defaultValue if not set
2426
func GetEnvAsStringOrFallback(key, defaultValue string) string {
2527
if v := os.Getenv(key); v != "" {
2628
return v
2729
}
2830
return defaultValue
2931
}
3032

33+
// GetEnvAsIntOrFallback returns the env variable (parsed as integer) for
34+
// the given key and falls back to the given defaultValue if not set
3135
func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
3236
if v := os.Getenv(key); v != "" {
3337
value, err := strconv.Atoi(v)
@@ -39,6 +43,8 @@ func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
3943
return defaultValue, nil
4044
}
4145

46+
// GetEnvAsFloat64OrFallback returns the env variable (parsed as float64) for
47+
// the given key and falls back to the given defaultValue if not set
4248
func GetEnvAsFloat64OrFallback(key string, defaultValue float64) (float64, error) {
4349
if v := os.Getenv(key); v != "" {
4450
value, err := strconv.ParseFloat(v, 64)

0 commit comments

Comments
 (0)