Prevent '--platform=xxx' after 'FROM' from being mistaken for the image name

This commit is contained in:
Martin Jambon 2022-01-05 00:02:15 -08:00
parent 7af32bc04a
commit 37f059a2aa
2 changed files with 19 additions and 1 deletions

View file

@ -71,3 +71,18 @@ FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb
digest: (image_digest))
as: (image_alias)))
==================
From with param
==================
FROM --platform=linux/arm64 alpine-${VERSION}-z
---
(source_file
(from_instruction
(param)
(image_spec
(image_name
(expansion
(variable))))))

View file

@ -211,7 +211,10 @@ module.exports = grammar({
)
),
image_name: ($) => repeat1(choice(/[^@:\s\$]+/, $.expansion)),
image_name: ($) => seq(
choice(/[^@:\s\$-][^@:\s\$]*/, $.expansion),
repeat(choice(/[^@:\s\$]+/, $.expansion))
),
image_tag: ($) =>
seq(