From fc90c36d5008ad4e3db43a1f552744f1fae5c56b Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Thu, 13 May 2021 14:28:10 -0400 Subject: [PATCH] removes unused db method (#34082) --- pkg/services/ngalert/models/alertmanager.go | 7 ------ pkg/services/ngalert/store/alertmanager.go | 27 --------------------- pkg/services/ngalert/store/database.go | 1 - 3 files changed, 35 deletions(-) diff --git a/pkg/services/ngalert/models/alertmanager.go b/pkg/services/ngalert/models/alertmanager.go index 3dad0ed2b05..70bf55c571d 100644 --- a/pkg/services/ngalert/models/alertmanager.go +++ b/pkg/services/ngalert/models/alertmanager.go @@ -18,13 +18,6 @@ type GetLatestAlertmanagerConfigurationQuery struct { Result *AlertConfiguration } -// GetAlertmanagerConfigurationQuery is the query to get the latest alertmanager configuration. -type GetAlertmanagerConfigurationQuery struct { - ID int64 - - Result *AlertConfiguration -} - // SaveAlertmanagerConfigurationCmd is the command to save an alertmanager configuration. type SaveAlertmanagerConfigurationCmd struct { AlertmanagerConfiguration string diff --git a/pkg/services/ngalert/store/alertmanager.go b/pkg/services/ngalert/store/alertmanager.go index 25c5f2f5fc5..40eeabf1e19 100644 --- a/pkg/services/ngalert/store/alertmanager.go +++ b/pkg/services/ngalert/store/alertmanager.go @@ -13,20 +13,6 @@ var ( ErrNoAlertmanagerConfiguration = fmt.Errorf("could not find an Alertmanager configuration") ) -func getAlertmanagerConfigurationByID(sess *sqlstore.DBSession, id int64) (*models.AlertConfiguration, error) { - c := &models.AlertConfiguration{} - - has, err := sess.ID(id).Get(c) - if err != nil { - return nil, err - } - if !has { - return nil, ErrNoAlertmanagerConfiguration - } - - return c, nil -} - func getLatestAlertmanagerConfiguration(sess *sqlstore.DBSession) (*models.AlertConfiguration, error) { c := &models.AlertConfiguration{} // The ID is already an auto incremental column, using the ID as an order should guarantee the latest. @@ -55,19 +41,6 @@ func (st *DBstore) GetLatestAlertmanagerConfiguration(query *models.GetLatestAle }) } -// GetAlertmanagerConfiguration returns the alertmanager configuration identified by the query. -// It returns ErrNoAlertmanagerConfiguration if no such configuration is found. -func (st *DBstore) GetAlertmanagerConfiguration(query *models.GetAlertmanagerConfigurationQuery) error { - return st.SQLStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error { - c, err := getAlertmanagerConfigurationByID(sess, query.ID) - if err != nil { - return err - } - query.Result = c - return nil - }) -} - // SaveAlertmanagerConfiguration creates an alertmanager configuration. func (st *DBstore) SaveAlertmanagerConfiguration(cmd *models.SaveAlertmanagerConfigurationCmd) error { return st.SQLStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error { diff --git a/pkg/services/ngalert/store/database.go b/pkg/services/ngalert/store/database.go index c11dd09455f..d8ad45a1c57 100644 --- a/pkg/services/ngalert/store/database.go +++ b/pkg/services/ngalert/store/database.go @@ -17,7 +17,6 @@ const AlertDefinitionMaxTitleLength = 190 // AlertingStore is the database interface used by the Alertmanager service. type AlertingStore interface { GetLatestAlertmanagerConfiguration(*models.GetLatestAlertmanagerConfigurationQuery) error - GetAlertmanagerConfiguration(*models.GetAlertmanagerConfigurationQuery) error SaveAlertmanagerConfiguration(*models.SaveAlertmanagerConfigurationCmd) error }