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 Mar 31, 2024
1 parent bfdb3e4 commit 96222e4
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 0 deletions.
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 96222e4

Please sign in to comment.