| Index: cipd/client/cipd/client.go
|
| diff --git a/cipd/client/cipd/client.go b/cipd/client/cipd/client.go
|
| index 2e0fea965ec02a6a6189963d3ff571dcb962d79c..b0b0f5bfa1c5e7207af0ef74fa5dd2c334464940 100644
|
| --- a/cipd/client/cipd/client.go
|
| +++ b/cipd/client/cipd/client.go
|
| @@ -40,9 +40,7 @@ import (
|
| "net/url"
|
| "os"
|
| "path/filepath"
|
| - "regexp"
|
| "sort"
|
| - "strings"
|
| "sync"
|
| "time"
|
|
|
| @@ -1403,58 +1401,3 @@ func buildInstanceIDMap(pins []common.Pin) map[string]string {
|
| }
|
| return out
|
| }
|
| -
|
| -var templateParm = regexp.MustCompile(`\${[^}]*}`)
|
| -var errSkipTemplate = errors.New("this template should be skipped")
|
| -
|
| -// expandTemplate applies template expansion rules to the package template,
|
| -// using the provided platform and arch values. If err == errSkipTemplate, that
|
| -// means that this template does not apply to this platform/arch combination and
|
| -// should be skipped.
|
| -func expandTemplate(template, platform, arch string) (pkg string, err error) {
|
| - skip := false
|
| -
|
| - expansionLookup := map[string]string{
|
| - "platform": platform,
|
| - "arch": arch,
|
| - }
|
| -
|
| - pkg = templateParm.ReplaceAllStringFunc(template, func(parm string) string {
|
| - // ${...}
|
| - contents := parm[2 : len(parm)-1]
|
| -
|
| - varNameValues := strings.SplitN(contents, "=", 2)
|
| - if len(varNameValues) == 1 {
|
| - // ${varName}
|
| - if value, ok := expansionLookup[varNameValues[0]]; ok {
|
| - return value
|
| - }
|
| -
|
| - err = errors.Reason("unknown variable in ${%(contents)s}").
|
| - D("contents", contents).Err()
|
| - }
|
| -
|
| - // ${varName=value,value}
|
| - ourValue, ok := expansionLookup[varNameValues[0]]
|
| - if !ok {
|
| - err = errors.Reason("unknown variable in %(parm)s").D("parm", parm).Err()
|
| - return parm
|
| - }
|
| -
|
| - for _, val := range strings.Split(varNameValues[1], ",") {
|
| - if val == ourValue {
|
| - return ourValue
|
| - }
|
| - }
|
| - skip = true
|
| - return parm
|
| - })
|
| - if skip {
|
| - err = errSkipTemplate
|
| - }
|
| - if err == nil && strings.ContainsRune(pkg, '$') {
|
| - err = errors.Reason("unable to process some variables in %(template)q").
|
| - D("template", template).Err()
|
| - }
|
| - return
|
| -}
|
|
|