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

Unified Diff: common/api/dm/service/v1/ensure_graph_data_normalize.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review Created 4 years, 6 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: common/api/dm/service/v1/ensure_graph_data_normalize.go
diff --git a/common/api/dm/service/v1/ensure_graph_data_normalize.go b/common/api/dm/service/v1/ensure_graph_data_normalize.go
index b6f21f70ee8fd43157eeabd858415f1d5becdd55..def39cd14d20265de1931d8e104a7626e595faca 100644
--- a/common/api/dm/service/v1/ensure_graph_data_normalize.go
+++ b/common/api/dm/service/v1/ensure_graph_data_normalize.go
@@ -20,15 +20,23 @@ func (t *TemplateInstantiation) Normalize() error {
// Normalize returns an error iff the request is invalid.
func (r *EnsureGraphDataReq) Normalize() error {
+ if r.ForExecution != nil {
+ if err := r.ForExecution.Normalize(); err != nil {
+ return err
+ }
+ }
+
if err := r.Attempts.Normalize(); err != nil {
return err
}
hasAttempts := false
- for _, nums := range r.Attempts.To {
- hasAttempts = true
- if len(nums.Nums) == 0 {
- return errors.New("EnsureGraphDataReq.attempts must only include valid (non-0, non-empty) attempt numbers")
+ if r.Attempts != nil {
+ for _, nums := range r.Attempts.To {
+ hasAttempts = true
+ if len(nums.Nums) == 0 {
+ return errors.New("EnsureGraphDataReq.attempts must only include valid (non-0, non-empty) attempt numbers")
+ }
}
}
@@ -50,6 +58,12 @@ func (r *EnsureGraphDataReq) Normalize() error {
}
}
+ for i, desc := range r.Quest {
+ if err := desc.Normalize(); err != nil {
+ return fmt.Errorf("quest[%d]: %s", i, err)
+ }
+ }
+
if len(r.Quest) == 0 && !hasAttempts {
return errors.New("EnsureGraphDataReq must have at least one of quests and attempts")
}

Powered by Google App Engine
This is Rietveld 408576698