diff --git a/internal/mapper/const.go b/internal/mapper/const.go new file mode 100644 index 000000000..6f2c123f8 --- /dev/null +++ b/internal/mapper/const.go @@ -0,0 +1,3 @@ +package mapper + +const AlertmanagerStatusString = "success" diff --git a/internal/mapper/v015/status.go b/internal/mapper/v015/status.go index c5f1f7078..28c04793f 100644 --- a/internal/mapper/v015/status.go +++ b/internal/mapper/v015/status.go @@ -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) } diff --git a/internal/mapper/v04/alerts.go b/internal/mapper/v04/alerts.go index 1f2dadd6f..495e5ca4a 100644 --- a/internal/mapper/v04/alerts.go +++ b/internal/mapper/v04/alerts.go @@ -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) } diff --git a/internal/mapper/v04/silences.go b/internal/mapper/v04/silences.go index 238bb5505..a5ea2f76f 100644 --- a/internal/mapper/v04/silences.go +++ b/internal/mapper/v04/silences.go @@ -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) } diff --git a/internal/mapper/v04/status.go b/internal/mapper/v04/status.go index eb702498e..28044f108 100644 --- a/internal/mapper/v04/status.go +++ b/internal/mapper/v04/status.go @@ -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) } diff --git a/internal/mapper/v05/alerts.go b/internal/mapper/v05/alerts.go index a7d8e3ca4..6094c5805 100644 --- a/internal/mapper/v05/alerts.go +++ b/internal/mapper/v05/alerts.go @@ -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) } diff --git a/internal/mapper/v05/silences.go b/internal/mapper/v05/silences.go index 482aa43cf..145c42199 100644 --- a/internal/mapper/v05/silences.go +++ b/internal/mapper/v05/silences.go @@ -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) } diff --git a/internal/mapper/v061/alerts.go b/internal/mapper/v061/alerts.go index beb888497..f5bb441e6 100644 --- a/internal/mapper/v061/alerts.go +++ b/internal/mapper/v061/alerts.go @@ -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) } diff --git a/internal/mapper/v062/alerts.go b/internal/mapper/v062/alerts.go index 2189acc47..cbc417375 100644 --- a/internal/mapper/v062/alerts.go +++ b/internal/mapper/v062/alerts.go @@ -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) }