[gold] Add docs to various Ignore structs
Also move/rename one to the frontend package as is appropriate.
Change-Id: I76672ded38e04dc06e69d155480b0b46b1ce92bd
Bug: skia:9778
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/263943
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
diff --git a/golden/go/ignore/ignorestore.go b/golden/go/ignore/ignorestore.go
index cc50617..c9a1ed7 100644
--- a/golden/go/ignore/ignorestore.go
+++ b/golden/go/ignore/ignorestore.go
@@ -27,12 +27,20 @@
// Rule defines a single ignore rule, matching zero or more traces based on
// Query.
type Rule struct {
- ID string
- Name string
+ // ID is the id used to store this Rule in a Store. They should be unique.
+ ID string
+ // Name is the email of the user who created the rule.
+ Name string
+ // UpdatedBy is the email of the user who last updated the rule.
UpdatedBy string
- Expires time.Time
- Query string
- Note string
+ // Expires indicates a time at which a human should re-consider the rule and see if
+ // it still needs to be applied.
+ Expires time.Time
+ // Query is a url-encoded set of key-value pairs that can be used to match traces.
+ // For example: "config=angle_d3d9_es2&cpu_or_gpu_value=RadeonHD7770"
+ Query string
+ // Note is a comment by a developer, typically a bug.
+ Note string
}
// toQuery makes a slice of url.Values from the given slice of Rules.
diff --git a/golden/go/web/frontend/types.go b/golden/go/web/frontend/types.go
index 73340fc..d9826b1 100644
--- a/golden/go/web/frontend/types.go
+++ b/golden/go/web/frontend/types.go
@@ -176,3 +176,14 @@
Note: r.Note,
}, nil
}
+
+// IgnoreRuleBody encapsulates a single ignore rule that is submitted for addition or update.
+type IgnoreRuleBody struct {
+ // Duration is a human readable string like "2w", "4h" to specify a duration.
+ Duration string `json:"duration"`
+ // Filter is a url-encoded set of key-value pairs that can be used to match traces.
+ // For example: "config=angle_d3d9_es2&cpu_or_gpu_value=RadeonHD7770"
+ Filter string `json:"filter"`
+ // Note is a comment by a developer, typically a bug.
+ Note string `json:"note"`
+}
diff --git a/golden/go/web/web.go b/golden/go/web/web.go
index f146365..a7f9689 100644
--- a/golden/go/web/web.go
+++ b/golden/go/web/web.go
@@ -13,6 +13,8 @@
"time"
"github.com/gorilla/mux"
+ "golang.org/x/time/rate"
+
"go.skia.org/infra/go/httputils"
"go.skia.org/infra/go/human"
"go.skia.org/infra/go/login"
@@ -41,7 +43,6 @@
"go.skia.org/infra/golden/go/types/expectations"
"go.skia.org/infra/golden/go/validation"
"go.skia.org/infra/golden/go/web/frontend"
- "golang.org/x/time/rate"
)
const (
@@ -771,13 +772,6 @@
return true
}
-// IgnoresRequest encapsulates a single ignore rule that is submitted for addition or update.
-type IgnoresRequest struct {
- Duration string `json:"duration"`
- Filter string `json:"filter"`
- Note string `json:"note"`
-}
-
// IgnoresUpdateHandler updates an existing ignores rule.
func (wh *Handlers) IgnoresUpdateHandler(w http.ResponseWriter, r *http.Request) {
defer metrics2.FuncTimer().Stop()
@@ -791,7 +785,7 @@
http.Error(w, "ID must be non-empty.", http.StatusBadRequest)
return
}
- req := &IgnoresRequest{}
+ req := &frontend.IgnoreRuleBody{}
if err := parseJSON(r, req); err != nil {
httputils.ReportError(w, err, "Failed to parse submitted data", http.StatusBadRequest)
return
@@ -855,7 +849,7 @@
http.Error(w, "You must be logged in to add an ignore rule", http.StatusUnauthorized)
return
}
- req := &IgnoresRequest{}
+ req := &frontend.IgnoreRuleBody{}
if err := parseJSON(r, req); err != nil {
httputils.ReportError(w, err, "Failed to parse submitted data", http.StatusBadRequest)
return