1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/cmd/internal/check.go
Emmanuel Ferdman a1bc85a912
fix: typo in check cmd (#7733)
Signed-off-by: emmanuel-ferdman <emmanuelferdman@gmail.com>
2023-07-02 11:40:14 +02:00

28 lines
662 B
Go

package internal
import (
"errors"
"os"
"github.com/go-logr/logr"
)
func check(logger logr.Logger) {
checkEnvVar(logger, "KYVERNO_NAMESPACE")
checkEnvVar(logger, "KYVERNO_SERVICEACCOUNT_NAME")
checkEnvVar(logger, "KYVERNO_DEPLOYMENT")
checkEnvVar(logger, "KYVERNO_POD_NAME")
checkEnvVar(logger, "INIT_CONFIG")
checkEnvVar(logger, "METRICS_CONFIG")
}
func checkEnvVar(logger logr.Logger, name string) {
checkError(logger, validateEnvVar(name), "please define the environment variable", "name", name)
}
func validateEnvVar(name string) error {
if os.Getenv(name) == "" {
return errors.New("environment variable must be defined")
}
return nil
}