Include common/model with silence type

This commit is contained in:
Fabian Reinartz 2015-10-01 17:44:47 +02:00
parent 7fb9e63f89
commit a31b79cb91
3 changed files with 66 additions and 2 deletions

View File

@ -1,3 +1,16 @@
// Copyright 2013 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package model
import (

51
vendor/github.com/prometheus/common/model/silence.go generated vendored Normal file
View File

@ -0,0 +1,51 @@
// Copyright 2015 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package model
import (
"encoding/json"
"fmt"
"time"
)
// Silence defines the representation of a silence definiton
// in the Prometheus eco-system.
type Silence struct {
ID uint64 `json:"id,omitempty"`
Matchers []struct {
Name LabelName `json:"name,omitempty"`
Value string `json:"value,omitempty"`
IsRegex bool `json:"isRegex"`
} `json:"matchers"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
CreatedBy string `json:"createdBy"`
Comment string `json:"comment,omitempty"`
}
func (s *Silence) UnmarshalJSON(b []byte) error {
if err := json.Unmarshal(b, s); err != nil {
return err
}
for _, m := range s.Matchers {
if len(m.Name) == 0 {
return fmt.Errorf("label name in matcher must not be empty")
}
}
return nil
}

4
vendor/vendor.json vendored
View File

@ -54,8 +54,8 @@
},
{
"path": "github.com/prometheus/common/model",
"revision": "6c6f80228c5942200f4927b3ebfcf84390bbd671",
"revisionTime": "2015-10-01T15:44:02+02:00"
"revision": "88806c605b876039ecf4f088e7e66596619eea79",
"revisionTime": "2015-10-01T17:40:08+02:00"
},
{
"path": "github.com/prometheus/common/route",