Skip to content

Commit 771dc36

Browse files
dmitshurgopherbot
authored andcommitted
internal/workflow: make Slice method variadic
Simplify API usage when the caller has multiple values they wish to make a slice from, allowing: Slice([]workflow.Value{v1, v2}) To be written as: Slice(v1, v2) For cases where the caller has a slice, they can do Slice(s...), which is only 3 extra characters compared to now. This was motivated by further uses of Slice in an upcoming CL. For golang/go#53537. Change-Id: I820ba6eaaa0d833259fed7bb6cc66b12b3f25611 Reviewed-on: https://go-review.googlesource.com/c/build/+/414034 Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]>
1 parent 35c44e5 commit 771dc36

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

internal/relui/workflows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func addSingleReleaseWorkflow(build *BuildReleaseTasks, milestone *task.Mileston
590590
nextVersion := wd.Task("Get next version", version.GetNextVersion, kindVal)
591591
milestones := wd.Task("Pick milestones", milestone.FetchMilestones, nextVersion, kindVal)
592592
checked := wd.Action("Check blocking issues", milestone.CheckBlockers, milestones, nextVersion, kindVal)
593-
dlcl := wd.Task("Mail DL CL", version.MailDLCL, wd.Slice([]workflow.Value{nextVersion}), wd.Constant(false))
593+
dlcl := wd.Task("Mail DL CL", version.MailDLCL, wd.Slice(nextVersion), wd.Constant(false))
594594
dlclCommit := wd.Task("Wait for DL CL", version.AwaitCL, dlcl, wd.Constant(""))
595595
wd.Output("Download CL submitted", dlclCommit)
596596

@@ -662,7 +662,7 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *workflow.Definition, majorVers
662662
testsPassed = append(testsPassed, long)
663663
}
664664
}
665-
stagedArtifacts := wd.Task("Stage artifacts for signing", tasks.copyToStaging, version, wd.Slice(artifacts))
665+
stagedArtifacts := wd.Task("Stage artifacts for signing", tasks.copyToStaging, version, wd.Slice(artifacts...))
666666
signedArtifacts := wd.Task("Wait for signed artifacts", tasks.awaitSigned, version, wd.Constant(darwinTargets), stagedArtifacts)
667667
signedAndTested := wd.Task("Wait for signing and tests", func(ctx *workflow.TaskContext, artifacts []artifact) ([]artifact, error) {
668668
return artifacts, nil

internal/workflow/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (c *constant) deps() []*taskDefinition { return nil }
201201

202202
// Slice combines multiple Values of the same type into a Value containing
203203
// a slice of that type.
204-
func (d *Definition) Slice(vs []Value) Value {
204+
func (d *Definition) Slice(vs ...Value) Value {
205205
if len(vs) == 0 {
206206
return &slice{}
207207
}

internal/workflow/workflow_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestSplitJoin(t *testing.T) {
139139
in := wd.Task("echo", echo, wd.Constant("string #"))
140140
add1 := wd.Task("add 1", appendInt, in, wd.Constant(1))
141141
add2 := wd.Task("add 2", appendInt, in, wd.Constant(2))
142-
both := wd.Slice([]workflow.Value{add1, add2})
142+
both := wd.Slice(add1, add2)
143143
out := wd.Task("join", join, both)
144144
wd.Output("strings", out)
145145

0 commit comments

Comments
 (0)