mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
a1bc85a912
Signed-off-by: emmanuel-ferdman <emmanuelferdman@gmail.com>
28 lines
662 B
Go
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
|
|
}
|