github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/integration/helpers/buildpack_v7.go (about) 1 // +build V7 2 3 package helpers 4 5 import ( 6 "fmt" 7 "regexp" 8 ) 9 10 func BuildpacksOutputRegex(fields BuildpackFields) string { 11 anyStringRegex := `\S+` 12 optionalStringRegex := `\S*` 13 anyBoolRegex := `(true|false)` 14 anyIntRegex := `\d+` 15 16 nameRegex := anyStringRegex 17 if fields.Name != "" { 18 nameRegex = regexp.QuoteMeta(fields.Name) 19 } 20 21 positionRegex := anyIntRegex 22 if fields.Position != "" { 23 positionRegex = regexp.QuoteMeta(fields.Position) 24 } 25 26 enabledRegex := anyBoolRegex 27 if fields.Enabled != "" { 28 enabledRegex = regexp.QuoteMeta(fields.Enabled) 29 } 30 31 lockedRegex := anyBoolRegex 32 if fields.Locked != "" { 33 lockedRegex = regexp.QuoteMeta(fields.Locked) 34 } 35 36 filenameRegex := anyStringRegex 37 if fields.Filename != "" { 38 filenameRegex = regexp.QuoteMeta(fields.Filename) 39 } 40 41 stackRegex := optionalStringRegex 42 if fields.Stack != "" { 43 stackRegex = regexp.QuoteMeta(fields.Stack) 44 } 45 46 return fmt.Sprintf(`%s\s+%s\s+%s\s+%s\s+%s\s+%s`, 47 positionRegex, 48 nameRegex, 49 stackRegex, 50 enabledRegex, 51 lockedRegex, 52 filenameRegex, 53 ) 54 }