We're using a separate file because the normal convey.yml is setup to work with
current convey, but the docs needs to be built by old convey at the moment.
packageenvironment
import(
"os"
log"github.com/sirupsen/logrus"
)
func(eEnvironment)expandMapper(namestring)string{
// We might have something like $(pwd), in which case we don't want
// to wrap the name in `{}`, which would cause it to be ${}(pwd) and
// cannot be evaluated by a run task.
ifname==""{
return"$"
}
ifval,found:=e[name];found{
ifval!=""{
returnval
}
returnos.Getenv(name)
}
return""
}
// Expand looks for the given key and returns the value if one is found
// recursing if the value contains another variable.
func(eEnvironment)Expand(keystring)string{
last:=os.Expand(key,e.expandMapper)
n_tries:=10
fori:=0;i<n_tries;i++{
next:=os.Expand(last,e.expandMapper)
ifnext==last{
returnnext
}
last=next
}
log.Warnf("failed to fully expand %q after %d recursions",key,n_tries)