Skip to content

Commit

Permalink
Containerfile: new parser
Browse files Browse the repository at this point in the history
Close universal-ctags#3970

Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed May 10, 2024
1 parent bfdb3e4 commit d4e46fe
Show file tree
Hide file tree
Showing 13 changed files with 530 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Tmain/list-map-patterns.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## all|grep LdScript
#LANGUAGE PATTERN
LdScript *.lds.S
LdScript ld.script
#LANGUAGE PATTERN
LdScript *.lds.S
LdScript ld.script
## LdScript
#PATTERN
*.lds.S
Expand Down
2 changes: 2 additions & 0 deletions Tmain/list-roles.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CUDA h/header system on system header
Cobol S/sourcefile copied on copied in source file
CobolFree S/sourcefile copied on copied in source file
CobolVariable S/sourcefile copied on copied in source file
Containerfile i/image base on referenced as a base image in FROM directive
DTD e/element attOwner on attributes owner
DTD p/parameterEntity condition on conditions
DTD p/parameterEntity elementName on element names
Expand Down Expand Up @@ -192,6 +193,7 @@ CUDA h/header system on system header
Cobol S/sourcefile copied on copied in source file
CobolFree S/sourcefile copied on copied in source file
CobolVariable S/sourcefile copied on copied in source file
Containerfile i/image base on referenced as a base image in FROM directive
DTD e/element attOwner on attributes owner
DTD p/parameterEntity condition on conditions
DTD p/parameterEntity elementName on element names
Expand Down
3 changes: 3 additions & 0 deletions Units/parser-containerfile.r/env.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--language-force=Containerfile
--fields=+in
16 changes: 16 additions & 0 deletions Units/parser-containerfile.r/env.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
img27634bbb0100 input.container /^FROM ubi8:latest$/;" i line:2 inherits:ubi8:latest
MY_NAME input.container /^ENV MY_NAME="John Doe"$/;" e line:4 image:img27634bbb0100
MY_DOG input.container /^ENV MY_DOG=Rex\\ The\\ Dog$/;" e line:5 image:img27634bbb0100
MY_CAT input.container /^ENV MY_CAT=fluffy$/;" e line:6 image:img27634bbb0100
MY_X input.container /^ENV MY_X=fluffy MY_Y="a" MY_Z=b$/;" e line:7 image:img27634bbb0100
MY_Y input.container /^ENV MY_X=fluffy MY_Y="a" MY_Z=b$/;" e line:7 image:img27634bbb0100
MY_Z input.container /^ENV MY_X=fluffy MY_Y="a" MY_Z=b$/;" e line:7 image:img27634bbb0100
MY_A input.container /^ENV MY_A=fluffy \\$/;" e line:8 image:img27634bbb0100
MY_B input.container /^MY_B="a" \\$/;" e line:9 image:img27634bbb0100
MY_C input.container /^MY_C=b$/;" e line:10 image:img27634bbb0100
YOUR_A input.container /^ENV YOUR_A "a"$/;" e line:12 image:img27634bbb0100
YOUR_B input.container /^ENV YOUR_B "b" \\$/;" e line:13 image:img27634bbb0100
YOUR_C input.container /^ YOUR_C "c" \\$/;" e line:14 image:img27634bbb0100
YOUR_D input.container /^ YOUR_D \\$/;" e line:15 image:img27634bbb0100
MY_HOUSE input.container /^ENV MY_HOUSE "a" MY_FAMILY "a"$/;" e line:18 image:img27634bbb0100
MY_FAMILY input.container /^ENV MY_HOUSE "a" MY_FAMILY "a"$/;" e line:18 image:img27634bbb0100
18 changes: 18 additions & 0 deletions Units/parser-containerfile.r/env.d/input.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://docs.docker.jp/engine/reference/builder.html#env
FROM ubi8:latest

ENV MY_NAME="John Doe"
ENV MY_DOG=Rex\ The\ Dog
ENV MY_CAT=fluffy
ENV MY_X=fluffy MY_Y="a" MY_Z=b
ENV MY_A=fluffy \
MY_B="a" \
MY_C=b

ENV YOUR_A "a"
ENV YOUR_B "b" \
YOUR_C "c" \
YOUR_D \
YOUR_E

ENV MY_HOUSE "a" MY_FAMILY "a"
4 changes: 4 additions & 0 deletions Units/parser-containerfile.r/multi.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--sort=no
--language-force=Containerfile
--fields=+inrl
--extras=+r
17 changes: 17 additions & 0 deletions Units/parser-containerfile.r/multi.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
X input.containerfile /^#define X /;" d line:3 language:CPreProcessor file: roles:def
busybox:latest input.containerfile /^FROM busybox:latest AS builder$/;" i line:5 language:Containerfile roles:base
builder input.containerfile /^FROM busybox:latest AS builder$/;" i line:5 language:Containerfile inherits:busybox:latest roles:def
BUILD_LOGLEVEL input.containerfile /^ENV 'BUILD'"_LOGLEVEL"="5" A=1$/;" e line:6 language:Containerfile image:builder roles:def
A input.containerfile /^ENV 'BUILD'"_LOGLEVEL"="5" A=1$/;" e line:6 language:Containerfile image:builder roles:def
OPENSHIFT_BUILD_NAME input.containerfile /^ENV "OPENSHIFT_BUILD_NAME"="mydockertest-1" "OPENSHIFT_BUILD_NAMESPACE"="default"$/;" e line:9 language:Containerfile image:builder roles:def
OPENSHIFT_BUILD_NAMESPACE input.containerfile /^ENV "OPENSHIFT_BUILD_NAME"="mydockertest-1" "OPENSHIFT_BUILD_NAMESPACE"="default"$/;" e line:9 language:Containerfile image:builder roles:def
io.openshift.build.name input.containerfile /^LABEL "io.openshift.build.name"="mydockertest-1" "io.openshift.build.namespace"="default"$/;" l line:10 language:Containerfile image:builder roles:def
io.openshift.build.namespace input.containerfile /^LABEL "io.openshift.build.name"="mydockertest-1" "io.openshift.build.namespace"="default"$/;" l line:10 language:Containerfile image:builder roles:def
Y input.containerfile /^#define Y /;" d line:12 language:CPreProcessor file: roles:def
builder input.containerfile /^FROM builder$/;" i line:14 language:Containerfile roles:base
img7a86bc1d0100 input.containerfile /^FROM builder$/;" i line:14 language:Containerfile inherits:builder roles:def
BUILD_LOGLEVEL input.containerfile /^ENV "BUILD_LOGLEVEL"="5"$/;" e line:15 language:Containerfile image:img7a86bc1d0100 roles:def
Z input.containerfile /^#define Z /;" d line:18 language:CPreProcessor file: roles:def
builder input.containerfile /^FROM builder$/;" i line:20 language:Containerfile roles:base
img7a86bc1d0200 input.containerfile /^FROM builder$/;" i line:20 language:Containerfile inherits:builder roles:def
BUILD_LOGLEVEL input.containerfile /^ENV "BUILD_LOGLEVEL"="5"$/;" e line:21 language:Containerfile image:img7a86bc1d0200 roles:def
22 changes: 22 additions & 0 deletions Units/parser-containerfile.r/multi.d/input.containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Based on https://github.com/containers/buildah/blob/main/tests/bud/multi-stage-builds/Dockerfile.extended

#define X 1

FROM busybox:latest AS builder
ENV 'BUILD'"_LOGLEVEL"="5" A=1
RUN touch /tmp/preCommit
ENTRYPOINT /bin/sleep 600
ENV "OPENSHIFT_BUILD_NAME"="mydockertest-1" "OPENSHIFT_BUILD_NAMESPACE"="default"
LABEL "io.openshift.build.name"="mydockertest-1" "io.openshift.build.namespace"="default"

#define Y 1

FROM builder
ENV "BUILD_LOGLEVEL"="5"
RUN touch /tmp/postCommit

#define Z 1

FROM builder
ENV "BUILD_LOGLEVEL"="5"
RUN echo "$BUILD_LOGLEVEL"
1 change: 1 addition & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
CobolParser, \
CobolFreeParser, \
CobolVariableParser, \
ContainerfileParser, \
CUDAParser, \
DParser, \
DiffParser, \
Expand Down
Loading

0 comments on commit d4e46fe

Please sign in to comment.