@@ -67,6 +67,7 @@ func NewRunner(ctx context.Context, cfg config.Config, db dbCommon.Store) (*Runn
6767 poolManagerCtrl := & poolManagerCtrl {
6868 controllerID : ctrlID .ControllerID .String (),
6969 config : cfg ,
70+ store : db ,
7071 repositories : map [string ]common.PoolManager {},
7172 organizations : map [string ]common.PoolManager {},
7273 enterprises : map [string ]common.PoolManager {},
@@ -92,6 +93,7 @@ type poolManagerCtrl struct {
9293
9394 controllerID string
9495 config config.Config
96+ store dbCommon.Store
9597
9698 repositories map [string ]common.PoolManager
9799 organizations map [string ]common.PoolManager
@@ -102,7 +104,12 @@ func (p *poolManagerCtrl) CreateRepoPoolManager(ctx context.Context, repo params
102104 p .mux .Lock ()
103105 defer p .mux .Unlock ()
104106
105- cfgInternal , err := p .getInternalConfig (ctx , repo .Credentials , repo .GetBalancerType ())
107+ creds , err := p .store .GetGithubCredentialsByName (ctx , repo .CredentialsName , true )
108+ if err != nil {
109+ return nil , errors .Wrap (err , "fetching credentials" )
110+ }
111+
112+ cfgInternal , err := p .getInternalConfig (ctx , creds , repo .GetBalancerType ())
106113 if err != nil {
107114 return nil , errors .Wrap (err , "fetching internal config" )
108115 }
@@ -130,7 +137,12 @@ func (p *poolManagerCtrl) UpdateRepoPoolManager(ctx context.Context, repo params
130137 return nil , errors .Wrapf (runnerErrors .ErrNotFound , "repository %s/%s pool manager not loaded" , repo .Owner , repo .Name )
131138 }
132139
133- internalCfg , err := p .getInternalConfig (ctx , repo .Credentials , repo .GetBalancerType ())
140+ creds , err := p .store .GetGithubCredentialsByName (ctx , repo .CredentialsName , true )
141+ if err != nil {
142+ return nil , errors .Wrap (err , "fetching credentials" )
143+ }
144+
145+ internalCfg , err := p .getInternalConfig (ctx , creds , repo .GetBalancerType ())
134146 if err != nil {
135147 return nil , errors .Wrap (err , "fetching internal config" )
136148 }
@@ -175,7 +187,11 @@ func (p *poolManagerCtrl) CreateOrgPoolManager(ctx context.Context, org params.O
175187 p .mux .Lock ()
176188 defer p .mux .Unlock ()
177189
178- cfgInternal , err := p .getInternalConfig (ctx , org .Credentials , org .GetBalancerType ())
190+ creds , err := p .store .GetGithubCredentialsByName (ctx , org .CredentialsName , true )
191+ if err != nil {
192+ return nil , errors .Wrap (err , "fetching credentials" )
193+ }
194+ cfgInternal , err := p .getInternalConfig (ctx , creds , org .GetBalancerType ())
179195 if err != nil {
180196 return nil , errors .Wrap (err , "fetching internal config" )
181197 }
@@ -202,7 +218,11 @@ func (p *poolManagerCtrl) UpdateOrgPoolManager(ctx context.Context, org params.O
202218 return nil , errors .Wrapf (runnerErrors .ErrNotFound , "org %s pool manager not loaded" , org .Name )
203219 }
204220
205- internalCfg , err := p .getInternalConfig (ctx , org .Credentials , org .GetBalancerType ())
221+ creds , err := p .store .GetGithubCredentialsByName (ctx , org .CredentialsName , true )
222+ if err != nil {
223+ return nil , errors .Wrap (err , "fetching credentials" )
224+ }
225+ internalCfg , err := p .getInternalConfig (ctx , creds , org .GetBalancerType ())
206226 if err != nil {
207227 return nil , errors .Wrap (err , "fetching internal config" )
208228 }
@@ -247,7 +267,11 @@ func (p *poolManagerCtrl) CreateEnterprisePoolManager(ctx context.Context, enter
247267 p .mux .Lock ()
248268 defer p .mux .Unlock ()
249269
250- cfgInternal , err := p .getInternalConfig (ctx , enterprise .Credentials , enterprise .GetBalancerType ())
270+ creds , err := p .store .GetGithubCredentialsByName (ctx , enterprise .CredentialsName , true )
271+ if err != nil {
272+ return nil , errors .Wrap (err , "fetching credentials" )
273+ }
274+ cfgInternal , err := p .getInternalConfig (ctx , creds , enterprise .GetBalancerType ())
251275 if err != nil {
252276 return nil , errors .Wrap (err , "fetching internal config" )
253277 }
@@ -275,7 +299,11 @@ func (p *poolManagerCtrl) UpdateEnterprisePoolManager(ctx context.Context, enter
275299 return nil , errors .Wrapf (runnerErrors .ErrNotFound , "enterprise %s pool manager not loaded" , enterprise .Name )
276300 }
277301
278- internalCfg , err := p .getInternalConfig (ctx , enterprise .Credentials , enterprise .GetBalancerType ())
302+ creds , err := p .store .GetGithubCredentialsByName (ctx , enterprise .CredentialsName , true )
303+ if err != nil {
304+ return nil , errors .Wrap (err , "fetching credentials" )
305+ }
306+ internalCfg , err := p .getInternalConfig (ctx , creds , enterprise .GetBalancerType ())
279307 if err != nil {
280308 return nil , errors .Wrap (err , "fetching internal config" )
281309 }
0 commit comments