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

Unified 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, 3 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
Index: dm/api/distributor/swarming/v1/cipd.go
diff --git a/dm/api/distributor/swarming/v1/cipd.go b/dm/api/distributor/swarming/v1/cipd.go
new file mode 100644
index 0000000000000000000000000000000000000000..696187847e207170c25916ebc3faee8fe29da41b
--- /dev/null
+++ b/dm/api/distributor/swarming/v1/cipd.go
@@ -0,0 +1,46 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package swarmingV1
+
+import (
+ "sort"
+
+ swarm "github.com/luci/luci-go/common/api/swarming/swarming/v1"
+)
+
+// ToCipdPackage converts this to a swarming api SwarmingRpcsCipdPackage.
+func (c *CipdPackage) ToCipdPackage() *swarm.SwarmingRpcsCipdPackage {
+ if c == nil {
+ return nil
+ }
+ return &swarm.SwarmingRpcsCipdPackage{PackageName: c.Name, Version: c.Version}
+}
+
+// ToCipdInput converts this to a swarming api SwarmingRpcsCipdInput.
+func (c *CipdSpec) ToCipdInput() *swarm.SwarmingRpcsCipdInput {
+ if c == nil || c.Client == nil && len(c.ByPath) == 0 {
+ return nil
+ }
+ ret := &swarm.SwarmingRpcsCipdInput{
+ ClientPackage: c.Client.ToCipdPackage(),
+ }
+ if len(c.ByPath) > 0 {
+ count := 0
+ paths := make(sort.StringSlice, 0, len(c.ByPath))
+ for path, pkgs := range c.ByPath {
+ paths = append(paths, path)
+ count += len(pkgs.Pkg)
+ }
+ ret.Packages = make([]*swarm.SwarmingRpcsCipdPackage, 0, count)
+ for _, path := range paths {
+ for _, pkg := range c.ByPath[path].Pkg {
+ retPkg := pkg.ToCipdPackage()
+ retPkg.Path = path
+ ret.Packages = append(ret.Packages, retPkg)
+ }
+ }
+ }
+ return ret
+}
« 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