1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package env 18 19 import ( 20 "sigs.k8s.io/release-utils/env/internal" 21 ) 22 23 // Default returns either the provided environment variable for the given key 24 // or the default value def if not set. 25 func Default(key, def string) string { 26 value, ok := internal.Impl.LookupEnv(key) 27 if !ok || value == "" { 28 return def 29 } 30 return value 31 } 32 33 // IsSet returns true if an environment variable is set. 34 func IsSet(key string) bool { 35 _, ok := internal.Impl.LookupEnv(key) 36 return ok 37 } 38