Skip to content

Commit

Permalink
Reworked activation helper env var check
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Lopukhov <[email protected]>
  • Loading branch information
alopukhov committed Jul 14, 2024
1 parent 023e922 commit d0094f0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/rootlesskit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ const (
)

func main() {
iAmActivationHelper, err := strconv.ParseBool(os.Getenv(runActivationHelperEnvKey))
if err != nil {
iAmActivationHelper = false
}
iAmActivationHelper := checkActivationHelper()
iAmChild := os.Getenv(pipeFDEnvKey) != ""
id := "parent"
if iAmChild {
Expand Down Expand Up @@ -686,6 +683,18 @@ func unameM() string {
return machine
}

func checkActivationHelper() bool {
envValue, envSet := os.LookupEnv(runActivationHelperEnvKey)
if !envSet {
return false
}
activationHelperValue, err := strconv.ParseBool(envValue)
if err != nil {
panic(fmt.Sprintf("Env variable [%s] is set to [%s] and cannot be parsed", runActivationHelperEnvKey, envValue))
}
return activationHelperValue
}

func createActivationOpts(clicontext *cli.Context) (activation.Opt, error) {
opt := activation.Opt {
RunActivationHelperEnvKey: runActivationHelperEnvKey,
Expand Down

0 comments on commit d0094f0

Please sign in to comment.