|
15 | 15 | "[keyword COPY] package*.json ./",
|
16 | 16 | "[keyword RUN] npm install",
|
17 | 17 | "[keyword COPY] . .",
|
18 |
| - "[keyword EXPOSE] 8080 3000", |
| 18 | + "[keyword EXPOSE] [number 8080] [number 3000]", |
19 | 19 | "[keyword ENV] NODE_ENV development",
|
20 |
| - "[keyword CMD] [[\"npm\", \"start\"]]"); |
| 20 | + "[keyword CMD] [[ [string \"npm\"], [string \"start\"] ]]"); |
21 | 21 |
|
22 | 22 | // Ideally the last space should not be highlighted.
|
23 | 23 | MT("instruction_without_args_1",
|
24 |
| - "[keyword CMD ]"); |
| 24 | + "[keyword CMD] "); |
25 | 25 |
|
26 | 26 | MT("instruction_without_args_2",
|
27 | 27 | "[comment # An instruction without args...]",
|
|
35 | 35 | " && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*");
|
36 | 36 |
|
37 | 37 | MT("from_comment",
|
38 |
| - " [keyword FROM] debian:stretch [comment # I tend to use stable as that is more stable]", |
39 |
| - " [keyword FROM] debian:stretch [keyword AS] stable [comment # I am even more stable]", |
| 38 | + " [keyword FROM] debian:stretch # I tend to use stable as that is more stable", |
| 39 | + " [keyword FROM] debian:stretch [keyword AS] stable # I am even more stable", |
40 | 40 | " [keyword FROM] [error # this is an error]");
|
41 | 41 |
|
42 | 42 | MT("from_as",
|
43 | 43 | "[keyword FROM] golang:1.9.2-alpine3.6 [keyword AS] build",
|
44 | 44 | "[keyword COPY] --from=build /bin/project /bin/project",
|
45 |
| - "[keyword ENTRYPOINT] [[\"/bin/project\"]]", |
46 |
| - "[keyword CMD] [[\"--help\"]]"); |
| 45 | + "[keyword ENTRYPOINT] [[ [string \"/bin/project\"] ]]", |
| 46 | + "[keyword CMD] [[ [string \"--help\"] ]]"); |
47 | 47 |
|
48 | 48 | MT("arg",
|
49 | 49 | "[keyword ARG] VERSION=latest",
|
|
52 | 52 | "[keyword RUN] echo $VERSION > image_version");
|
53 | 53 |
|
54 | 54 | MT("label",
|
55 |
| - "[keyword LABEL] com.example.label-with-value=\"foo\"", |
56 |
| - "[keyword LABEL] description=\"This text illustrates \"", |
57 |
| - " that label-values can span multiple lines.\""); |
| 55 | + "[keyword LABEL] com.example.label-with-value=[string \"foo\"]"); |
| 56 | + |
| 57 | + MT("label_multiline", |
| 58 | + "[keyword LABEL] description=[string \"This text illustrates ]\\", |
| 59 | + "[string that label-values can span multiple lines.\"]"); |
58 | 60 |
|
59 | 61 | MT("maintainer",
|
60 |
| - "[keyword MAINTAINER] Foo Bar \"foo@bar.com\"", |
| 62 | + "[keyword MAINTAINER] Foo Bar [string \"foo@bar.com\"] ", |
61 | 63 | "[keyword MAINTAINER] Bar Baz <bar@baz.com>");
|
62 | 64 |
|
| 65 | + MT("env", |
| 66 | + "[keyword ENV] BUNDLE_PATH=[string \"$GEM_HOME\"] \\", |
| 67 | + " BUNDLE_APP_CONFIG=[string \"$GEM_HOME\"]"); |
| 68 | + |
63 | 69 | MT("verify_keyword",
|
64 | 70 | "[keyword RUN] add-apt-repository ppa:chris-lea/node.js");
|
65 | 71 |
|
66 | 72 | MT("scripts",
|
67 | 73 | "[comment # Set an entrypoint, to automatically install node modules]",
|
68 |
| - "[keyword ENTRYPOINT] [[\"/bin/bash\", \"-c\", \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"]]", |
| 74 | + "[keyword ENTRYPOINT] [[ [string \"/bin/bash\"], [string \"-c\"], [string \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"] ]]", |
69 | 75 | "[keyword CMD] npm start",
|
70 |
| - "[keyword RUN] npm run build && npm run test"); |
| 76 | + "[keyword RUN] npm run build && \\", |
| 77 | + "[comment # a comment between the shell commands]", |
| 78 | + " npm run test"); |
| 79 | + |
| 80 | + MT("strings_single", |
| 81 | + "[keyword FROM] buildpack-deps:stretch", |
| 82 | + "[keyword RUN] { \\", |
| 83 | + " echo [string 'install: --no-document']; \\", |
| 84 | + " echo [string 'update: --no-document']; \\", |
| 85 | + " } >> /usr/local/etc/gemrc"); |
| 86 | + |
| 87 | + MT("strings_single_multiline", |
| 88 | + "[keyword RUN] set -ex \\", |
| 89 | + " \\", |
| 90 | + " && buildDeps=[string ' ]\\", |
| 91 | + "[string bison ]\\", |
| 92 | + "[string dpkg-dev ]\\", |
| 93 | + "[string libgdbm-dev ]\\", |
| 94 | + "[string ruby ]\\", |
| 95 | + "[string '] \\", |
| 96 | + " && apt-get update"); |
| 97 | + |
| 98 | + MT("strings_single_multiline_2", |
| 99 | + "[keyword RUN] echo [string 'say \\' ]\\", |
| 100 | + "[string it works'] "); |
| 101 | + |
| 102 | + MT("strings_double", |
| 103 | + "[keyword RUN] apt-get install -y --no-install-recommends $buildDeps \\", |
| 104 | + " \\", |
| 105 | + " && wget -O ruby.tar.xz [string \"https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz\"] \\", |
| 106 | + " && echo [string \"$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz\"] | sha256sum -c - "); |
| 107 | + |
| 108 | + MT("strings_double_multiline", |
| 109 | + "[keyword RUN] echo [string \"say \\\" ]\\", |
| 110 | + "[string it works\"] "); |
| 111 | + |
| 112 | + MT("escape", |
| 113 | + "[comment # escape=`]", |
| 114 | + "[keyword FROM] microsoft/windowsservercore", |
| 115 | + "[keyword RUN] powershell.exe -Command `", |
| 116 | + " $ErrorActionPreference = [string 'Stop']; `", |
| 117 | + " wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; `", |
| 118 | + " Start-Process c:\python-3.5.1.exe -ArgumentList [string '/quiet InstallAllUsers=1 PrependPath=1'] -Wait ; `", |
| 119 | + " Remove-Item c:\python-3.5.1.exe -Force)"); |
| 120 | + |
| 121 | + MT("escape_strings", |
| 122 | + "[comment # escape=`]", |
| 123 | + "[keyword FROM] python:3.6-windowsservercore [keyword AS] python", |
| 124 | + "[keyword RUN] $env:PATH = [string 'C:\\Python;C:\\Python\\Scripts;{0}'] -f $env:PATH ; `", |
| 125 | + // It should not consider \' as escaped. |
| 126 | + // " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\'] -Name Path -Value $env:PATH ;"); |
| 127 | + " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\' -Name Path -Value $env:PATH ;]"); |
71 | 128 | })();
|
0 commit comments