mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix golint issues in pkg/util/env
This commit is contained in:
parent
898042007c
commit
fa36b19e79
@ -230,7 +230,6 @@ pkg/serviceaccount
|
||||
pkg/ssh
|
||||
pkg/util/config
|
||||
pkg/util/ebtables
|
||||
pkg/util/env
|
||||
pkg/util/goroutinemap/exponentialbackoff
|
||||
pkg/util/iptables
|
||||
pkg/util/iptables/testing
|
||||
|
6
pkg/util/env/env.go
vendored
6
pkg/util/env/env.go
vendored
@ -21,6 +21,8 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// GetEnvAsStringOrFallback returns the env variable for the given key
|
||||
// and falls back to the given defaultValue if not set
|
||||
func GetEnvAsStringOrFallback(key, defaultValue string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
@ -28,6 +30,8 @@ func GetEnvAsStringOrFallback(key, defaultValue string) string {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
// GetEnvAsIntOrFallback returns the env variable (parsed as integer) for
|
||||
// the given key and falls back to the given defaultValue if not set
|
||||
func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
value, err := strconv.Atoi(v)
|
||||
@ -39,6 +43,8 @@ func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error) {
|
||||
return defaultValue, nil
|
||||
}
|
||||
|
||||
// GetEnvAsFloat64OrFallback returns the env variable (parsed as float64) for
|
||||
// the given key and falls back to the given defaultValue if not set
|
||||
func GetEnvAsFloat64OrFallback(key string, defaultValue float64) (float64, error) {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
value, err := strconv.ParseFloat(v, 64)
|
||||
|
Loading…
Reference in New Issue
Block a user