2015-09-05 19:49:06 +00:00
|
|
|
package dockerfile
|
2014-08-05 20:17:40 +00:00
|
|
|
|
2015-09-06 17:26:40 +00:00
|
|
|
import "strings"
|
2015-04-04 14:54:43 +00:00
|
|
|
|
2016-05-03 20:56:59 +00:00
|
|
|
// handleJSONArgs parses command passed to CMD, ENTRYPOINT, RUN and SHELL instruction in Dockerfile
|
2016-04-05 21:00:37 +00:00
|
|
|
// for exec form it returns untouched args slice
|
|
|
|
// for shell form it returns concatenated args as the first element of a slice
|
2015-07-22 05:29:03 +00:00
|
|
|
func handleJSONArgs(args []string, attributes map[string]bool) []string {
|
2014-08-30 11:34:09 +00:00
|
|
|
if len(args) == 0 {
|
|
|
|
return []string{}
|
|
|
|
}
|
|
|
|
|
2014-08-13 10:07:41 +00:00
|
|
|
if attributes != nil && attributes["json"] {
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
|
|
|
// literal string command, not an exec array
|
2014-08-30 11:34:09 +00:00
|
|
|
return []string{strings.Join(args, " ")}
|
2014-08-13 10:07:41 +00:00
|
|
|
}
|