From 9074822e5745a18d27ff5e55d8d15892f1ae48e4 Mon Sep 17 00:00:00 2001 From: Googlom <36107508+Googlom@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:51:32 +0500 Subject: [PATCH] allow reconfiguration of provider (#4776) Co-authored-by: Gulom Alimov --- pkg/orchestrator/orchestrator.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/orchestrator/orchestrator.go b/pkg/orchestrator/orchestrator.go index 24572d925..52619a7c1 100644 --- a/pkg/orchestrator/orchestrator.go +++ b/pkg/orchestrator/orchestrator.go @@ -93,18 +93,22 @@ func GetOrchestratorConfigProvider(opts *Options) (ConfigProvider, error) { provider = newUnknownOrchestratorConfigProvider() err = errors.New("unable to detect a supported orchestrator (Azure DevOps, GitHub Actions, Jenkins)") } - - if opts == nil { - log.Entry().Debug("ConfigProvider initialized without options. Some data may be unavailable") - return - } - - if cfgErr := provider.Configure(opts); cfgErr != nil { - err = errors.Wrap(cfgErr, "provider configuration failed") - } }) + if err != nil { + return provider, err + } - return provider, err + if opts == nil { + log.Entry().Debug("ConfigProvider options are not set. Provider configuration is skipped.") + return provider, nil + } + + // This allows configuration of the provider during initialization and/or after it (reconfiguration) + if cfgErr := provider.Configure(opts); cfgErr != nil { + return provider, errors.Wrap(cfgErr, "provider configuration failed") + } + + return provider, nil } // DetectOrchestrator function determines in which orchestrator Piper is running by examining environment variables.