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
Родитель a78ce5c228
Коммит 6ecf23861e
2 изменённых файлов: 16 добавлений и 16 удалений

Просмотреть файл

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

Просмотреть файл

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