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

Unified Diff: dm/api/distributor/swarming/v1/normalize.go

Issue 2338153003: Add snapshotting for CIPD packages and dimensions to DM. (Closed)
Patch Set: Fix comments 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
« no previous file with comments | « dm/api/distributor/swarming/v1/isolate_ref.pb.go ('k') | dm/api/distributor/swarming/v1/params.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/api/distributor/swarming/v1/normalize.go
diff --git a/dm/api/distributor/swarming/v1/normalize.go b/dm/api/distributor/swarming/v1/normalize.go
index f1bef718a92507775b4375a49fe69ff9d90bbf11..11dcb36beefa964fe4930e633f3fb0659d0eb065 100644
--- a/dm/api/distributor/swarming/v1/normalize.go
+++ b/dm/api/distributor/swarming/v1/normalize.go
@@ -75,22 +75,45 @@ func (j *Parameters_Job) Normalize() (err error) {
}
// Normalize normalizes and checks for input violations.
+func (p *CipdPackage) Normalize() error {
+ if p.Name == "" {
+ return errors.New("missing name")
+ }
+ if p.Version == "" {
+ return errors.New("missing version")
+ }
+ return nil
+}
+
+// Normalize normalizes and checks for input violations.
+func (c *CipdSpec) Normalize() error {
+ if err := schemaHostURLValidate(c.Server); err != nil {
+ return fmt.Errorf("job.inputs.cipd.server: %s", err)
+ }
+ if c.Client != nil {
+ if err := c.Client.Normalize(); err != nil {
+ return fmt.Errorf("job.inputs.cipd.client: %s", err)
+ }
+ }
+ for path, pkgs := range c.ByPath {
+ for i, p := range pkgs.Pkg {
+ if err := p.Normalize(); err != nil {
+ return fmt.Errorf("job.inputs.cipd.by_path[%s].pkg[%d]: %s", path, i, err)
+ }
+ }
+ }
+ return nil
+}
+
+// Normalize normalizes and checks for input violations.
func (i *Parameters_Job_Inputs) Normalize() (err error) {
- if len(i.Packages) == 0 && len(i.Isolated) == 0 {
+ if i.Cipd == nil && len(i.Isolated) == 0 {
return errors.New(
"job.inputs: at least one of packages and isolated must be specified")
}
- if len(i.Packages) > 0 {
- if err = schemaHostURLValidate(i.CipdServer); err != nil {
- return fmt.Errorf("job.inputs.cipd_server: %s", err)
- }
- for i, p := range i.Packages {
- if p.Name == "" {
- return fmt.Errorf("job.inputs.packages[%d]: missing name", i)
- }
- if p.Version == "" {
- return fmt.Errorf("job.inputs.packages[%d]: missing version", i)
- }
+ if i.Cipd != nil {
+ if err = i.Cipd.Normalize(); err != nil {
+ return
}
}
return
« no previous file with comments | « dm/api/distributor/swarming/v1/isolate_ref.pb.go ('k') | dm/api/distributor/swarming/v1/params.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698