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

Side by Side Diff: swarming/tasktemplate/template.go

Issue 2701033003: milo: Add SwarmBucket templating. (Closed)
Patch Set: Apparently "/swarming" is gitignored! Added... Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 // Package tasktemplate resolves Swarming task templates.
6 //
7 // Templated strings may be passed to Swarming tasks in order to have them
8 // resolve task-side parameters. See Params for more information.
9 package tasktemplate
10
11 import (
12 "github.com/luci/luci-go/common/data/text/stringtemplate"
13 )
14
15 // Params contains supported Swarming task string substitution parameters.
16 //
17 // A template string can be resolved by passing it to a Params instance's
18 // Resolve method.
19 type Params struct {
20 // SwarmingRunID is the substitution to use for the "swarming_run_id" te mplate
21 // parameter.
22 //
23 // Note that this is the Swarming Run ID, not Task ID. The Run ID is the
24 // combination of the Task ID with the try number.
25 SwarmingRunID string
26 }
27
28 func (p *Params) substMap() map[string]string {
29 res := make(map[string]string, 1)
30 if p.SwarmingRunID != "" {
31 res["swarming_run_id"] = p.SwarmingRunID
32 }
33 return res
34 }
35
36 // Resolve resolves v against p's parameters, populating any template fields
37 // with their respective parameter value.
38 //
39 // If the string is invalid, or if it references an undefined template
40 // parameter, an error will be returned.
41 func (p *Params) Resolve(v string) (string, error) {
42 return stringtemplate.Resolve(v, p.substMap())
43 }
OLDNEW
« no previous file with comments | « milo/appengine/swarming/testdata/build-running-logdog.swarm ('k') | swarming/tasktemplate/template_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698