envd
envd copied to clipboard
feat(lang): Support built-in variables
Description
base(os="ubuntu20.04", language="python3")
print(midi.os)
We need to provide some built-in variables to support conditional build like this
if midi.os == "ubuntu":
ubuntu_apt_source("xxx")
IIUC, according to the signature of ExecFile, these built-in variables could only be pre-declared, but the value of os is only known to us in runtime(during the execution of the script) as it is the argument of base function.
If our goal is to get the value of os, could we add another function like current_os()? its usage could be like:
base(os="ubuntu20.04", language="python3")
if current_os() == "ubuntu":
# do something
This issue is related to #91
The design purpose of this feature is to support conditional exec. The func approach LGTM but I am not sure if there is any fancy way to achieve this.
https://github.com/maxmcd/bramble gives us some insights.
Related to #1132