From cfb68f89288c36403e6e1d9aefbe55020e47ee1e Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Mon, 18 Mar 2024 09:37:25 +0000 Subject: [PATCH] Check webhook secret for entity Signed-off-by: Gabriel Adrian Samfira --- runner/pool/pool.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 5f4a6e03..ac8eb4e2 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -102,6 +102,10 @@ func NewEntityPoolManager(ctx context.Context, entity params.GithubEntity, cfgIn return nil, errors.Wrap(err, "getting github client") } + if entity.WebhookSecret == "" { + return nil, errors.New("webhook secret is empty") + } + wg := &sync.WaitGroup{} keyMuxes := &keyMutex{} @@ -1689,16 +1693,17 @@ func (r *basePoolManager) Stop() error { func (r *basePoolManager) RefreshState(param params.UpdatePoolStateParams) error { r.mux.Lock() - r.entity.WebhookSecret = param.WebhookSecret + if param.WebhookSecret != "" { + r.entity.WebhookSecret = param.WebhookSecret + } if param.InternalConfig != nil { r.cfgInternal = *param.InternalConfig - } - - r.urls = urls{ - webhookURL: r.cfgInternal.BaseWebhookURL, - callbackURL: r.cfgInternal.InstanceCallbackURL, - metadataURL: r.cfgInternal.InstanceMetadataURL, - controllerWebhookURL: r.cfgInternal.ControllerWebhookURL, + r.urls = urls{ + webhookURL: r.cfgInternal.BaseWebhookURL, + callbackURL: r.cfgInternal.InstanceCallbackURL, + metadataURL: r.cfgInternal.InstanceMetadataURL, + controllerWebhookURL: r.cfgInternal.ControllerWebhookURL, + } } ghc, err := garmUtil.GithubClient(r.ctx, r.entity, r.cfgInternal.GithubCredentialsDetails)