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

Side by Side Diff: dm/api/distributor/swarming/v1/cipd.go

Issue 2338153003: Add snapshotting for CIPD packages and dimensions to DM. (Closed)
Patch Set: Remove cleanup noise Created 4 years, 2 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 2016 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 swarmingV1
6
7 import (
8 "sort"
9
10 swarm "github.com/luci/luci-go/common/api/swarming/swarming/v1"
11 )
12
13 // ToCipdPackage converts this to a swarming api SwarmingRpcsCipdPackage.
14 func (c *CipdPackage) ToCipdPackage() *swarm.SwarmingRpcsCipdPackage {
15 if c == nil {
16 return nil
17 }
18 return &swarm.SwarmingRpcsCipdPackage{PackageName: c.Name, Version: c.Ve rsion}
19 }
20
21 // ToCipdInput converts this to a swarming api SwarmingRpcsCipdInput.
22 func (c *CipdSpec) ToCipdInput() *swarm.SwarmingRpcsCipdInput {
23 if c == nil || c.Client == nil && len(c.ByPath) == 0 {
24 return nil
25 }
26 ret := &swarm.SwarmingRpcsCipdInput{
27 ClientPackage: c.Client.ToCipdPackage(),
28 }
29 if len(c.ByPath) > 0 {
30 count := 0
31 paths := make(sort.StringSlice, 0, len(c.ByPath))
32 for path, pkgs := range c.ByPath {
33 paths = append(paths, path)
34 count += len(pkgs.Pkg)
35 }
36 ret.Packages = make([]*swarm.SwarmingRpcsCipdPackage, 0, count)
37 for _, path := range paths {
38 for _, pkg := range c.ByPath[path].Pkg {
39 retPkg := pkg.ToCipdPackage()
40 retPkg.Path = path
41 ret.Packages = append(ret.Packages, retPkg)
42 }
43 }
44 }
45 return ret
46 }
OLDNEW
« no previous file with comments | « no previous file | dm/api/distributor/swarming/v1/cipd.proto » ('j') | dm/api/distributor/swarming/v1/normalize.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698