@@ -21,7 +21,8 @@ type EventInterval struct {
2121
2222 // TODO: Remove the omitempty, just here to keep from having to repeatedly updated the json
2323 // files used in some new tests
24- Source string `json:"tempSource,omitempty"` // also temporary, unsure if this concept will survive
24+ Source string `json:"tempSource,omitempty"` // also temporary, unsure if this concept will survive
25+ Display bool `json:"display"`
2526
2627 // TODO: we're hoping to move these to just locator/message when everything is ready.
2728 StructuredLocator monitorapi.Locator `json:"tempStructuredLocator"`
@@ -37,7 +38,7 @@ type EventIntervalList struct {
3738}
3839
3940func EventsToFile (filename string , events monitorapi.Intervals ) error {
40- json , err := EventsToJSON (events )
41+ json , err := IntervalsToJSON (events )
4142 if err != nil {
4243 return err
4344 }
@@ -49,10 +50,10 @@ func EventsFromFile(filename string) (monitorapi.Intervals, error) {
4950 if err != nil {
5051 return nil , err
5152 }
52- return EventsFromJSON (data )
53+ return IntervalsFromJSON (data )
5354}
5455
55- func EventsFromJSON (data []byte ) (monitorapi.Intervals , error ) {
56+ func IntervalsFromJSON (data []byte ) (monitorapi.Intervals , error ) {
5657 var list EventIntervalList
5758 if err := json .Unmarshal (data , & list ); err != nil {
5859 return nil , err
@@ -64,12 +65,13 @@ func EventsFromJSON(data []byte) (monitorapi.Intervals, error) {
6465 return nil , err
6566 }
6667 events = append (events , monitorapi.Interval {
67- Source : monitorapi .IntervalSource (interval .Source ),
68+ Source : monitorapi .IntervalSource (interval .Source ),
69+ Display : interval .Display ,
6870 Condition : monitorapi.Condition {
6971 Level : level ,
7072 Locator : interval .Locator ,
71- Message : interval .Message ,
7273 StructuredLocator : interval .StructuredLocator ,
74+ Message : interval .Message ,
7375 StructuredMessage : interval .StructuredMessage ,
7476 },
7577
@@ -91,7 +93,8 @@ func IntervalFromJSON(data []byte) (*monitorapi.Interval, error) {
9193 return nil , err
9294 }
9395 return & monitorapi.Interval {
94- Source : monitorapi .IntervalSource (serializedInterval .Source ),
96+ Source : monitorapi .IntervalSource (serializedInterval .Source ),
97+ Display : serializedInterval .Display ,
9598 Condition : monitorapi.Condition {
9699 Level : level ,
97100 Locator : serializedInterval .Locator ,
@@ -120,9 +123,9 @@ func IntervalToOneLineJSON(interval monitorapi.Interval) ([]byte, error) {
120123 return buf .Bytes (), nil
121124}
122125
123- func EventsToJSON ( events monitorapi.Intervals ) ([]byte , error ) {
126+ func IntervalsToJSON ( intervals monitorapi.Intervals ) ([]byte , error ) {
124127 outputEvents := []EventInterval {}
125- for _ , curr := range events {
128+ for _ , curr := range intervals {
126129 outputEvents = append (outputEvents , monitorEventIntervalToEventInterval (curr ))
127130 }
128131
@@ -131,14 +134,16 @@ func EventsToJSON(events monitorapi.Intervals) ([]byte, error) {
131134 return json .MarshalIndent (list , "" , " " )
132135}
133136
134- func EventsIntervalsToFile (filename string , events monitorapi.Intervals ) error {
135- json , err := EventsIntervalsToJSON (events )
137+ func IntervalsToFile (filename string , intervals monitorapi.Intervals ) error {
138+ json , err := EventsIntervalsToJSON (intervals )
136139 if err != nil {
137140 return err
138141 }
139142 return ioutil .WriteFile (filename , json , 0644 )
140143}
141144
145+ // TODO: this is very similar but subtly different to the function above, what is the purpose of skipping those
146+ // with from/to equal or empty to?
142147func EventsIntervalsToJSON (events monitorapi.Intervals ) ([]byte , error ) {
143148 outputEvents := []EventInterval {}
144149 for _ , curr := range events {
@@ -161,11 +166,11 @@ func monitorEventIntervalToEventInterval(interval monitorapi.Interval) EventInte
161166 StructuredLocator : interval .StructuredLocator ,
162167 StructuredMessage : interval .StructuredMessage ,
163168 Source : string (interval .Source ),
169+ Display : interval .Display ,
164170
165171 From : metav1.Time {Time : interval .From },
166172 To : metav1.Time {Time : interval .To },
167173 }
168-
169174 return ret
170175}
171176
0 commit comments