1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Map Commands instead of using them as a slice

The most obvious use case is when one wants to make sure as fast
as possible that a command is a valid Dockerfile command.

Signed-off-by: kargakis <kargakis@users.noreply.github.com>
This commit is contained in:
kargakis 2015-02-20 11:38:55 +01:00
parent a78ce5c228
commit 6ecf23861e
2 changed files with 16 additions and 16 deletions

View file

@ -19,19 +19,19 @@ const (
) )
// Commands is list of all Dockerfile commands // Commands is list of all Dockerfile commands
var Commands = []string{ var Commands = map[string]struct{}{
Env, Env: {},
Maintainer, Maintainer: {},
Add, Add: {},
Copy, Copy: {},
From, From: {},
Onbuild, Onbuild: {},
Workdir, Workdir: {},
Run, Run: {},
Cmd, Cmd: {},
Entrypoint, Entrypoint: {},
Expose, Expose: {},
Volume, Volume: {},
User, User: {},
Insert, Insert: {},
} }

View file

@ -4836,7 +4836,7 @@ func TestBuildMissingArgs(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
for _, cmd := range command.Commands { for cmd := range command.Commands {
cmd = strings.ToUpper(cmd) cmd = strings.ToUpper(cmd)
if _, ok := skipCmds[cmd]; ok { if _, ok := skipCmds[cmd]; ok {
continue continue