2015-09-05 15:49:06 -04:00
|
|
|
package dockerfile
|
2014-08-05 16:17:40 -04:00
|
|
|
|
2015-09-06 13:26:40 -04:00
|
|
|
import "strings"
|
2015-04-04 10:54:43 -04:00
|
|
|
|
2016-05-03 16:56:59 -04:00
|
|
|
// handleJSONArgs parses command passed to CMD, ENTRYPOINT, RUN and SHELL instruction in Dockerfile
|
2016-04-05 17:00:37 -04: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 01:29:03 -04:00
|
|
|
func handleJSONArgs(args []string, attributes map[string]bool) []string {
|
2014-08-30 07:34:09 -04:00
|
|
|
if len(args) == 0 {
|
|
|
|
return []string{}
|
|
|
|
}
|
|
|
|
|
2014-08-13 06:07:41 -04:00
|
|
|
if attributes != nil && attributes["json"] {
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
|
|
|
// literal string command, not an exec array
|
2014-08-30 07:34:09 -04:00
|
|
|
return []string{strings.Join(args, " ")}
|
2014-08-13 06:07:41 -04:00
|
|
|
}
|