Finalizer envs (#242)

* Allow to define envs for finalizer

Fixes: #241

* tests: Add integration test for finalizer with envs
This commit is contained in:
Daniele Rondina
2021-08-11 11:18:16 +02:00
committed by GitHub
parent db784597d7
commit 0cc8930708
9 changed files with 213 additions and 2 deletions

View File

@@ -16,6 +16,9 @@
package util
import (
"errors"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -72,3 +75,19 @@ func SetSolverConfig() (c *config.LuetSolverOptions) {
MaxAttempts: attempts,
}
}
func SetCliFinalizerEnvs(finalizerEnvs []string) error {
if len(finalizerEnvs) > 0 {
for _, v := range finalizerEnvs {
idx := strings.Index(v, "=")
if idx < 0 {
return errors.New("Found invalid runtime finalizer environment: " + v)
}
LuetCfg.SetFinalizerEnv(v[0:idx], v[idx+1:])
}
}
return nil
}