earthly
earthly copied to clipboard
Add a `CONST` Command
Sometimes we may use ARG
with a default value that we treat as a constant. This can be useful for declaring a reusable value at build-time in an Earthfile.
It's not always clear, however, that the ARG is not intended to be overridden with a different value. We may even want to prevent the value from being overridden and causing unexpected behavior.
A CONST
command would improve readability in these cases, as well as prevent users from overriding its value.
Here's how it might look in an Earthfile:
FROM alpine
CONST URL=https://example.com
get-1:
RUN wget "$URL/thing-1"
get-2:
RUN wget "$URL/thing-2"
I imagine this would be straight forward to implement, as we would leverage a lot of the infrastructure we already have for ARG
I imagine the need for that would be way less if https://github.com/earthly/earthly/issues/1575 was implemented.
It would be nice to also consider how we can use an IMPORT
so we can define these CONST
s in a single Earthfile.