AST: encode the specific form of pair in the AST #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LABEL
andENV
instructions to their own filesDocker currently supports two forms for key value pairs. The
key=value
syntax and the deprecated
key value
syntax. These are primarily usedin the
ENV
andLABEL
instructions.This change adds encoding for which form was parsed to the syntax tree.
Having this information can be used e.g. to warn about the use of
deprecated syntax and to specify which syntax form the pretty printer
should produce.
This is a draft PR because I am not sure if this is the best way to do this, but I need feedback to decide.
On the one hand this breaks backward compatibility quite badly, on the other hand, every other way to encode the parsed syntax version in the AST will also break backwards compatibility.
Motivation for this change is that it is needed for hadolint/hadolint#752, because without it, looking at the AST does not show which syntax was used in the
ENV
respectivelyLABEL
instruction.An alternative implementation would be to extend the
Pairs
type such that it includes annotation about the syntax used something like so:This would have the benefit that it might be possible to convert easily from
[Pair]
toPairs
and thus make migration less painful. However parsing becomes harder.