github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/builder/dockerfile/support.go (about)

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