kool-dev / kool

From local development to the cloud: web apps development with containers made easy.

Home Page:https://kool.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kool persists flags and environment on recursive commands execution

danielsuguimoto opened this issue · comments

Describe the bug

When executing kool run with multiple commands and the script commands are also kool commands, kool execute itself again for the children commands. But for each iteration, the flags from the previous execution is persisted for the current one.

Kool version and environment

kool 1.10.1

To Reproduce

Create a script like this:

script:
  - kool cmd -f "VALUE"
  - kool cmd -f "OTHER_VALUE"

On the second iteration, the command already has the flag set with "VALUE" even before parsing the flag. If it is a string variable, the flag will be overwritten...but if it is an array, both flags from the entire script will be concatenated on the second command.

Expected behavior

The flags for each iteration should be reset.

The same situation about flags persisting also happens for the whole environment variables parsing. This was initially reported and discussed on #290

@danielsuguimoto with the just merged #291 - the only thing I am not sure is about the environment reloading... did you check if environment.NewEnvStorage() will indeed parse files all over again?

@danielsuguimoto with the just merged #291 - the only thing I am not sure is about the environment reloading... did you check if environment.NewEnvStorage() will indeed parse files all over again?

@fabriciojs env storage is just a struct that creates a abstraction layer for os package for handling environment variables...all environment variables are loaded in kool entrypoint, main.go only

That is right! I am reopening this then so we follow up with the environment reloading per recursive call... does that make sense?

That is right! I am reopening this then so we follow up with the environment reloading per recursive call... does that make sense?

Sure...I didn't add it to this PR because I thought we were still discussing about it

The environment variable update within scripts is not necessarily an issue. Closing this until we have more info to ideas or vision in case this should be different than today's implementation.