From 7ec9a7a4a80a8cbbe217c030cc51839b2ec5e114 Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> Date: Thu, 11 Sep 2025 17:26:54 +0300 Subject: [PATCH] Configprovider: Update the interface to propagate errors (#110814) * ConfigProvider: Update Get method to return error alongside configuration --- pkg/configprovider/configprovider.go | 6 +++--- pkg/services/quota/quotaimpl/quota.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/configprovider/configprovider.go b/pkg/configprovider/configprovider.go index 8f20e87eaa2..7f140ee980a 100644 --- a/pkg/configprovider/configprovider.go +++ b/pkg/configprovider/configprovider.go @@ -8,7 +8,7 @@ import ( ) type ConfigProvider interface { - Get(context.Context) *setting.Cfg + Get(context.Context) (*setting.Cfg, error) } type OSSConfigProvider struct { @@ -16,9 +16,9 @@ type OSSConfigProvider struct { log log.Logger } -func (c *OSSConfigProvider) Get(_ context.Context) *setting.Cfg { +func (c *OSSConfigProvider) Get(_ context.Context) (*setting.Cfg, error) { c.log.Debug("OSSConfigProvider Get") - return c.Cfg + return c.Cfg, nil } func ProvideService(cfg *setting.Cfg) (ConfigProvider, error) { diff --git a/pkg/services/quota/quotaimpl/quota.go b/pkg/services/quota/quotaimpl/quota.go index 8b0da1f71bf..c6a686bb128 100644 --- a/pkg/services/quota/quotaimpl/quota.go +++ b/pkg/services/quota/quotaimpl/quota.go @@ -76,7 +76,8 @@ func ProvideService(ctx context.Context, db db.DB, configProvider configprovider } func (s *service) IsDisabled(ctx context.Context) bool { - return !s.cfg.Get(ctx).Quota.Enabled + c, err := s.cfg.Get(ctx) + return err != nil || !c.Quota.Enabled } // QuotaReached checks that quota is reached for a target. Runs CheckQuotaReached and take context and scope parameters from the request context