fix: allow empty value for env_pair

This commit is contained in:
Stephan Seitz 2022-01-12 22:43:34 +01:00
parent dd2673d44c
commit 44be8fbf72
6 changed files with 4261 additions and 3412 deletions

View file

@ -1,10 +1,10 @@
================== ================================================================================
Add Add
================== ================================================================================
ADD /$FOO ./${bar} ADD /$FOO ./${bar}
--- --------------------------------------------------------------------------------
(source_file (source_file
(add_instruction (add_instruction
@ -15,13 +15,13 @@ ADD /$FOO ./${bar}
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Copy Copy
================== ================================================================================
COPY $FOO ./${bar} COPY $FOO ./${bar}
--- --------------------------------------------------------------------------------
(source_file (source_file
(copy_instruction (copy_instruction
@ -32,13 +32,13 @@ COPY $FOO ./${bar}
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Special chars Special chars
================== ================================================================================
COPY $FOO ./${bar:-abc} COPY $FOO ./${bar:-abc}
--- --------------------------------------------------------------------------------
(source_file (source_file
(copy_instruction (copy_instruction
@ -49,16 +49,16 @@ COPY $FOO ./${bar:-abc}
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Env Env
================== ================================================================================
ENV TEST="foo$BAR" \ ENV TEST="foo$BAR" \
TEST_2=foo\ bar$BAZ \ TEST_2=foo\ bar$BAZ \
TEST_3="foo${bar}" \ TEST_3="foo${bar}" \
TEST_4=foo\ ${baz}bar TEST_4=foo\ ${baz}bar
--- --------------------------------------------------------------------------------
(source_file (source_file
(env_instruction (env_instruction
@ -86,26 +86,58 @@ ENV TEST="foo$BAR" \
(expansion (expansion
(variable)))))) (variable))))))
================== ================================================================================
Empty Env
================================================================================
ENV TEST= \
TEST_2= \
TEST_3="foo${bar}" \
TEST_4=
ENV FOO=
--------------------------------------------------------------------------------
(source_file
(env_instruction
(env_pair
(unquoted_string))
(line_continuation)
(env_pair
(unquoted_string))
(line_continuation)
(env_pair
(unquoted_string)
(double_quoted_string
(expansion
(variable))))
(line_continuation)
(env_pair
(unquoted_string)))
(env_instruction
(env_pair
(unquoted_string))))
================================================================================
Expose Expose
================== ================================================================================
EXPOSE $FOO EXPOSE $FOO
--- --------------------------------------------------------------------------------
(source_file (source_file
(expose_instruction (expose_instruction
(expansion (expansion
(variable)))) (variable))))
================== ================================================================================
From From
================== ================================================================================
FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
--- --------------------------------------------------------------------------------
(source_file (source_file
(from_instruction (from_instruction
@ -123,13 +155,13 @@ FROM foo/$FOO:$BAR@sha256:$BAZ AS baz$QUX
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Label Label
================== ================================================================================
LABEL key="value$FOO" LABEL key="value$FOO"
--- --------------------------------------------------------------------------------
(source_file (source_file
(label_instruction (label_instruction
@ -139,26 +171,26 @@ LABEL key="value$FOO"
(expansion (expansion
(variable)))))) (variable))))))
================== ================================================================================
Stopsignal Stopsignal
================== ================================================================================
STOPSIGNAL $FOO STOPSIGNAL $FOO
--- --------------------------------------------------------------------------------
(source_file (source_file
(stopsignal_instruction (stopsignal_instruction
(expansion (expansion
(variable)))) (variable))))
================== ================================================================================
User User
================== ================================================================================
USER foo$FOO:bar${bar} USER foo$FOO:bar${bar}
--- --------------------------------------------------------------------------------
(source_file (source_file
(user_instruction (user_instruction
@ -169,14 +201,14 @@ USER foo$FOO:bar${bar}
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Volume Volume
================== ================================================================================
volume /my$FOO /my${bar} volume /my$FOO /my${bar}
--- --------------------------------------------------------------------------------
(source_file (source_file
(volume_instruction (volume_instruction
@ -187,13 +219,13 @@ volume /my$FOO /my${bar}
(expansion (expansion
(variable))))) (variable)))))
================== ================================================================================
Workdir Workdir
================== ================================================================================
WORKDIR /tmp/$FOO WORKDIR /tmp/$FOO
--- --------------------------------------------------------------------------------
(source_file (source_file
(workdir_instruction (workdir_instruction
@ -201,14 +233,13 @@ WORKDIR /tmp/$FOO
(expansion (expansion
(variable))))) (variable)))))
================================================================================
==================
Onbuild Onbuild
================== ================================================================================
ONBUILD ADD /$FOO ./${bar} ONBUILD ADD /$FOO ./${bar}
--- --------------------------------------------------------------------------------
(source_file (source_file
(onbuild_instruction (onbuild_instruction

View file

@ -180,7 +180,7 @@ module.exports = grammar({
seq( seq(
field("name", $._env_key), field("name", $._env_key),
token.immediate("="), token.immediate("="),
field("value", choice($.double_quoted_string, $.unquoted_string)) optional(field("value", choice($.double_quoted_string, $.unquoted_string)))
), ),
_spaced_env_pair: ($) => _spaced_env_pair: ($) =>

View file

@ -857,6 +857,9 @@
"value": "=" "value": "="
} }
}, },
{
"type": "CHOICE",
"members": [
{ {
"type": "FIELD", "type": "FIELD",
"name": "value", "name": "value",
@ -873,6 +876,11 @@
} }
] ]
} }
},
{
"type": "BLANK"
}
]
} }
] ]
}, },
@ -1045,7 +1053,23 @@
] ]
}, },
"image_name": { "image_name": {
"type": "REPEAT1", "type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[^@:\\s\\$-]"
},
{
"type": "SYMBOL",
"name": "expansion"
}
]
},
{
"type": "REPEAT",
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -1059,6 +1083,8 @@
} }
] ]
} }
}
]
}, },
"image_tag": { "image_tag": {
"type": "SEQ", "type": "SEQ",
@ -1235,8 +1261,13 @@
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "ALIAS",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "line_continuation" "name": "required_line_continuation"
},
"named": true,
"value": "line_continuation"
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
@ -1274,6 +1305,10 @@
"type": "STRING", "type": "STRING",
"value": "\\\n" "value": "\\\n"
}, },
"required_line_continuation": {
"type": "STRING",
"value": "\\\n"
},
"_comment_line": { "_comment_line": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

View file

@ -165,7 +165,7 @@
}, },
"value": { "value": {
"multiple": false, "multiple": false,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "double_quoted_string", "type": "double_quoted_string",
@ -408,6 +408,11 @@
} }
} }
}, },
{
"type": "line_continuation",
"named": true,
"fields": {}
},
{ {
"type": "maintainer_instruction", "type": "maintainer_instruction",
"named": true, "named": true,
@ -910,6 +915,10 @@
"type": "[", "type": "[",
"named": false "named": false
}, },
{
"type": "\\\n",
"named": false
},
{ {
"type": "\\ ", "type": "\\ ",
"named": false "named": false
@ -922,10 +931,6 @@
"type": "escape_sequence", "type": "escape_sequence",
"named": true "named": true
}, },
{
"type": "line_continuation",
"named": true
},
{ {
"type": "variable", "type": "variable",
"named": true "named": true

File diff suppressed because it is too large Load diff

View file

@ -102,8 +102,8 @@ struct TSLanguage {
const uint16_t *small_parse_table; const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map; const uint32_t *small_parse_table_map;
const TSParseActionEntry *parse_actions; const TSParseActionEntry *parse_actions;
const char * const *symbol_names; const char **symbol_names;
const char * const *field_names; const char **field_names;
const TSFieldMapSlice *field_map_slices; const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries; const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata; const TSSymbolMetadata *symbol_metadata;