Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: cipd/client/cipd/client.go

Issue 2651813007: [cipd] Remove dead expandTemplate function (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
-}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698