Merge pull request #7 from returntocorp/mj-from-param

Prevent '--platform=xxx' after 'FROM' from being mistaken for the image name
This commit is contained in:
Camden Cheek 2022-01-05 20:55:06 -07:00 committed by GitHub
commit dd2673d44c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)) digest: (image_digest))
as: (image_alias))) 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\$-]/, $.expansion),
repeat(choice(/[^@:\s\$]+/, $.expansion))
),
image_tag: ($) => image_tag: ($) =>
seq( seq(