server/container_create: Simplify command/args join

The old code was needlessly splitting either kubeCommands or kubeArgs
into [0] and [1:].  The new code doesn't bother with that.  From
[1,2], all we need to do is append kubeArgs to kubeCommands, and we
can do that in one line.

[1]: https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact
[2]: https://github.com/opencontainers/image-spec/blob/v1.0.1/conversion.md#verbatim-fields

Signed-off-by: W. Trevor King <wking@tremily.us>
This commit is contained in:
W. Trevor King 2018-01-19 10:28:15 -08:00
parent cff96ecf5c
commit c93ca853f3

View file

@ -399,18 +399,7 @@ func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, ociConfig *v1.
return nil, fmt.Errorf("no command specified")
}
// create entrypoint and args
var entrypoint string
var args []string
if len(kubeCommands) != 0 {
entrypoint = kubeCommands[0]
args = append(kubeCommands[1:], kubeArgs...)
} else {
entrypoint = kubeArgs[0]
args = kubeArgs[1:]
}
processArgs := append([]string{entrypoint}, args...)
processArgs := append(kubeCommands, kubeArgs...)
logrus.Debugf("OCI process args %v", processArgs)