Check validity of cluster.json files

This commit is contained in:
Lou Knauer
2022-03-01 16:00:44 +01:00
parent e11507de5a
commit 6ad74e918e
3 changed files with 43 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ func (e *MetricScope) UnmarshalGQL(v interface{}) error {
}
*e = MetricScope(str)
if _, ok := metricScopeGranularity[*e]; !ok {
if !e.Valid() {
return fmt.Errorf("%s is not a valid MetricScope", str)
}
return nil
@@ -102,6 +102,11 @@ func (e MetricScope) MarshalGQL(w io.Writer) {
fmt.Fprintf(w, "\"%s\"", e)
}
func (e MetricScope) Valid() bool {
gran, ok := metricScopeGranularity[e]
return ok && gran > 0
}
func (jd *JobData) Size() int {
n := 128
for _, scopes := range *jd {