UnmarshalJSON implements the json.Unmarshaler interface.
(data []byte)
| 445 | |
| 446 | // UnmarshalJSON implements the json.Unmarshaler interface. |
| 447 | func (l *Limits) UnmarshalJSON(data []byte) error { |
| 448 | // Like the YAML method above, we want to set l to the defaults and then overwrite |
| 449 | // it with the input. We prevent an infinite loop of calling UnmarshalJSON by hiding |
| 450 | // behind type indirection. |
| 451 | if defaultLimits != nil { |
| 452 | *l = *defaultLimits |
| 453 | // Make copy of default limits. Otherwise unmarshalling would modify map in default limits. |
| 454 | l.copyNotificationIntegrationLimits(defaultLimits.NotificationRateLimitPerIntegration) |
| 455 | } |
| 456 | |
| 457 | type plain Limits |
| 458 | dec := json.NewDecoder(bytes.NewReader(data)) |
| 459 | dec.DisallowUnknownFields() |
| 460 | |
| 461 | if err := dec.Decode((*plain)(l)); err != nil { |
| 462 | return err |
| 463 | } |
| 464 | |
| 465 | if err := l.compileQueryAttributeRegex(); err != nil { |
| 466 | return err |
| 467 | } |
| 468 | |
| 469 | if err := l.calculateMaxSeriesPerLabelSetId(); err != nil { |
| 470 | return err |
| 471 | } |
| 472 | |
| 473 | return nil |
| 474 | } |
| 475 | |
| 476 | func (l *Limits) calculateMaxSeriesPerLabelSetId() error { |
| 477 | hMap := map[uint64]struct{}{} |
no test coverage detected