diff --git a/pkg/docker/dockerfile/dockerfile.go b/pkg/docker/dockerfile/dockerfile.go index e58fe4ff..4b72eef7 100644 --- a/pkg/docker/dockerfile/dockerfile.go +++ b/pkg/docker/dockerfile/dockerfile.go @@ -12,40 +12,16 @@ import ( docker "github.com/fsouza/go-dockerclient" "github.com/mintoolkit/mint/pkg/consts" + "github.com/mintoolkit/mint/pkg/docker/instruction" v "github.com/mintoolkit/mint/pkg/version" ) -// note: dup (todo: refactor) -const ( - //MAINTAINER: - instPrefixMaintainer = "MAINTAINER " - //ENTRYPOINT: - instTypeEntrypoint = "ENTRYPOINT" - instPrefixEntrypoint = "ENTRYPOINT " - //CMD: - instTypeCmd = "CMD" - instPrefixCmd = "CMD " - //USER: - instTypeUser = "USER" - instPrefixUser = "USER " - //EXPOSE: - instTypeExpose = "EXPOSE" - instPrefixExpose = "EXPOSE " - //WORKDIR: - instTypeWorkdir = "WORKDIR" - instPrefixWorkdir = "WORKDIR " - //HEALTHCHECK: - instTypeHealthcheck = "HEALTHCHECK" - instPrefixHealthcheck = "HEALTHCHECK " - //ONBUILD: - instTypeOnbuild = "ONBUILD" - //RUN: - instTypeRun = "RUN" - instPrefixRun = "RUN " - //ADD: - instTypeAdd = "ADD" - //COPY: - instTypeCopy = "COPY" +// Instruction prefixes in the uppercase form written to the Dockerfile, +// derived from the canonical names in pkg/docker/instruction +var ( + instPrefixUser = strings.ToUpper(instruction.User) + " " + instPrefixExpose = strings.ToUpper(instruction.Expose) + " " + instPrefixWorkdir = strings.ToUpper(instruction.Workdir) + " " ) // GenerateFromInfo builds and saves a Dockerfile file object diff --git a/pkg/docker/dockerfile/reverse/reverse.go b/pkg/docker/dockerfile/reverse/reverse.go index 4ff3c8b3..88758375 100644 --- a/pkg/docker/dockerfile/reverse/reverse.go +++ b/pkg/docker/dockerfile/reverse/reverse.go @@ -16,6 +16,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/mintoolkit/mint/pkg/crt" + "github.com/mintoolkit/mint/pkg/docker/instruction" ) var ( @@ -105,45 +106,45 @@ const ( runInstArgsPrefix = "|" ) -const ( - //MAINTAINER: - instTypeMaintainer = "MAINTAINER" - instPrefixMaintainer = "MAINTAINER " - //ENTRYPOINT: - instTypeEntrypoint = "ENTRYPOINT" - instPrefixEntrypoint = "ENTRYPOINT " - //CMD: - instTypeCmd = "CMD" - instPrefixCmd = "CMD " - //USER: - instTypeUser = "USER" - instPrefixUser = "USER " - //EXPOSE: - instTypeExpose = "EXPOSE" - instPrefixExpose = "EXPOSE " - //WORKDIR: - instTypeWorkdir = "WORKDIR" - instPrefixWorkdir = "WORKDIR " - //HEALTHCHECK: - instTypeHealthcheck = "HEALTHCHECK" - instPrefixHealthcheck = "HEALTHCHECK " - instPrefixBasicEncHealthcheck = "HEALTHCHECK --" - //ONBUILD: - instTypeOnbuild = "ONBUILD" - //RUN: - instTypeRun = "RUN" - instPrefixRun = "RUN " - //ADD: - instTypeAdd = "ADD" - //COPY: - instTypeCopy = "COPY" - - instTypeVolume = "VOLUME" - instTypeEnv = "ENV" - instTypeLabel = "LABEL" - instTypeStopSignal = "STOPSIGNAL" - instTypeShell = "SHELL" - instTypeArg = "ARG" //shouldn't see it as an standalone instruction +// Instruction names in the uppercase form used in image history data, +// derived from the canonical names in pkg/docker/instruction +var ( + instTypeMaintainer = strings.ToUpper(instruction.Maintainer) + instPrefixMaintainer = instTypeMaintainer + " " + + instTypeEntrypoint = strings.ToUpper(instruction.Entrypoint) + instPrefixEntrypoint = instTypeEntrypoint + " " + + instTypeCmd = strings.ToUpper(instruction.Cmd) + instPrefixCmd = instTypeCmd + " " + + instTypeUser = strings.ToUpper(instruction.User) + instPrefixUser = instTypeUser + " " + + instTypeExpose = strings.ToUpper(instruction.Expose) + instPrefixExpose = instTypeExpose + " " + + instTypeWorkdir = strings.ToUpper(instruction.Workdir) + instPrefixWorkdir = instTypeWorkdir + " " + + instTypeHealthcheck = strings.ToUpper(instruction.Healthcheck) + instPrefixHealthcheck = instTypeHealthcheck + " " + instPrefixBasicEncHealthcheck = instTypeHealthcheck + " --" + + instTypeOnbuild = strings.ToUpper(instruction.Onbuild) + + instTypeRun = strings.ToUpper(instruction.Run) + instPrefixRun = instTypeRun + " " + + instTypeAdd = strings.ToUpper(instruction.Add) + instTypeCopy = strings.ToUpper(instruction.Copy) + + instTypeVolume = strings.ToUpper(instruction.Volume) + instTypeEnv = strings.ToUpper(instruction.Env) + instTypeLabel = strings.ToUpper(instruction.Label) + instTypeStopSignal = strings.ToUpper(instruction.StopSignal) + instTypeShell = strings.ToUpper(instruction.Shell) + instTypeArg = strings.ToUpper(instruction.Arg) //shouldn't see it as an standalone instruction ) var instructionTypes = map[string]struct{}{