| 1 |
package base |
| 2 |
|
| 3 |
// This file contains everything else |
| 4 |
|
| 5 |
import ( |
| 6 |
"list" |
| 7 |
"strings" |
| 8 |
) |
| 9 |
|
| 10 |
// _matchPattern returns a GitHub Actions expression which evaluates whether a |
| 11 |
// variable matches a globbing pattern. For literal patterns it uses "==", |
| 12 |
// and for suffix patterns it uses "startsWith". |
| 13 |
// See https://docs.github.com/en/actions/learn-github-actions/expressions. |
| 14 |
_matchPattern: { |
| 15 |
variable: string |
| 16 |
pattern: string |
| 17 |
expr: [ |
| 18 |
if strings.HasSuffix(pattern, "*") { |
| 19 |
let prefix = strings.TrimSuffix(pattern, "*") |
| 20 |
"startsWith(\(variable), '\(prefix)')" |
| 21 |
}, |
| 22 |
{ |
| 23 |
"\(variable) == '\(pattern)'" |
| 24 |
}, |
| 25 |
][0] |
| 26 |
} |
| 27 |
|
| 28 |
doNotEditMessage: { |
| 29 |
#generatedBy: string |
| 30 |
"Code generated \(#generatedBy); DO NOT EDIT." |
| 31 |
} |
| 32 |
|
| 33 |
// #URLPath is a temporary measure to derive the path part of a URL. |
| 34 |
// |
| 35 |
// TODO: remove when cuelang.org/issue/1433 lands. |
| 36 |
URLPath: { |
| 37 |
#url: string |
| 38 |
let parts = strings.Split(#url, "/") |
| 39 |
strings.Join(list.Slice(parts, 3, len(parts)), "/") |
| 40 |
} |