dockerfile-rb 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +7 -1
- data/.github/workflows/release.yml +2 -3
- data/.gitignore +2 -0
- data/CHANGELOG.md +25 -0
- data/README.md +3 -2
- data/dockerfile-rb.gemspec +1 -1
- data/lib/dockerfile-rb/expose.rb +6 -2
- data/lib/dockerfile-rb/grammars/dockerfile.citrus +42 -32
- data/lib/dockerfile-rb/version.rb +1 -1
- metadata +6 -7
- data/.travis.yml +0 -7
- data/Gemfile.lock +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663aa3f090391de7b468e62880fc66e97a5bd7c57a03d0d786f71f75f08f32e6
|
4
|
+
data.tar.gz: 9df143eb94746540c6845ec09a68157c337267c612c76bcb918c50fba7c4c3c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2999672e3c952718aeb3bf011b3b472d6e5ae3a7eca6aef9da8466770fa37662cdfeb19a81b96befd8417e29c11e761259e27bfbdcee9593bbd7933c4dc16963
|
7
|
+
data.tar.gz: 7c263c8dd367e0c0bb2fc57590cb851ace3d3fdfd46001179b6fb02e1e475f0ee24693487a6263ebb050eb90895b610c1283dcebd52d718e182b33c2527a5388
|
data/.github/workflows/rake.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v0.2.0](https://github.com/gscho/dockerfile-rb/tree/v0.2.0) (2021-09-29)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/gscho/dockerfile-rb/compare/0.1.0...v0.2.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Add support for variables [\#4](https://github.com/gscho/dockerfile-rb/pull/4) ([gscho](https://github.com/gscho))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- variable looks not supported [\#2](https://github.com/gscho/dockerfile-rb/issues/2)
|
14
|
+
|
15
|
+
## [0.1.0](https://github.com/gscho/dockerfile-rb/tree/0.1.0) (2020-05-10)
|
16
|
+
|
17
|
+
[Full Changelog](https://github.com/gscho/dockerfile-rb/compare/1908994ec01bb02077da3fb5efc975c90e591716...0.1.0)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#1](https://github.com/gscho/dockerfile-rb/pull/1) ([dependabot[bot]](https://github.com/apps/dependabot))
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
The intent of this gem is to use a PEG (citrus) to parse a Dockerfile into a Ruby
|
5
|
+
The intent of this gem is to use a PEG (citrus) to parse a Dockerfile into a hash of Ruby objects.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -27,7 +27,8 @@ Example usage:
|
|
27
27
|
```
|
28
28
|
require 'dockerfile-rb'
|
29
29
|
|
30
|
-
dockerfile = DockerfileRB.parse('/path/to/Dockerfile')
|
30
|
+
dockerfile = DockerfileRB.parse(File.read('/path/to/Dockerfile'))
|
31
|
+
puts dockerfile.inspect
|
31
32
|
```
|
32
33
|
|
33
34
|
## Contributing
|
data/dockerfile-rb.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_development_dependency "bundler", "~>
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
30
|
spec.add_development_dependency "rake", "~> 13.0"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
32
|
spec.add_dependency "citrus"
|
data/lib/dockerfile-rb/expose.rb
CHANGED
@@ -2,8 +2,12 @@ module DockerfileRB
|
|
2
2
|
class Expose
|
3
3
|
attr_reader :port, :protocol
|
4
4
|
def initialize(port, protocol)
|
5
|
-
|
6
|
-
|
5
|
+
if port.match /\d/
|
6
|
+
@port = port.to_i
|
7
|
+
@protocol = (protocol || 'tcp').downcase
|
8
|
+
else # port is a variable
|
9
|
+
@port = port
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
module ExposeParser
|
@@ -24,22 +24,27 @@ grammar DockerfileRB::Dockerfile
|
|
24
24
|
)*
|
25
25
|
{
|
26
26
|
parsed = matches.map(&:value).compact
|
27
|
-
|
28
|
-
parsed.each
|
29
|
-
|
27
|
+
results = Hash.new {|h,k| h[k] = [] }
|
28
|
+
parsed.each do |p|
|
29
|
+
key = p.class.name.split('::').last.downcase
|
30
|
+
next if key.eql?('string')
|
31
|
+
|
32
|
+
results[key].push p
|
33
|
+
end
|
34
|
+
results
|
30
35
|
}
|
31
36
|
end
|
32
37
|
|
33
38
|
rule add
|
34
|
-
('ADD' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? src_term:(string) space dest_term:(string) ) <DockerfileRB::AddParser>
|
39
|
+
('ADD' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? src_term:(string | variable) space dest_term:(string | variable) comment?) <DockerfileRB::AddParser>
|
35
40
|
end
|
36
41
|
|
37
42
|
rule add_with_whitespace
|
38
|
-
('ADD' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? '[' quote src_term:(string_with_whitespace) quote comma quote dest_term:(string_with_whitespace) quote ']' ) <DockerfileRB::AddParser>
|
43
|
+
('ADD' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? '[' quote src_term:(string_with_whitespace | variable) quote comma quote dest_term:(string_with_whitespace | variable) quote ']' comment?) <DockerfileRB::AddParser>
|
39
44
|
end
|
40
45
|
|
41
46
|
rule arg
|
42
|
-
('ARG' space arg_name_term:(string) '=' arg_value_term:(string)) <DockerfileRB::ArgParser>
|
47
|
+
('ARG' space arg_name_term:(string) '=' arg_value_term:(string) comment?) <DockerfileRB::ArgParser>
|
43
48
|
end
|
44
49
|
|
45
50
|
rule as
|
@@ -48,32 +53,28 @@ grammar DockerfileRB::Dockerfile
|
|
48
53
|
}
|
49
54
|
end
|
50
55
|
|
51
|
-
rule comment
|
52
|
-
'#' space? (string_with_whitespace | '\'' | '=' | '"')* line_break
|
53
|
-
end
|
54
|
-
|
55
56
|
rule copy
|
56
|
-
('COPY' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? src_term:(string) space dest_term:(string) ) <DockerfileRB::CopyParser>
|
57
|
+
('COPY' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? src_term:(string | variable) space dest_term:(string | variable) comment?) <DockerfileRB::CopyParser>
|
57
58
|
end
|
58
59
|
|
59
60
|
rule copy_with_whitespace
|
60
|
-
('COPY' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? '[' quote src_term:(string_with_whitespace) quote comma quote dest_term:(string_with_whitespace) quote ']' ) <DockerfileRB::CopyParser>
|
61
|
+
('COPY' space arg_term:('--chown=' [a-zA-Z0-9.@/_\-\$\\]+ ':' [a-zA-Z0-9:.@/_\-\$\\]+)? space? '[' quote src_term:(string_with_whitespace | variable) quote comma quote dest_term:(string_with_whitespace | variable) quote ']' comment?) <DockerfileRB::CopyParser>
|
61
62
|
end
|
62
63
|
|
63
64
|
rule cmd_exec
|
64
|
-
('CMD' space '[' (quote cmd_term:(string) quote comma?)* ']') <DockerfileRB::CmdParser>
|
65
|
+
('CMD' space '[' (quote cmd_term:(string) quote comma?)* ']' comment?) <DockerfileRB::CmdParser>
|
65
66
|
end
|
66
67
|
|
67
68
|
rule cmd_shell
|
68
|
-
('CMD' space (cmd_term:(string) space?)*) <DockerfileRB::CmdParser>
|
69
|
+
('CMD' space (cmd_term:(string) space?)* comment?) <DockerfileRB::CmdParser>
|
69
70
|
end
|
70
71
|
|
71
72
|
rule entrypoint_exec
|
72
|
-
('ENTRYPOINT' space '[' (quote entrypoint_term:(string) quote comma?)* ']') <DockerfileRB::EntrypointExecParser>
|
73
|
+
('ENTRYPOINT' space '[' (quote entrypoint_term:(string) quote comma?)* ']' comment?) <DockerfileRB::EntrypointExecParser>
|
73
74
|
end
|
74
75
|
|
75
76
|
rule entrypoint_shell
|
76
|
-
('ENTRYPOINT' space (entrypoint_term:(string) space?)*) <DockerfileRB::EntrypointShellParser>
|
77
|
+
('ENTRYPOINT' space (entrypoint_term:(string) space?)* comment?) <DockerfileRB::EntrypointShellParser>
|
77
78
|
end
|
78
79
|
|
79
80
|
rule env_with_whitespace
|
@@ -81,65 +82,70 @@ grammar DockerfileRB::Dockerfile
|
|
81
82
|
end
|
82
83
|
|
83
84
|
rule env_key_value
|
84
|
-
('ENV' space (key_term:(escaped_string) space? '=' quote? space? value_term:(escaped_string) quote? line_continuation?)+) <DockerfileRB::EnvKeyValueParser>
|
85
|
+
('ENV' space (key_term:(escaped_string) space? '=' quote? space? value_term:(escaped_string | variable) quote? line_continuation?)+ comment?) <DockerfileRB::EnvKeyValueParser>
|
85
86
|
end
|
86
87
|
|
87
88
|
rule expose
|
88
|
-
('EXPOSE' space expose_term:(string)) <DockerfileRB::ExposeParser>
|
89
|
+
('EXPOSE' space expose_term:(string | variable) comment?) <DockerfileRB::ExposeParser>
|
89
90
|
end
|
90
91
|
|
91
92
|
rule healthcheck_none
|
92
|
-
'HEALTHCHECK NONE' <DockerfileRB::HealthcheckNoneParser>
|
93
|
+
('HEALTHCHECK NONE' comment?) <DockerfileRB::HealthcheckNoneParser>
|
93
94
|
end
|
94
95
|
|
95
96
|
rule from
|
96
|
-
('FROM' space from_term:(string) space? as?) <DockerfileRB::FromParser>
|
97
|
+
('FROM' space from_term:(string | variable) space? as? comment?) <DockerfileRB::FromParser>
|
97
98
|
end
|
98
99
|
|
99
100
|
rule label
|
100
|
-
('LABEL' space label_term:(quote? string_with_whitespace quote? '=' quote? string_with_whitespace quote? line_continuation?)+) <DockerfileRB::LabelParser>
|
101
|
+
('LABEL' space label_term:(quote? string_with_whitespace quote? '=' quote? (string_with_whitespace | variable) quote? line_continuation?)+ comment?) <DockerfileRB::LabelParser>
|
101
102
|
end
|
102
103
|
|
103
104
|
rule maintainer
|
104
|
-
('MAINTAINER' space maintainer_term:(string)) <DockerfileRB::MaintainerParser>
|
105
|
+
('MAINTAINER' space maintainer_term:(string) comment?) <DockerfileRB::MaintainerParser>
|
105
106
|
end
|
106
107
|
|
107
108
|
rule run_exec
|
108
|
-
('RUN' space '[' (quote run_term:(string_with_whitespace) quote comma?)* ']') <DockerfileRB::RunExecParser>
|
109
|
+
('RUN' space '[' (quote run_term:(string_with_whitespace) quote comma?)* ']' comment?) <DockerfileRB::RunExecParser>
|
109
110
|
end
|
110
111
|
|
111
112
|
rule run_shell
|
112
|
-
('RUN' space (run_term:(run_string) space? line_continuation? (comment)*)*) <DockerfileRB::RunShellParser>
|
113
|
+
('RUN' space (run_term:(run_string) space? line_continuation? (comment)*)* comment?) <DockerfileRB::RunShellParser>
|
113
114
|
end
|
114
115
|
|
115
116
|
rule stopsignal
|
116
|
-
('STOPSIGNAL' space signal_term:(signal)) <DockerfileRB::StopsignalParser>
|
117
|
+
('STOPSIGNAL' space signal_term:(signal | variable) comment?) <DockerfileRB::StopsignalParser>
|
117
118
|
end
|
118
119
|
|
119
120
|
rule user
|
120
|
-
('USER' space user_term:(string)) <DockerfileRB::UserParser>
|
121
|
+
('USER' space user_term:(string | variable) comment?) <DockerfileRB::UserParser>
|
121
122
|
end
|
122
123
|
|
123
124
|
rule volume_string
|
124
|
-
('VOLUME' space (volume_term:(string) space?)* (']')?) <DockerfileRB::VolumeStringParser>
|
125
|
+
('VOLUME' space (volume_term:(string | variable) space?)* (']')?) <DockerfileRB::VolumeStringParser>
|
125
126
|
end
|
126
127
|
|
127
128
|
rule volume_json
|
128
|
-
('VOLUME' space '[' (quote volume_term:(string) quote comma?)* ']') <DockerfileRB::VolumeJSONParser>
|
129
|
+
('VOLUME' space '[' (quote volume_term:(string | variable) quote comma?)* ']') <DockerfileRB::VolumeJSONParser>
|
129
130
|
end
|
130
131
|
|
131
132
|
rule workdir
|
132
|
-
('WORKDIR' space quote? workdir_term:(path) quote?) <DockerfileRB::WorkdirParser>
|
133
|
+
('WORKDIR' space quote? workdir_term:(path | variable) quote? comment?) <DockerfileRB::WorkdirParser>
|
134
|
+
end
|
135
|
+
|
136
|
+
rule comment
|
137
|
+
(space? "#" (~line_break)* line_break?)
|
133
138
|
end
|
134
139
|
|
135
140
|
rule path
|
136
|
-
[a-zA-Z0-9:.@/_\-\$\[\]\\]+
|
141
|
+
[a-zA-Z0-9:.@/_\-\$\[\]\\{}]+
|
137
142
|
end
|
138
143
|
|
139
144
|
rule string
|
140
|
-
[a-zA-Z0-9
|
145
|
+
[a-zA-Z0-9:;!<>*&^,()+.@/_\-\[\]\|\?{}]+
|
141
146
|
end
|
142
147
|
|
148
|
+
|
143
149
|
rule string_with_whitespace
|
144
150
|
(string | ' ')+
|
145
151
|
end
|
@@ -149,7 +155,11 @@ grammar DockerfileRB::Dockerfile
|
|
149
155
|
end
|
150
156
|
|
151
157
|
rule run_string
|
152
|
-
[a-zA-Z0-9:;!#<>*&^,()
|
158
|
+
[a-zA-Z0-9:;!#<>*&^,()+#.@/_\-\$\[\]\| ='"?{}%]+ | '\\'
|
159
|
+
end
|
160
|
+
|
161
|
+
rule variable
|
162
|
+
/^(\\\$|\$)/ string
|
153
163
|
end
|
154
164
|
|
155
165
|
rule comma
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerfile-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gscho
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,9 +77,8 @@ files:
|
|
77
77
|
- ".github/workflows/release.yml"
|
78
78
|
- ".gitignore"
|
79
79
|
- ".rspec"
|
80
|
-
-
|
80
|
+
- CHANGELOG.md
|
81
81
|
- Gemfile
|
82
|
-
- Gemfile.lock
|
83
82
|
- LICENSE.txt
|
84
83
|
- README.md
|
85
84
|
- Rakefile
|
@@ -127,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
126
|
- !ruby/object:Gem::Version
|
128
127
|
version: '0'
|
129
128
|
requirements: []
|
130
|
-
rubygems_version: 3.0.3
|
129
|
+
rubygems_version: 3.0.3.1
|
131
130
|
signing_key:
|
132
131
|
specification_version: 4
|
133
132
|
summary: A Dockerfile parser implemented in ruby
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
dockerfile-rb (0.1.0)
|
5
|
-
citrus
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
citrus (3.0.2)
|
11
|
-
diff-lcs (1.3)
|
12
|
-
rake (13.0.1)
|
13
|
-
rspec (3.9.0)
|
14
|
-
rspec-core (~> 3.9.0)
|
15
|
-
rspec-expectations (~> 3.9.0)
|
16
|
-
rspec-mocks (~> 3.9.0)
|
17
|
-
rspec-core (3.9.1)
|
18
|
-
rspec-support (~> 3.9.1)
|
19
|
-
rspec-expectations (3.9.0)
|
20
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.9.0)
|
22
|
-
rspec-mocks (3.9.1)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.9.0)
|
25
|
-
rspec-support (3.9.2)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
bundler (~> 1.17)
|
32
|
-
dockerfile-rb!
|
33
|
-
rake (~> 13.0)
|
34
|
-
rspec (~> 3.0)
|
35
|
-
|
36
|
-
BUNDLED WITH
|
37
|
-
1.17.3
|