Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted keys and values are not parsed correctly #30

Closed
rcjsuen opened this issue May 24, 2018 · 0 comments
Closed

Quoted keys and values are not parsed correctly #30

rcjsuen opened this issue May 24, 2018 · 0 comments
Assignees
Labels

Comments

@rcjsuen
Copy link
Owner

rcjsuen commented May 24, 2018

It's okay to put quotes around the individual keys and values of a key-value pair in ARG, ENV, and LABEL. They should of course be stripped out from the actual value.

FROM alpine
ARG "aaa"="bbb"
ENV "ccc"="ddd"
LABEL "eee"="fff"
RUN echo $aaa
RUN echo $ccc
$ docker build .
Sending build context to Docker daemon  1.693MB
Step 1/6 : FROM alpine
 ---> 3fd9065eaf02
Step 2/6 : ARG "aaa"="bbb"
 ---> Running in 20b77196bad8
Removing intermediate container 20b77196bad8
 ---> 9e77ad80e9ed
Step 3/6 : ENV "ccc"="ddd"
 ---> Running in e2568271365b
Removing intermediate container e2568271365b
 ---> e19436f8431a
Step 4/6 : LABEL "eee"="fff"
 ---> Running in a0ee3aa9549e
Removing intermediate container a0ee3aa9549e
 ---> 71cf3db4566e
Step 5/6 : RUN echo $aaa
 ---> Running in 6bb97ff8336b
bbb
Removing intermediate container 6bb97ff8336b
 ---> 1c08388d111c
Step 6/6 : RUN echo $ccc
 ---> Running in 656632f6b97f
ddd
Removing intermediate container 656632f6b97f
 ---> a351391c8188
Successfully built a351391c8188
$ docker inspect a351391c8188 --format={{.ContainerConfig.Labels}}
map[eee:fff]

However, the quotes seem to be confusing the parser and it's causing the value to not be calculated correctly. The name is also not being stripped of the quotes.

import { DockerfileParser, Label } 'dockerfile-ast';
import { TextDocument } from 'vscode-languageserver-types/lib/umd/main';

const content =
`ARG "aaa"="bbb"
ENV "ccc"="ddd"
LABEL "eee"="fff"`;

let dockerfile = DockerfileParser.parse(content);
console.log(dockerfile.getARGs()[0].getProperties()[0].getName());
console.log(dockerfile.getARGs()[0].getProperties()[0].getValue());
console.log(dockerfile.getARGs()[0].getProperties()[0].getUnescapedValue());
console.log(dockerfile.getENVs()[0].getProperties()[0].getName());
console.log(dockerfile.getENVs()[0].getProperties()[0].getValue());
console.log(dockerfile.getENVs()[0].getProperties()[0].getUnescapedValue());
console.log((dockerfile.getInstructions()[2] as Label).getProperties()[0].getName());
console.log((dockerfile.getInstructions()[2] as Label).getProperties()[0].getValue());
console.log((dockerfile.getInstructions()[2] as Label).getProperties()[0].getUnescapedValue());
"aaa"
="bbb"
="bbb"
"ccc"
="ddd"
="ddd"
"eee"
="fff"
="fff"
@rcjsuen rcjsuen added the bug label May 24, 2018
@rcjsuen rcjsuen self-assigned this May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant