2014-08-15 12:29:35 -04:00
|
|
|
package builder
|
2014-08-05 16:17:40 -04:00
|
|
|
|
|
|
|
import (
|
2015-04-04 10:54:43 -04:00
|
|
|
"regexp"
|
2014-08-05 16:17:40 -04:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2015-04-04 10:54:43 -04:00
|
|
|
const acceptableRemoteMIME = `(?:application/(?:(?:x\-)?tar|octet\-stream|((?:x\-)?(?:gzip|bzip2?|xz)))|(?:text/plain))`
|
|
|
|
|
|
|
|
var mimeRe = regexp.MustCompile(acceptableRemoteMIME)
|
|
|
|
|
|
|
|
func selectAcceptableMIME(ct string) string {
|
|
|
|
return mimeRe.FindString(ct)
|
|
|
|
}
|
|
|
|
|
2014-08-13 06:07:41 -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
|
|
|
}
|