support.go 541 B

12345678910111213141516171819
  1. package instructions
  2. import "strings"
  3. // handleJSONArgs parses command passed to CMD, ENTRYPOINT, RUN and SHELL instruction in Dockerfile
  4. // for exec form it returns untouched args slice
  5. // for shell form it returns concatenated args as the first element of a slice
  6. func handleJSONArgs(args []string, attributes map[string]bool) []string {
  7. if len(args) == 0 {
  8. return []string{}
  9. }
  10. if attributes != nil && attributes["json"] {
  11. return args
  12. }
  13. // literal string command, not an exec array
  14. return []string{strings.Join(args, " ")}
  15. }