mirror of
https://github.com/prymitive/karma
synced 2026-08-19 11:36:24 +00:00
fix(backend): don't hardcode success reponse string
Linter doesn't like repeated strings, neither should I
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package mapper
|
||||
|
||||
const AlertmanagerStatusString = "success"
|
||||
@@ -70,7 +70,7 @@ func (s StatusMapper) Decode(source io.ReadCloser) (models.AlertmanagerStatus, e
|
||||
return status, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return status, fmt.Errorf("status endpoint returned status value '%s'", resp.Status)
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func (m AlertMapper) Decode(source io.ReadCloser) ([]models.AlertGroup, error) {
|
||||
return groups, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return groups, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ func (m SilenceMapper) Decode(source io.ReadCloser) ([]models.Silence, error) {
|
||||
return silences, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return silences, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func (s StatusMapper) Decode(source io.ReadCloser) (models.AlertmanagerStatus, e
|
||||
return status, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return status, fmt.Errorf("status endpoint returned status value '%s'", resp.Status)
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ func (m AlertMapper) Decode(source io.ReadCloser) ([]models.AlertGroup, error) {
|
||||
return groups, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return groups, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (m SilenceMapper) Decode(source io.ReadCloser) ([]models.Silence, error) {
|
||||
return silences, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return silences, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func (m AlertMapper) Decode(source io.ReadCloser) ([]models.AlertGroup, error) {
|
||||
return groups, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return groups, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ func (m AlertMapper) Decode(source io.ReadCloser) ([]models.AlertGroup, error) {
|
||||
return groups, err
|
||||
}
|
||||
|
||||
if resp.Status != "success" {
|
||||
if resp.Status != mapper.AlertmanagerStatusString {
|
||||
return groups, errors.New(resp.Error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user