Skip to content

Derive Dockerfile instruction names from pkg/docker/instruction instead of duplicating them - #199

Open
Londopy wants to merge 1 commit into
mintoolkit:masterfrom
Londopy:unify-instruction-constants
Open

Londopy wants to merge 1 commit into
mintoolkit:masterfrom
Londopy:unify-instruction-constants

Conversation

@Londopy

@Londopy Londopy commented Sep 20, 2026

Copy link
Copy Markdown

pkg/docker/dockerfile/dockerfile.go and pkg/docker/dockerfile/reverse/reverse.go each carried their own uppercase copies of the Dockerfile instruction names (instTypeCmd = "CMD", instPrefixCmd = "CMD ", ...) alongside the canonical lowercase set in pkg/docker/instruction.

This replaces both const blocks with var blocks that derive the uppercase form from instruction.* (strings.ToUpper(instruction.Cmd)), so there's one set of names to maintain and the two files can't drift from it. The lowercase constants stay canonical because the AST parser, parser, and linter checks all key on them; the uppercase form is still needed here for image-history matching and Dockerfile output (InstructionInfo.Type is serialized uppercase, so no output change).

The local identifiers are kept, so none of the ~25 usage sites change. dockerfile.go only ever used the USER/EXPOSE/WORKDIR prefixes, so the other 17 unused names there are just dropped.

Verified with GOOS=linux go build ./pkg/docker/..., go vet, and the reverse package tests (run on Linux).

Not touched, in case you want them as a follow-up: the inline fmt.Sprintf("RUN %s", ...) / "EXPOSE %s" / WriteString("ENV ") literals in the same two files.

Closes #74

…ad of duplicating them

Signed-off-by: Londopy <Londopy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Refactor to use one set of Docker instruction name constants when processing Docker instruction/command info

1 participant