From bf47ea928b1b8288dac5b29b46a4b23636e62ede Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 20 Mar 2018 13:00:36 -0700 Subject: [PATCH] Integration tests for entrypoint --- .../{Dockerfile_test_cmd => Dockerfile_test_metadata} | 3 +++ .../dockerfiles/{test_cmd.yaml => test_metadata.yaml} | 1 + integration_tests/integration_test_yaml.go | 8 ++++---- pkg/commands/cmd.go | 6 ++++-- 4 files changed, 12 insertions(+), 6 deletions(-) rename integration_tests/dockerfiles/{Dockerfile_test_cmd => Dockerfile_test_metadata} (56%) rename integration_tests/dockerfiles/{test_cmd.yaml => test_metadata.yaml} (66%) diff --git a/integration_tests/dockerfiles/Dockerfile_test_cmd b/integration_tests/dockerfiles/Dockerfile_test_metadata similarity index 56% rename from integration_tests/dockerfiles/Dockerfile_test_cmd rename to integration_tests/dockerfiles/Dockerfile_test_metadata index 7b8b04999..261db4d5b 100644 --- a/integration_tests/dockerfiles/Dockerfile_test_cmd +++ b/integration_tests/dockerfiles/Dockerfile_test_metadata @@ -2,3 +2,6 @@ FROM gcr.io/distroless/base:latest CMD ["command", "one"] CMD ["command", "two"] CMD echo "hello" + +ENTRYPOINT ["execute", "something"] +ENTRYPOINT ["execute", "entrypoint"] diff --git a/integration_tests/dockerfiles/test_cmd.yaml b/integration_tests/dockerfiles/test_metadata.yaml similarity index 66% rename from integration_tests/dockerfiles/test_cmd.yaml rename to integration_tests/dockerfiles/test_metadata.yaml index c05b14824..cb0024311 100644 --- a/integration_tests/dockerfiles/test_cmd.yaml +++ b/integration_tests/dockerfiles/test_metadata.yaml @@ -1,3 +1,4 @@ schemaVersion: '2.0.0' metadataTest: cmd: ["/bin/sh", "-c", "echo \"hello\""] + entrypoint: ["execute", "entrypoint"] diff --git a/integration_tests/integration_test_yaml.go b/integration_tests/integration_test_yaml.go index d610e5146..19c5a8926 100644 --- a/integration_tests/integration_test_yaml.go +++ b/integration_tests/integration_test_yaml.go @@ -66,11 +66,11 @@ var structureTests = []struct { structureTestYamlPath: "/workspace/integration_tests/dockerfiles/test_env.yaml", }, { - description: "test cmd", - dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_cmd", - repo: "test-cmd", + description: "test metadata", + dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_metadata", + repo: "test-metadata", dockerBuildContext: "/workspace/integration_tests/dockerfiles/", - structureTestYamlPath: "/workspace/integration_tests/dockerfiles/test_cmd.yaml", + structureTestYamlPath: "/workspace/integration_tests/dockerfiles/test_metadata.yaml", }, } diff --git a/pkg/commands/cmd.go b/pkg/commands/cmd.go index 54e18e241..4d49234b2 100644 --- a/pkg/commands/cmd.go +++ b/pkg/commands/cmd.go @@ -53,11 +53,13 @@ func (c *CmdCommand) FilesToSnapshot() []string { // CreatedBy returns some information about the command for the image config history func (c *CmdCommand) CreatedBy() string { + cmd := []string{"CMD"} cmdLine := strings.Join(c.cmd.CmdLine, " ") if c.cmd.PrependShell { // TODO: Support shell command here shell := []string{"/bin/sh", "-c"} - return strings.Join(append(shell, cmdLine), " ") + appendedShell := append(cmd, shell...) + return strings.Join(append(appendedShell, cmdLine), " ") } - return cmdLine + return strings.Join(append(cmd, cmdLine), " ") }