Set credentials in pool manager
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
f12d93f14c
commit
3d26900d32
15 changed files with 314 additions and 48 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -28,6 +28,20 @@ func (_m *Store) AddInstanceEvent(ctx context.Context, instanceID string, event
|
|||
return r0
|
||||
}
|
||||
|
||||
// BreakLockJobIsQueued provides a mock function with given fields: ctx, jobID
|
||||
func (_m *Store) BreakLockJobIsQueued(ctx context.Context, jobID int64) error {
|
||||
ret := _m.Called(ctx, jobID)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, jobID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// ControllerInfo provides a mock function with given fields:
|
||||
func (_m *Store) ControllerInfo() (params.ControllerInfo, error) {
|
||||
ret := _m.Called()
|
||||
|
|
@ -124,6 +138,30 @@ func (_m *Store) CreateInstance(ctx context.Context, poolID string, param params
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateOrUpdateJob provides a mock function with given fields: ctx, job
|
||||
func (_m *Store) CreateOrUpdateJob(ctx context.Context, job params.Job) (params.Job, error) {
|
||||
ret := _m.Called(ctx, job)
|
||||
|
||||
var r0 params.Job
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.Job) (params.Job, error)); ok {
|
||||
return rf(ctx, job)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.Job) params.Job); ok {
|
||||
r0 = rf(ctx, job)
|
||||
} else {
|
||||
r0 = ret.Get(0).(params.Job)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, params.Job) error); ok {
|
||||
r1 = rf(ctx, job)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateOrganization provides a mock function with given fields: ctx, name, credentialsName, webhookSecret
|
||||
func (_m *Store) CreateOrganization(ctx context.Context, name string, credentialsName string, webhookSecret string) (params.Organization, error) {
|
||||
ret := _m.Called(ctx, name, credentialsName, webhookSecret)
|
||||
|
|
@ -244,6 +282,20 @@ func (_m *Store) CreateUser(ctx context.Context, user params.NewUserParams) (par
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// DeleteCompletedJobs provides a mock function with given fields: ctx
|
||||
func (_m *Store) DeleteCompletedJobs(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteEnterprise provides a mock function with given fields: ctx, enterpriseID
|
||||
func (_m *Store) DeleteEnterprise(ctx context.Context, enterpriseID string) error {
|
||||
ret := _m.Called(ctx, enterpriseID)
|
||||
|
|
@ -286,6 +338,20 @@ func (_m *Store) DeleteInstance(ctx context.Context, poolID string, instanceName
|
|||
return r0
|
||||
}
|
||||
|
||||
// DeleteJob provides a mock function with given fields: ctx, jobID
|
||||
func (_m *Store) DeleteJob(ctx context.Context, jobID int64) error {
|
||||
ret := _m.Called(ctx, jobID)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, jobID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteOrganization provides a mock function with given fields: ctx, orgID
|
||||
func (_m *Store) DeleteOrganization(ctx context.Context, orgID string) error {
|
||||
ret := _m.Called(ctx, orgID)
|
||||
|
|
@ -404,6 +470,32 @@ func (_m *Store) FindOrganizationPoolByTags(ctx context.Context, orgID string, t
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// FindPoolsMatchingAllTags provides a mock function with given fields: ctx, entityType, entityID, tags
|
||||
func (_m *Store) FindPoolsMatchingAllTags(ctx context.Context, entityType params.PoolType, entityID string, tags []string) ([]params.Pool, error) {
|
||||
ret := _m.Called(ctx, entityType, entityID, tags)
|
||||
|
||||
var r0 []params.Pool
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, []string) ([]params.Pool, error)); ok {
|
||||
return rf(ctx, entityType, entityID, tags)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, []string) []params.Pool); ok {
|
||||
r0 = rf(ctx, entityType, entityID, tags)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]params.Pool)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, params.PoolType, string, []string) error); ok {
|
||||
r1 = rf(ctx, entityType, entityID, tags)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// FindRepositoryPoolByTags provides a mock function with given fields: ctx, repoID, tags
|
||||
func (_m *Store) FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error) {
|
||||
ret := _m.Called(ctx, repoID, tags)
|
||||
|
|
@ -524,6 +616,30 @@ func (_m *Store) GetInstanceByName(ctx context.Context, instanceName string) (pa
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// GetJobByID provides a mock function with given fields: ctx, jobID
|
||||
func (_m *Store) GetJobByID(ctx context.Context, jobID int64) (params.Job, error) {
|
||||
ret := _m.Called(ctx, jobID)
|
||||
|
||||
var r0 params.Job
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) (params.Job, error)); ok {
|
||||
return rf(ctx, jobID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) params.Job); ok {
|
||||
r0 = rf(ctx, jobID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(params.Job)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
|
||||
r1 = rf(ctx, jobID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetOrganization provides a mock function with given fields: ctx, name
|
||||
func (_m *Store) GetOrganization(ctx context.Context, name string) (params.Organization, error) {
|
||||
ret := _m.Called(ctx, name)
|
||||
|
|
@ -828,6 +944,32 @@ func (_m *Store) ListAllInstances(ctx context.Context) ([]params.Instance, error
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// ListAllJobs provides a mock function with given fields: ctx
|
||||
func (_m *Store) ListAllJobs(ctx context.Context) ([]params.Job, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 []params.Job
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) ([]params.Job, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) []params.Job); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]params.Job)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListAllPools provides a mock function with given fields: ctx
|
||||
func (_m *Store) ListAllPools(ctx context.Context) ([]params.Pool, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
|
@ -932,6 +1074,32 @@ func (_m *Store) ListEnterprises(ctx context.Context) ([]params.Enterprise, erro
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// ListEntityJobsByStatus provides a mock function with given fields: ctx, entityType, entityID, status
|
||||
func (_m *Store) ListEntityJobsByStatus(ctx context.Context, entityType params.PoolType, entityID string, status params.JobStatus) ([]params.Job, error) {
|
||||
ret := _m.Called(ctx, entityType, entityID, status)
|
||||
|
||||
var r0 []params.Job
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, params.JobStatus) ([]params.Job, error)); ok {
|
||||
return rf(ctx, entityType, entityID, status)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, params.JobStatus) []params.Job); ok {
|
||||
r0 = rf(ctx, entityType, entityID, status)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]params.Job)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, params.PoolType, string, params.JobStatus) error); ok {
|
||||
r1 = rf(ctx, entityType, entityID, status)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListInstanceEvents provides a mock function with given fields: ctx, instanceID, eventType, eventLevel
|
||||
func (_m *Store) ListInstanceEvents(ctx context.Context, instanceID string, eventType params.EventType, eventLevel params.EventLevel) ([]params.StatusMessage, error) {
|
||||
ret := _m.Called(ctx, instanceID, eventType, eventLevel)
|
||||
|
|
@ -958,6 +1126,32 @@ func (_m *Store) ListInstanceEvents(ctx context.Context, instanceID string, even
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// ListJobsByStatus provides a mock function with given fields: ctx, status
|
||||
func (_m *Store) ListJobsByStatus(ctx context.Context, status params.JobStatus) ([]params.Job, error) {
|
||||
ret := _m.Called(ctx, status)
|
||||
|
||||
var r0 []params.Job
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.JobStatus) ([]params.Job, error)); ok {
|
||||
return rf(ctx, status)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, params.JobStatus) []params.Job); ok {
|
||||
r0 = rf(ctx, status)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]params.Job)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, params.JobStatus) error); ok {
|
||||
r1 = rf(ctx, status)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListOrgInstances provides a mock function with given fields: ctx, orgID
|
||||
func (_m *Store) ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) {
|
||||
ret := _m.Called(ctx, orgID)
|
||||
|
|
@ -1140,6 +1334,20 @@ func (_m *Store) ListRepositories(ctx context.Context) ([]params.Repository, err
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// LockJob provides a mock function with given fields: ctx, jobID, entityID
|
||||
func (_m *Store) LockJob(ctx context.Context, jobID int64, entityID string) error {
|
||||
ret := _m.Called(ctx, jobID, entityID)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
|
||||
r0 = rf(ctx, jobID, entityID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// PoolInstanceCount provides a mock function with given fields: ctx, poolID
|
||||
func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, error) {
|
||||
ret := _m.Called(ctx, poolID)
|
||||
|
|
@ -1164,6 +1372,20 @@ func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, e
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// UnlockJob provides a mock function with given fields: ctx, jobID, entityID
|
||||
func (_m *Store) UnlockJob(ctx context.Context, jobID int64, entityID string) error {
|
||||
ret := _m.Called(ctx, jobID, entityID)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
|
||||
r0 = rf(ctx, jobID, entityID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateEnterprise provides a mock function with given fields: ctx, enterpriseID, param
|
||||
func (_m *Store) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
|
||||
ret := _m.Called(ctx, enterpriseID, param)
|
||||
|
|
@ -1356,13 +1578,12 @@ func (_m *Store) UpdateUser(ctx context.Context, user string, param params.Updat
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewStore interface {
|
||||
// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewStore(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewStore(t mockConstructorTestingTNewStore) *Store {
|
||||
}) *Store {
|
||||
mock := &Store{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -402,7 +402,8 @@ type Provider struct {
|
|||
}
|
||||
|
||||
type UpdatePoolStateParams struct {
|
||||
WebhookSecret string
|
||||
WebhookSecret string
|
||||
InternalConfig *Internal
|
||||
}
|
||||
|
||||
type PoolManagerStatus struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -311,13 +311,12 @@ func (_m *GithubClient) RemoveRunner(ctx context.Context, owner string, repo str
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewGithubClient interface {
|
||||
// NewGithubClient creates a new instance of GithubClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewGithubClient(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewGithubClient creates a new instance of GithubClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewGithubClient(t mockConstructorTestingTNewGithubClient) *GithubClient {
|
||||
}) *GithubClient {
|
||||
mock := &GithubClient{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -145,13 +145,12 @@ func (_m *GithubEnterpriseClient) RemoveRunner(ctx context.Context, enterprise s
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewGithubEnterpriseClient interface {
|
||||
// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewGithubEnterpriseClient(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewGithubEnterpriseClient(t mockConstructorTestingTNewGithubEnterpriseClient) *GithubEnterpriseClient {
|
||||
}) *GithubEnterpriseClient {
|
||||
mock := &GithubEnterpriseClient{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -162,13 +162,12 @@ func (_m *PoolManager) WebhookSecret() string {
|
|||
return r0
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewPoolManager interface {
|
||||
// NewPoolManager creates a new instance of PoolManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewPoolManager(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewPoolManager creates a new instance of PoolManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewPoolManager(t mockConstructorTestingTNewPoolManager) *PoolManager {
|
||||
}) *PoolManager {
|
||||
mock := &PoolManager{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -158,13 +158,12 @@ func (_m *Provider) Stop(ctx context.Context, instance string, force bool) error
|
|||
return r0
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewProvider interface {
|
||||
// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewProvider(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewProvider(t mockConstructorTestingTNewProvider) *Provider {
|
||||
}) *Provider {
|
||||
mock := &Provider{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -170,11 +170,15 @@ func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, para
|
|||
}
|
||||
|
||||
poolMgr, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise)
|
||||
if err != nil {
|
||||
newState := params.UpdatePoolStateParams{
|
||||
WebhookSecret: enterprise.WebhookSecret,
|
||||
if err == nil {
|
||||
internalCfg, err := r.poolManagerCtrl.GetInternalConfig(enterprise.CredentialsName)
|
||||
if err != nil {
|
||||
return params.Enterprise{}, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
newState := params.UpdatePoolStateParams{
|
||||
WebhookSecret: enterprise.WebhookSecret,
|
||||
InternalConfig: &internalCfg,
|
||||
}
|
||||
// stop the pool mgr
|
||||
if err := poolMgr.RefreshState(newState); err != nil {
|
||||
return params.Enterprise{}, errors.Wrap(err, "updating enterprise pool manager")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,4 +49,6 @@ type PoolManagerController interface {
|
|||
RepoPoolManager
|
||||
OrgPoolManager
|
||||
EnterprisePoolManager
|
||||
|
||||
GetInternalConfig(credsName string) (params.Internal, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
@ -191,6 +191,30 @@ func (_m *PoolManagerController) GetEnterprisePoolManagers() (map[string]common.
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// GetInternalConfig provides a mock function with given fields: credsName
|
||||
func (_m *PoolManagerController) GetInternalConfig(credsName string) (params.Internal, error) {
|
||||
ret := _m.Called(credsName)
|
||||
|
||||
var r0 params.Internal
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (params.Internal, error)); ok {
|
||||
return rf(credsName)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) params.Internal); ok {
|
||||
r0 = rf(credsName)
|
||||
} else {
|
||||
r0 = ret.Get(0).(params.Internal)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(credsName)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetOrgPoolManager provides a mock function with given fields: org
|
||||
func (_m *PoolManagerController) GetOrgPoolManager(org params.Organization) (common.PoolManager, error) {
|
||||
ret := _m.Called(org)
|
||||
|
|
@ -295,13 +319,12 @@ func (_m *PoolManagerController) GetRepoPoolManagers() (map[string]common.PoolMa
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewPoolManagerController interface {
|
||||
// NewPoolManagerController creates a new instance of PoolManagerController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewPoolManagerController(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewPoolManagerController creates a new instance of PoolManagerController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewPoolManagerController(t mockConstructorTestingTNewPoolManagerController) *PoolManagerController {
|
||||
}) *PoolManagerController {
|
||||
mock := &PoolManagerController{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -185,8 +185,13 @@ func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param par
|
|||
|
||||
poolMgr, err := r.poolManagerCtrl.GetOrgPoolManager(org)
|
||||
if err != nil {
|
||||
internalCfg, err := r.poolManagerCtrl.GetInternalConfig(org.CredentialsName)
|
||||
if err != nil {
|
||||
return params.Organization{}, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
newState := params.UpdatePoolStateParams{
|
||||
WebhookSecret: org.WebhookSecret,
|
||||
WebhookSecret: org.WebhookSecret,
|
||||
InternalConfig: &internalCfg,
|
||||
}
|
||||
// stop the pool mgr
|
||||
if err := poolMgr.RefreshState(newState); err != nil {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,9 @@ func (r *enterprise) UpdateState(param params.UpdatePoolStateParams) error {
|
|||
defer r.mux.Unlock()
|
||||
|
||||
r.cfg.WebhookSecret = param.WebhookSecret
|
||||
if param.InternalConfig != nil {
|
||||
r.cfgInternal = *param.InternalConfig
|
||||
}
|
||||
|
||||
ghc, ghcEnterprise, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ func (r *organization) UpdateState(param params.UpdatePoolStateParams) error {
|
|||
defer r.mux.Unlock()
|
||||
|
||||
r.cfg.WebhookSecret = param.WebhookSecret
|
||||
if param.InternalConfig != nil {
|
||||
r.cfgInternal = *param.InternalConfig
|
||||
}
|
||||
|
||||
ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ func (r *repository) UpdateState(param params.UpdatePoolStateParams) error {
|
|||
defer r.mux.Unlock()
|
||||
|
||||
r.cfg.WebhookSecret = param.WebhookSecret
|
||||
if param.InternalConfig != nil {
|
||||
r.cfgInternal = *param.InternalConfig
|
||||
}
|
||||
|
||||
ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -183,9 +183,14 @@ func (r *Runner) UpdateRepository(ctx context.Context, repoID string, param para
|
|||
}
|
||||
|
||||
poolMgr, err := r.poolManagerCtrl.GetRepoPoolManager(repo)
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
internalCfg, err := r.poolManagerCtrl.GetInternalConfig(repo.CredentialsName)
|
||||
if err != nil {
|
||||
return params.Repository{}, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
newState := params.UpdatePoolStateParams{
|
||||
WebhookSecret: repo.WebhookSecret,
|
||||
WebhookSecret: repo.WebhookSecret,
|
||||
InternalConfig: &internalCfg,
|
||||
}
|
||||
// stop the pool mgr
|
||||
if err := poolMgr.RefreshState(newState); err != nil {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func (p *poolManagerCtrl) CreateRepoPoolManager(ctx context.Context, repo params
|
|||
p.mux.Lock()
|
||||
defer p.mux.Unlock()
|
||||
|
||||
cfgInternal, err := p.getInternalConfig(repo.CredentialsName)
|
||||
cfgInternal, err := p.GetInternalConfig(repo.CredentialsName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ func (p *poolManagerCtrl) CreateOrgPoolManager(ctx context.Context, org params.O
|
|||
p.mux.Lock()
|
||||
defer p.mux.Unlock()
|
||||
|
||||
cfgInternal, err := p.getInternalConfig(org.CredentialsName)
|
||||
cfgInternal, err := p.GetInternalConfig(org.CredentialsName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ func (p *poolManagerCtrl) CreateEnterprisePoolManager(ctx context.Context, enter
|
|||
p.mux.Lock()
|
||||
defer p.mux.Unlock()
|
||||
|
||||
cfgInternal, err := p.getInternalConfig(enterprise.CredentialsName)
|
||||
cfgInternal, err := p.GetInternalConfig(enterprise.CredentialsName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fetching internal config")
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ func (p *poolManagerCtrl) GetEnterprisePoolManagers() (map[string]common.PoolMan
|
|||
return p.enterprises, nil
|
||||
}
|
||||
|
||||
func (p *poolManagerCtrl) getInternalConfig(credsName string) (params.Internal, error) {
|
||||
func (p *poolManagerCtrl) GetInternalConfig(credsName string) (params.Internal, error) {
|
||||
creds, ok := p.credentials[credsName]
|
||||
if !ok {
|
||||
return params.Internal{}, runnerErrors.NewBadRequestError("invalid credential name (%s)", credsName)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue