From 6ecf23861ec7036aa4210fe6d3b7dbfaaedbd6d0 Mon Sep 17 00:00:00 2001
From: kargakis <kargakis@users.noreply.github.com>
Date: Fri, 20 Feb 2015 11:38:55 +0100
Subject: [PATCH] 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>
---
 builder/command/command.go               | 30 ++++++++++++------------
 integration-cli/docker_cli_build_test.go |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/builder/command/command.go b/builder/command/command.go
index 3901bb34f7..f99fa2d906 100644
--- a/builder/command/command.go
+++ b/builder/command/command.go
@@ -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:     {},
 }
diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go
index 3384eed60c..376889b6db 100644
--- a/integration-cli/docker_cli_build_test.go
+++ b/integration-cli/docker_cli_build_test.go
@@ -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