Add `resolve_vars_with_context` to find variable names in an image
Building on v0.6.0's ImageRef::resolve_vars(&self, &dockerfile)
, this adds an additional function, ImageRef::resolve_vars_with_context(&self &dockerfile)
, to additionally return a HashSet
of all variables referenced (both directly and indirectly) in the image string.
Additionally, Stage::arg_index(&self, &str)
was added to determine if a given stage references a particular ARG
, and if so, after which instruction index it becomes available to other instructions within that stage. As the Dockerfile's scoping rules require build stages to redefine all ARG
s, the presence of a duplicate ARG
instruction should reliably indicate whether or not a build stage actually used a given ARG
outside of its FROM
.
These two functions can be used together to help determine if a particular ARG
is actually used within a given Dockerfile or if a parameterized image string can be automatically replaced with its variable-free equivalent.