tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.58k stars 298 forks source link

Can't call load inside of an if statement in Tiltfile #3524

Open jazzdan opened 4 years ago

jazzdan commented 4 years ago

Via k8s slack DM:

Hi, do you know smth about such error during tilt up ? load statement within a conditional I have a load inside if condition

I traced it to this issue and resulting commit from Starlark where they recently disallowed loads inside if statements and for statements.

There's at least one Tiltfile out there that depends on this behavior, and probably more. In fact our own Tiltfiles used to depend on this behavior when we had our internal services in microrepos with one Tilt repo to manage them. The Tiltfile would check to see which microrepos are cloned locally, and only if it was present in the expected location on disk would it then load that microrepo's Tiltfile. In fact: we still recommend this setup. We've since moved to a monorepo, but if any customers are using a similar set up their Tiltfiles would now be broken.

nicks commented 4 years ago

I think it's pretty clear allowing load() in an if block was a bug in Starlark-Go.

Starlark-Java doesn't allow this, and in fact, can't allow this, because it would break the ability to determine what files are loaded at parse-time (i.e., without executing the code)

We probably have to move forward with https://github.com/tilt-dev/tilt/issues/3433 to resolve this, and recommend include() as the execution-time way to load code

nicks commented 4 years ago

@jazzdan do you have a sense of how urgent this is? a short-term fix is to fork starlark-go, rollback the fix for now, and then have a plan to move forward with a workaround

jazzdan commented 4 years ago

@nicks I don't have a sense yet, no. Following up with the user.

jazzdan commented 4 years ago

@nicks it's not blocking, they can work around it.