Merge pull request #672 from prymitive/alertmanager-v0.17.0

chore(backend): rename mapper to match alertmanager version
This commit is contained in:
Łukasz Mierzwa
2019-05-03 21:20:40 +01:00
committed by GitHub
54 changed files with 38 additions and 42 deletions

View File

@@ -9,12 +9,8 @@ Alertmanager `0.16.x` is **NOT** supported by karma due to changes
in the API, see [this issue](https://github.com/prymitive/karma/issues/115)
for details.
A new API endpoint
[was added](https://github.com/prometheus/alertmanager/pull/1791) and will be
available in the next Alertmanager release (`>=0.17.0`). This new endpoint is
supported by karma.
tl;dr skip Alertmanager `0.16.x` and wait for `0.17.0` if you wish to use it
with karma
[was added for 0.17.0](https://github.com/prometheus/alertmanager/pull/1791) and
alertmanager `>=0.17.0` is supported.
---

View File

@@ -2,7 +2,7 @@ package alertmanager
import (
"github.com/prymitive/karma/internal/mapper"
v016 "github.com/prymitive/karma/internal/mapper/v016"
v017 "github.com/prymitive/karma/internal/mapper/v017"
v04 "github.com/prymitive/karma/internal/mapper/v04"
v05 "github.com/prymitive/karma/internal/mapper/v05"
v061 "github.com/prymitive/karma/internal/mapper/v061"
@@ -17,6 +17,6 @@ func init() {
mapper.RegisterAlertMapper(v062.AlertMapper{})
mapper.RegisterSilenceMapper(v04.SilenceMapper{})
mapper.RegisterSilenceMapper(v05.SilenceMapper{})
mapper.RegisterAlertMapper(v016.AlertMapper{})
mapper.RegisterSilenceMapper(v016.SilenceMapper{})
mapper.RegisterAlertMapper(v017.AlertMapper{})
mapper.RegisterSilenceMapper(v017.SilenceMapper{})
}

View File

@@ -1,6 +1,6 @@
ALERTMANAGER_VERSION := 2fa210d0e3c86bea44a38f4131c069752738a6cb
ALERTMANAGER_VERSION := v0.17.0
API_VERSION := v2
PACKAGE := v016
PACKAGE := v017
TARGET_DIR := /go/src/github.com/prymitive/karma/internal/mapper/$(PACKAGE)
IMAGE_NAME := openapi_client_$(PACKAGE)

View File

@@ -1,4 +1,4 @@
package v016
package v017
import (
"net/http"
@@ -28,7 +28,7 @@ func (m AlertMapper) QueryArgs() string {
// IsSupported returns true if given version string is supported
func (m AlertMapper) IsSupported(version string) bool {
versionRange := semver.MustParseRange(">=0.16.1")
versionRange := semver.MustParseRange(">=0.17.0")
return versionRange(semver.MustParse(version))
}

View File

@@ -1,4 +1,4 @@
package v016
package v017
import (
"net/http"
@@ -10,9 +10,9 @@ import (
httptransport "github.com/go-openapi/runtime/client"
"github.com/prymitive/karma/internal/mapper"
"github.com/prymitive/karma/internal/mapper/v016/client"
"github.com/prymitive/karma/internal/mapper/v016/client/alertgroup"
"github.com/prymitive/karma/internal/mapper/v016/client/silence"
"github.com/prymitive/karma/internal/mapper/v017/client"
"github.com/prymitive/karma/internal/mapper/v017/client/alertgroup"
"github.com/prymitive/karma/internal/mapper/v017/client/silence"
"github.com/prymitive/karma/internal/models"
)

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetAlertsReader is a Reader for the GetAlerts structure.

View File

@@ -16,7 +16,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// NewPostAlertsParams creates a new PostAlertsParams object

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetAlertGroupsReader is a Reader for the GetAlertGroups structure.

View File

@@ -11,11 +11,11 @@ import (
strfmt "github.com/go-openapi/strfmt"
"github.com/prymitive/karma/internal/mapper/v016/client/alert"
"github.com/prymitive/karma/internal/mapper/v016/client/alertgroup"
"github.com/prymitive/karma/internal/mapper/v016/client/general"
"github.com/prymitive/karma/internal/mapper/v016/client/receiver"
"github.com/prymitive/karma/internal/mapper/v016/client/silence"
"github.com/prymitive/karma/internal/mapper/v017/client/alert"
"github.com/prymitive/karma/internal/mapper/v017/client/alertgroup"
"github.com/prymitive/karma/internal/mapper/v017/client/general"
"github.com/prymitive/karma/internal/mapper/v017/client/receiver"
"github.com/prymitive/karma/internal/mapper/v017/client/silence"
)
// Default alertmanager HTTP client.

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetStatusReader is a Reader for the GetStatus structure.

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetReceiversReader is a Reader for the GetReceivers structure.

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetSilenceReader is a Reader for the GetSilence structure.

View File

@@ -13,7 +13,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// GetSilencesReader is a Reader for the GetSilences structure.

View File

@@ -16,7 +16,7 @@ import (
strfmt "github.com/go-openapi/strfmt"
models "github.com/prymitive/karma/internal/mapper/v016/models"
models "github.com/prymitive/karma/internal/mapper/v017/models"
)
// NewPostSilencesParams creates a new PostSilencesParams object

View File

@@ -12,6 +12,7 @@ import (
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// AlertGroup alert group
@@ -19,13 +20,16 @@ import (
type AlertGroup struct {
// alerts
// Required: true
Alerts []*GettableAlert `json:"alerts"`
// labels
Labels LabelSet `json:"labels,omitempty"`
// Required: true
Labels LabelSet `json:"labels"`
// receiver
Receiver *Receiver `json:"receiver,omitempty"`
// Required: true
Receiver *Receiver `json:"receiver"`
}
// Validate validates this alert group
@@ -52,8 +56,8 @@ func (m *AlertGroup) Validate(formats strfmt.Registry) error {
func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error {
if swag.IsZero(m.Alerts) { // not required
return nil
if err := validate.Required("alerts", "body", m.Alerts); err != nil {
return err
}
for i := 0; i < len(m.Alerts); i++ {
@@ -77,10 +81,6 @@ func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error {
func (m *AlertGroup) validateLabels(formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
}
if err := m.Labels.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
@@ -93,8 +93,8 @@ func (m *AlertGroup) validateLabels(formats strfmt.Registry) error {
func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error {
if swag.IsZero(m.Receiver) { // not required
return nil
if err := validate.Required("receiver", "body", m.Receiver); err != nil {
return err
}
if m.Receiver != nil {

View File

@@ -1,4 +1,4 @@
package v016
package v017
import (
"net/http"
@@ -27,7 +27,7 @@ func (m SilenceMapper) QueryArgs() string {
// IsSupported returns true if given version string is supported
func (m SilenceMapper) IsSupported(version string) bool {
versionRange := semver.MustParseRange(">=0.16.0")
versionRange := semver.MustParseRange(">=0.17.0")
return versionRange(semver.MustParse(version))
}