diff --git a/frontend/dockerfile/instructions/commands.go b/frontend/dockerfile/instructions/commands.go index 87252f9f17dd..c5b1762f7187 100644 --- a/frontend/dockerfile/instructions/commands.go +++ b/frontend/dockerfile/instructions/commands.go @@ -3,9 +3,8 @@ package instructions import ( "strings" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" "github.com/moby/buildkit/frontend/dockerfile/parser" + dockerspec "github.com/moby/docker-image-spec/specs-go/v1" "github.com/pkg/errors" ) @@ -325,7 +324,7 @@ type ShellInlineFile struct { // ShellDependantCmdLine represents a cmdline optionally prepended with the shell type ShellDependantCmdLine struct { - CmdLine strslice.StrSlice + CmdLine []string Files []ShellInlineFile PrependShell bool } @@ -368,7 +367,7 @@ type CmdCommand struct { // HEALTHCHECK type HealthCheckCommand struct { withNameAndCode - Health *container.HealthConfig + Health *dockerspec.HealthcheckConfig } // EntrypointCommand sets the default entrypoint of the container to use the @@ -479,7 +478,7 @@ func (c *ArgCommand) Expand(expander SingleWordExpander) error { // SHELL bash -e -c type ShellCommand struct { withNameAndCode - Shell strslice.StrSlice + Shell []string } // Stage represents a bundled collection of commands. diff --git a/frontend/dockerfile/instructions/parse.go b/frontend/dockerfile/instructions/parse.go index b3d684f0d69b..7e34730c6a0a 100644 --- a/frontend/dockerfile/instructions/parse.go +++ b/frontend/dockerfile/instructions/parse.go @@ -12,12 +12,11 @@ import ( "strings" "time" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/strslice" "github.com/moby/buildkit/frontend/dockerfile/command" "github.com/moby/buildkit/frontend/dockerfile/linter" "github.com/moby/buildkit/frontend/dockerfile/parser" "github.com/moby/buildkit/util/suggest" + dockerspec "github.com/moby/docker-image-spec/specs-go/v1" "github.com/pkg/errors" ) @@ -475,12 +474,11 @@ func parseShellDependentCommand(req parseRequest, command string, emptyAsNil boo } args := handleJSONArgs(req.args, req.attributes) - cmd := strslice.StrSlice(args) - if emptyAsNil && len(cmd) == 0 { - cmd = nil + if emptyAsNil && len(args) == 0 { + args = nil } return ShellDependantCmdLine{ - CmdLine: cmd, + CmdLine: args, Files: files, PrependShell: !req.attributes["json"], }, nil @@ -563,8 +561,10 @@ func parseOptInterval(f *Flag) (time.Duration, error) { if d == 0 { return 0, nil } - if d < container.MinimumDuration { - return 0, errors.Errorf("Interval %#v cannot be less than %s", f.name, container.MinimumDuration) + + const minimumDuration = time.Millisecond + if d < minimumDuration { + return 0, errors.Errorf("Interval %#v cannot be less than %s", f.name, minimumDuration) } return d, nil } @@ -582,12 +582,11 @@ func parseHealthcheck(req parseRequest) (*HealthCheckCommand, error) { if len(args) != 0 { return nil, errors.New("HEALTHCHECK NONE takes no arguments") } - test := strslice.StrSlice{typ} - cmd.Health = &container.HealthConfig{ - Test: test, + cmd.Health = &dockerspec.HealthcheckConfig{ + Test: []string{typ}, } } else { - healthcheck := container.HealthConfig{} + healthcheck := dockerspec.HealthcheckConfig{} flInterval := req.flags.AddString("interval", "") flTimeout := req.flags.AddString("timeout", "") @@ -610,7 +609,7 @@ func parseHealthcheck(req parseRequest) (*HealthCheckCommand, error) { typ = "CMD-SHELL" } - healthcheck.Test = strslice.StrSlice(append([]string{typ}, cmdSlice...)) + healthcheck.Test = append([]string{typ}, cmdSlice...) default: return nil, errors.Errorf("Unknown type %#v in HEALTHCHECK (try CMD)", typ) } @@ -774,7 +773,7 @@ func parseShell(req parseRequest) (*ShellCommand, error) { // SHELL ["powershell", "-command"] return &ShellCommand{ - Shell: strslice.StrSlice(shellSlice), + Shell: shellSlice, withNameAndCode: newWithNameAndCode(req), }, nil default: diff --git a/frontend/dockerfile/instructions/parse_heredoc_test.go b/frontend/dockerfile/instructions/parse_heredoc_test.go index 28cf034ee9ce..78595c5c9751 100644 --- a/frontend/dockerfile/instructions/parse_heredoc_test.go +++ b/frontend/dockerfile/instructions/parse_heredoc_test.go @@ -4,7 +4,6 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types/strslice" "github.com/moby/buildkit/frontend/dockerfile/parser" "github.com/stretchr/testify/require" ) @@ -179,22 +178,22 @@ func TestRunHeredoc(t *testing.T) { cases := []struct { dockerfile string shell bool - command strslice.StrSlice + command []string files []ShellInlineFile }{ { dockerfile: `RUN ["ls", "/"]`, - command: strslice.StrSlice{"ls", "/"}, + command: []string{"ls", "/"}, shell: false, }, { dockerfile: `RUN ["<