@@ -10,25 +10,33 @@ type configVersion struct {
10
10
APIVersion values.Int64Value `json:"apiVersion" yaml:"apiVersion"`
11
11
}
12
12
13
+ type OrgID int64
14
+
13
15
type AlertingFile struct {
14
16
configVersion
17
+ Filename string
15
18
Groups []AlertRuleGroup
16
19
DeleteRules []RuleDelete
17
20
ContactPoints []ContactPoint
18
21
DeleteContactPoints []DeleteContactPoint
22
+ Policies []NotificiationPolicy
23
+ ResetPolicies []OrgID
19
24
}
20
25
21
26
type AlertingFileV1 struct {
22
27
configVersion
23
28
Filename string
24
- Groups []AlertRuleGroupV1 `json:"groups" yaml:"groups"`
25
- DeleteRules []RuleDeleteV1 `json:"deleteRules" yaml:"deleteRules"`
26
- ContactPoints []ContactPointV1 `json:"contactPoints" yaml:"contactPoints"`
27
- DeleteContactPoints []DeleteContactPointV1 `json:"deleteContactPoints" yaml:"deleteContactPoints"`
29
+ Groups []AlertRuleGroupV1 `json:"groups" yaml:"groups"`
30
+ DeleteRules []RuleDeleteV1 `json:"deleteRules" yaml:"deleteRules"`
31
+ ContactPoints []ContactPointV1 `json:"contactPoints" yaml:"contactPoints"`
32
+ DeleteContactPoints []DeleteContactPointV1 `json:"deleteContactPoints" yaml:"deleteContactPoints"`
33
+ Policies []NotificiationPolicyV1 `json:"policies" yaml:"policies"`
34
+ ResetPolicies []values.Int64Value `json:"resetPolicies" yaml:"resetPolicies"`
28
35
}
29
36
30
37
func (fileV1 * AlertingFileV1 ) MapToModel () (AlertingFile , error ) {
31
38
alertingFile := AlertingFile {}
39
+ alertingFile .Filename = fileV1 .Filename
32
40
err := fileV1 .mapRules (& alertingFile )
33
41
if err != nil {
34
42
return AlertingFile {}, fmt .Errorf ("failure parsing rules: %w" , err )
@@ -37,9 +45,19 @@ func (fileV1 *AlertingFileV1) MapToModel() (AlertingFile, error) {
37
45
if err != nil {
38
46
return AlertingFile {}, fmt .Errorf ("failure parsing contact points: %w" , err )
39
47
}
48
+ fileV1 .mapPolicies (& alertingFile )
40
49
return alertingFile , nil
41
50
}
42
51
52
+ func (fileV1 * AlertingFileV1 ) mapPolicies (alertingFile * AlertingFile ) {
53
+ for _ , npV1 := range fileV1 .Policies {
54
+ alertingFile .Policies = append (alertingFile .Policies , npV1 .mapToModel ())
55
+ }
56
+ for _ , orgIDV1 := range fileV1 .ResetPolicies {
57
+ alertingFile .ResetPolicies = append (alertingFile .ResetPolicies , OrgID (orgIDV1 .Value ()))
58
+ }
59
+ }
60
+
43
61
func (fileV1 * AlertingFileV1 ) mapContactPoint (alertingFile * AlertingFile ) error {
44
62
for _ , dcp := range fileV1 .DeleteContactPoints {
45
63
alertingFile .DeleteContactPoints = append (alertingFile .DeleteContactPoints , dcp .MapToModel ())
0 commit comments