2023-09-03 22:14:42 +02:00
|
|
|
package experimental
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
2023-09-14 17:17:02 +02:00
|
|
|
const (
|
|
|
|
ExperimentalEnv = "KYVERNO_EXPERIMENTAL"
|
2023-09-19 13:36:29 +02:00
|
|
|
KubectlValidateEnv = "KYVERNO_KUBECTL_VALIDATE" //nolint:gosec
|
2023-09-14 17:17:02 +02:00
|
|
|
)
|
2023-09-03 22:14:42 +02:00
|
|
|
|
2023-12-20 09:37:26 +01:00
|
|
|
func getBool(env string, fallback bool) bool {
|
2023-09-14 17:17:02 +02:00
|
|
|
if b, err := strconv.ParseBool(os.Getenv(env)); err == nil {
|
2023-09-03 22:14:42 +02:00
|
|
|
return b
|
|
|
|
}
|
2023-12-20 09:37:26 +01:00
|
|
|
return fallback
|
2023-09-03 22:14:42 +02:00
|
|
|
}
|
2023-09-14 17:17:02 +02:00
|
|
|
|
|
|
|
func IsEnabled() bool {
|
2023-12-20 09:37:26 +01:00
|
|
|
return getBool(ExperimentalEnv, false)
|
2023-09-14 17:17:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func UseKubectlValidate() bool {
|
2023-12-20 09:37:26 +01:00
|
|
|
return getBool(KubectlValidateEnv, true)
|
2023-09-14 17:17:02 +02:00
|
|
|
}
|