Rename UpdateRepositoryParams to UpdateEntityParams

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-07-04 23:47:55 +00:00
parent 6c6c6636ba
commit 86ed06d6ff
24 changed files with 44 additions and 44 deletions

View file

@ -136,7 +136,7 @@ func (a *APIController) UpdateEnterpriseHandler(w http.ResponseWriter, r *http.R
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return

View file

@ -136,7 +136,7 @@ func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request)
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return

View file

@ -184,7 +184,7 @@ func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return

View file

@ -51,7 +51,7 @@ func (c *Client) CreateEnterprise(param params.CreateEnterpriseParams) (params.E
return response, nil
}
func (c *Client) UpdateEnterprise(enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (c *Client) UpdateEnterprise(enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
url := fmt.Sprintf("%s/api/v1/enterprises/%s", c.Config.BaseURL, enterpriseID)
var response params.Enterprise

View file

@ -51,8 +51,8 @@ func (c *Client) CreateOrganization(param params.CreateOrgParams) (params.Organi
return response, nil
}
func (c *Client) UpdateOrganization(enterpriseID string, param params.UpdateRepositoryParams) (params.Organization, error) {
url := fmt.Sprintf("%s/api/v1/organizations/%s", c.Config.BaseURL, enterpriseID)
func (c *Client) UpdateOrganization(orgID string, param params.UpdateEntityParams) (params.Organization, error) {
url := fmt.Sprintf("%s/api/v1/organizations/%s", c.Config.BaseURL, orgID)
var response params.Organization
body, err := json.Marshal(param)

View file

@ -147,7 +147,7 @@ func (c *Client) UpdateRepoPool(repoID, poolID string, param params.UpdatePoolPa
return response, nil
}
func (c *Client) UpdateRepo(repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (c *Client) UpdateRepo(repoID string, param params.UpdateEntityParams) (params.Repository, error) {
url := fmt.Sprintf("%s/api/v1/repositories/%s", c.Config.BaseURL, repoID)
var response params.Repository

View file

@ -153,7 +153,7 @@ var enterpriseUpdateCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}
enterpriseUpdateReq := params.UpdateRepositoryParams{
enterpriseUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
}

View file

@ -86,7 +86,7 @@ var orgUpdateCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}
orgUpdateReq := params.UpdateRepositoryParams{
orgUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: orgCreds,
}

View file

@ -108,7 +108,7 @@ var repoUpdateCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}
repoUpdateReq := params.UpdateRepositoryParams{
repoUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
}

View file

@ -26,7 +26,7 @@ type RepoStore interface {
GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error)
ListRepositories(ctx context.Context) ([]params.Repository, error)
DeleteRepository(ctx context.Context, repoID string) error
UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error)
UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error)
CreateRepositoryPool(ctx context.Context, repoId string, param params.CreatePoolParams) (params.Pool, error)
@ -45,7 +45,7 @@ type OrgStore interface {
GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error)
ListOrganizations(ctx context.Context) ([]params.Organization, error)
DeleteOrganization(ctx context.Context, orgID string) error
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error)
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error)
CreateOrganizationPool(ctx context.Context, orgId string, param params.CreatePoolParams) (params.Pool, error)
GetOrganizationPool(ctx context.Context, orgID, poolID string) (params.Pool, error)
@ -63,7 +63,7 @@ type EnterpriseStore interface {
GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error)
ListEnterprises(ctx context.Context) ([]params.Enterprise, error)
DeleteEnterprise(ctx context.Context, enterpriseID string) error
UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error)
UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error)
CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error)
GetEnterprisePool(ctx context.Context, enterpriseID, poolID string) (params.Pool, error)

View file

@ -1165,21 +1165,21 @@ func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, e
}
// 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) {
func (_m *Store) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
ret := _m.Called(ctx, enterpriseID, param)
var r0 params.Enterprise
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Enterprise, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Enterprise, error)); ok {
return rf(ctx, enterpriseID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Enterprise); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Enterprise); ok {
r0 = rf(ctx, enterpriseID, param)
} else {
r0 = ret.Get(0).(params.Enterprise)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, enterpriseID, param)
} else {
r1 = ret.Error(1)
@ -1237,21 +1237,21 @@ func (_m *Store) UpdateInstance(ctx context.Context, instanceID string, param pa
}
// UpdateOrganization provides a mock function with given fields: ctx, orgID, param
func (_m *Store) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (_m *Store) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
ret := _m.Called(ctx, orgID, param)
var r0 params.Organization
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Organization, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Organization, error)); ok {
return rf(ctx, orgID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Organization); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Organization); ok {
r0 = rf(ctx, orgID, param)
} else {
r0 = ret.Get(0).(params.Organization)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, orgID, param)
} else {
r1 = ret.Error(1)
@ -1285,21 +1285,21 @@ func (_m *Store) UpdateOrganizationPool(ctx context.Context, orgID string, poolI
}
// UpdateRepository provides a mock function with given fields: ctx, repoID, param
func (_m *Store) UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (_m *Store) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error) {
ret := _m.Called(ctx, repoID, param)
var r0 params.Repository
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Repository, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Repository, error)); ok {
return rf(ctx, repoID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Repository); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Repository); ok {
r0 = rf(ctx, repoID, param)
} else {
r0 = ret.Get(0).(params.Repository)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, repoID, param)
} else {
r1 = ret.Error(1)

View file

@ -99,7 +99,7 @@ func (s *sqlDatabase) DeleteEnterprise(ctx context.Context, enterpriseID string)
return nil
}
func (s *sqlDatabase) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (s *sqlDatabase) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
enterprise, err := s.getEnterpriseByID(ctx, enterpriseID)
if err != nil {
return params.Enterprise{}, errors.Wrap(err, "fetching enterprise")

View file

@ -40,7 +40,7 @@ type EnterpriseTestFixtures struct {
CreateEnterpriseParams params.CreateEnterpriseParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -142,7 +142,7 @@ func (s *EnterpriseTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},

View file

@ -103,7 +103,7 @@ func (s *sqlDatabase) DeleteOrganization(ctx context.Context, orgID string) erro
return nil
}
func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
org, err := s.getOrgByID(ctx, orgID)
if err != nil {
return params.Organization{}, errors.Wrap(err, "fetching org")

View file

@ -39,7 +39,7 @@ type OrgTestFixtures struct {
CreateOrgParams params.CreateOrgParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -141,7 +141,7 @@ func (s *OrgTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},

View file

@ -103,7 +103,7 @@ func (s *sqlDatabase) DeleteRepository(ctx context.Context, repoID string) error
return nil
}
func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error) {
repo, err := s.getRepoByID(ctx, repoID)
if err != nil {
return params.Repository{}, errors.Wrap(err, "fetching repo")

View file

@ -38,7 +38,7 @@ type RepoTestFixtures struct {
CreateRepoParams params.CreateRepoParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -153,7 +153,7 @@ func (s *RepoTestSuite) SetupTest() {
Name: "test-instance",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-webhook-secret",
},

View file

@ -227,7 +227,7 @@ func (p PasswordLoginParams) Validate() error {
return nil
}
type UpdateRepositoryParams struct {
type UpdateEntityParams struct {
CredentialsName string `json:"credentials_name"`
WebhookSecret string `json:"webhook_secret"`
}

View file

@ -144,7 +144,7 @@ func (r *Runner) DeleteEnterprise(ctx context.Context, enterpriseID string) erro
return nil
}
func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
if !auth.IsAdmin(ctx) {
return params.Enterprise{}, runnerErrors.ErrUnauthorized
}

View file

@ -44,7 +44,7 @@ type EnterpriseTestFixtures struct {
CreateEnterpriseParams params.CreateEnterpriseParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
UpdatePoolStateParams params.UpdatePoolStateParams
ErrMock error
@ -124,7 +124,7 @@ func (s *EnterpriseTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},

View file

@ -158,7 +158,7 @@ func (r *Runner) DeleteOrganization(ctx context.Context, orgID string) error {
return nil
}
func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
if !auth.IsAdmin(ctx) {
return params.Organization{}, runnerErrors.ErrUnauthorized
}

View file

@ -44,7 +44,7 @@ type OrgTestFixtures struct {
CreateOrgParams params.CreateOrgParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
UpdatePoolStateParams params.UpdatePoolStateParams
ErrMock error
@ -124,7 +124,7 @@ func (s *OrgTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},

View file

@ -157,7 +157,7 @@ func (r *Runner) DeleteRepository(ctx context.Context, repoID string) error {
return nil
}
func (r *Runner) UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (r *Runner) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error) {
if !auth.IsAdmin(ctx) {
return params.Repository{}, runnerErrors.ErrUnauthorized
}

View file

@ -43,7 +43,7 @@ type RepoTestFixtures struct {
CreateRepoParams params.CreateRepoParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
UpdatePoolStateParams params.UpdatePoolStateParams
ErrMock error
@ -124,7 +124,7 @@ func (s *RepoTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},