mirror of
https://github.com/ysoftdevs/imagepullsecret-injector.git
synced 2026-03-11 21:05:47 +01:00
Refactor helper methods into a separate file
This commit is contained in:
29
cmd/main.go
29
cmd/main.go
@@ -8,40 +8,11 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
func LookupStringEnv(envName string, defVal string) string {
|
||||
if envVal, exists := os.LookupEnv(envName); exists {
|
||||
return envVal
|
||||
}
|
||||
|
||||
return defVal
|
||||
}
|
||||
|
||||
func LookupBoolEnv(envName string, defVal bool) bool {
|
||||
if envVal, exists := os.LookupEnv(envName); exists {
|
||||
if boolVal, err := strconv.ParseBool(envVal); err == nil {
|
||||
return boolVal
|
||||
}
|
||||
}
|
||||
|
||||
return defVal
|
||||
}
|
||||
|
||||
func LookupIntEnv(envName string, defVal int) int {
|
||||
if envVal, exists := os.LookupEnv(envName); exists {
|
||||
if intVal, err := strconv.Atoi(envVal); err == nil {
|
||||
return intVal
|
||||
}
|
||||
}
|
||||
|
||||
return defVal
|
||||
}
|
||||
|
||||
func main() {
|
||||
parameters := DefaultParametersObject()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user