fix(backend): don't hardcode success reponse string

Linter doesn't like repeated strings, neither should I
This commit is contained in:
Łukasz Mierzwa
2019-06-22 17:48:33 +01:00
parent 4bd9f447e2
commit 50cdc617e7
9 changed files with 11 additions and 8 deletions
+3
View File
@@ -0,0 +1,3 @@
package mapper
const AlertmanagerStatusString = "success"
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}