Skip to content

Panic with ONBUILD ARG and ONBUILD ENV #35

@tpansino

Description

@tpansino
$> dockerfmt version
dockerfmt 0.3.7

$> cat Dockerfile
FROM ubuntu:latest

ONBUILD ARG MY_ARG

$> dockerfmt --newline --check Dockerfile
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/reteps/dockerfmt/lib.formatBasic(0xc00012a680, 0xc00011a420)
        /github/workspace/lib/format.go:418 +0xeb
github.com/reteps/dockerfmt/lib.FormatNode(0xc00012a680, 0xc00011a420)
        /github/workspace/lib/format.go:69 +0x51f
github.com/reteps/dockerfmt/lib.FormatOnBuild(0xc00012a600, 0xc000197910?)
        /github/workspace/lib/format.go:116 +0x3e
github.com/reteps/dockerfmt/lib.FormatNode(0xc00012a600, 0xc00011a420)
        /github/workspace/lib/format.go:69 +0x51f
github.com/reteps/dockerfmt/lib.(*ParseState).processNode(0xc000197a40, 0xc00012a600)
        /github/workspace/lib/format.go:94 +0xf9
github.com/reteps/dockerfmt/lib.(*ParseState).processNode(0xc000197a40, 0xc00012a540)
        /github/workspace/lib/format.go:103 +0x18b
github.com/reteps/dockerfmt/lib.FormatFileLines({0xc000127110, 0x3, 0x3}, 0xc00011a420)
        /github/workspace/lib/format.go:139 +0x246
github.com/reteps/dockerfmt/cmd.processInput({0x7fff3377c7ed, 0xa}, {0xc000190000?, 0x0?, 0x0?}, 0xc00011a420)
        /github/workspace/cmd/root.go:81 +0xc6
github.com/reteps/dockerfmt/cmd.Run(0x87c320, {0xc000127080, 0x1, 0x68632e?})
        /github/workspace/cmd/root.go:65 +0x1d1
github.com/spf13/cobra.(*Command).execute(0x87c320, {0xc00012a090, 0x3, 0x3})
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0xa7b
github.com/spf13/cobra.(*Command).ExecuteC(0x87c320)
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x40c
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
github.com/reteps/dockerfmt/cmd.Execute()
        /github/workspace/cmd/root.go:112 +0x1a
main.main()
        /github/workspace/main.go:8 +0xf

This also occurs if you replace the ONBUILD ARG with ONBUILD ENV.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions