envd icon indicating copy to clipboard operation
envd copied to clipboard

feat(lang): Support built-in variables

Open gaocegege opened this issue 3 years ago • 3 comments

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")

gaocegege avatar Apr 25 '22 06:04 gaocegege

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

knight42 avatar May 12 '22 15:05 knight42

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.

gaocegege avatar May 13 '22 00:05 gaocegege

Related to #1132

kemingy avatar Nov 10 '22 09:11 kemingy