Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 7eb6227

Browse files
author
Noah Lee
authored
Fix plural naming (#342)
* Fix plural in the `interactor` pkg * Fix the `repos` pkg * Fix the `api` pkg
1 parent 479e993 commit 7eb6227

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+183
-183
lines changed

cmd/cli/deployment_deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var deploymentDeployCommand = &cli.Command{
3434
}
3535

3636
c := buildClient(cli)
37-
d, err := c.Deployments.Create(cli.Context, ns, n, api.DeploymentCreateRequest{
37+
d, err := c.Deployment.Create(cli.Context, ns, n, api.DeploymentCreateRequest{
3838
Type: cli.String("type"),
3939
Ref: cli.String("ref"),
4040
Env: cli.String("env"),

cmd/cli/deployment_get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var deploymentGetCommand = &cli.Command{
2323
}
2424

2525
c := buildClient(cli)
26-
d, err := c.Deployments.Get(cli.Context, ns, n, number)
26+
d, err := c.Deployment.Get(cli.Context, ns, n, number)
2727
if err != nil {
2828
return err
2929
}

cmd/cli/deployment_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var deploymentListCommand = &cli.Command{
4040
return err
4141
}
4242

43-
ds, err := c.Deployments.List(cli.Context, ns, n, api.DeploymentListOptions{
43+
ds, err := c.Deployment.List(cli.Context, ns, n, api.DeploymentListOptions{
4444
ListOptions: api.ListOptions{Page: cli.Int("page"), PerPage: cli.Int("per-page")},
4545
Env: cli.String("env"),
4646
Status: deployment.Status(cli.String("status")),

cmd/cli/deployment_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var deploymentUpdateCommand = &cli.Command{
2222
}
2323

2424
c := buildClient(cli)
25-
d, err := c.Deployments.Update(cli.Context, ns, n, number)
25+
d, err := c.Deployment.Update(cli.Context, ns, n, number)
2626
if err != nil {
2727
return err
2828
}

cmd/cli/repo_get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var repoGetCommand = &cli.Command{
1919
}
2020

2121
c := buildClient(cli)
22-
repo, err := c.Repos.Get(cli.Context, ns, n)
22+
repo, err := c.Repo.Get(cli.Context, ns, n)
2323
if err != nil {
2424
return err
2525
}

cmd/cli/repo_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ var repoListCommand = &cli.Command{
4040
)
4141

4242
if cli.Bool("all") {
43-
if repos, err = c.Repos.ListAll(cli.Context); err != nil {
43+
if repos, err = c.Repo.ListAll(cli.Context); err != nil {
4444
return err
4545
}
4646
} else {
47-
if repos, err = c.Repos.List(cli.Context, api.RepoListOptions{
47+
if repos, err = c.Repo.List(cli.Context, api.RepoListOptions{
4848
ListOptions: api.ListOptions{Page: cli.Int("page"), PerPage: cli.Int("per-page")},
4949
}); err != nil {
5050
return err

cmd/cli/repo_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var repoUpdateCommand = &cli.Command{
4949
}
5050

5151
c := buildClient(cli)
52-
repo, err := c.Repos.Update(cli.Context, ns, n, req)
52+
repo, err := c.Repo.Update(cli.Context, ns, n, req)
5353
if err != nil {
5454
return err
5555
}

internal/interactor/deployment.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import (
1515
)
1616

1717
type (
18-
DeploymentsInteractor service
18+
DeploymentInteractor service
1919
)
2020

2121
// IsApproved verifies that the request is approved or not.
2222
// It is approved if there is an approval of reviews at least, but
2323
// it is rejected if there is a reject of reviews.
24-
func (i *DeploymentsInteractor) IsApproved(ctx context.Context, d *ent.Deployment) bool {
24+
func (i *DeploymentInteractor) IsApproved(ctx context.Context, d *ent.Deployment) bool {
2525
rvs, _ := i.store.ListReviews(ctx, d)
2626

2727
for _, r := range rvs {
@@ -43,7 +43,7 @@ func (i *DeploymentsInteractor) IsApproved(ctx context.Context, d *ent.Deploymen
4343
// But if it requires a review, it saves the payload on the DB
4444
// and waits until reviewed.
4545
// It returns an error for a undeployable payload.
46-
func (i *DeploymentsInteractor) Deploy(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*ent.Deployment, error) {
46+
func (i *DeploymentInteractor) Deploy(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*ent.Deployment, error) {
4747
if err := i.isDeployable(ctx, u, r, d, env); err != nil {
4848
return nil, err
4949
}
@@ -128,7 +128,7 @@ func (i *DeploymentsInteractor) Deploy(ctx context.Context, u *ent.User, r *ent.
128128
// DeployToRemote posts a new deployment to SCM with the saved payload
129129
// after review has finished.
130130
// It returns an error for a undeployable payload.
131-
func (i *DeploymentsInteractor) DeployToRemote(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*ent.Deployment, error) {
131+
func (i *DeploymentInteractor) DeployToRemote(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*ent.Deployment, error) {
132132
if d.Status != deployment.StatusWaiting {
133133
return nil, e.NewErrorWithMessage(
134134
e.ErrorCodeDeploymentStatusInvalid,
@@ -172,7 +172,7 @@ func (i *DeploymentsInteractor) DeployToRemote(ctx context.Context, u *ent.User,
172172
return d, nil
173173
}
174174

175-
func (i *DeploymentsInteractor) createRemoteDeployment(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*extent.RemoteDeployment, error) {
175+
func (i *DeploymentInteractor) createRemoteDeployment(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*extent.RemoteDeployment, error) {
176176
// Rollback configures it can deploy the ref without any constraints.
177177
// 1) Set auto_merge false to avoid the merge conflict.
178178
// 2) Set required_contexts empty to skip the verfication.
@@ -184,7 +184,7 @@ func (i *DeploymentsInteractor) createRemoteDeployment(ctx context.Context, u *e
184184
return i.scm.CreateRemoteDeployment(ctx, u, r, d, env)
185185
}
186186

187-
func (i *DeploymentsInteractor) isDeployable(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) error {
187+
func (i *DeploymentInteractor) isDeployable(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) error {
188188
// Skip verifications for roll back.
189189
if !d.IsRollback {
190190
if ok, err := env.IsDeployableRef(d.Ref); !ok {
@@ -210,7 +210,7 @@ func (i *DeploymentsInteractor) isDeployable(ctx context.Context, u *ent.User, r
210210
return nil
211211
}
212212

213-
func (i *DeploymentsInteractor) runClosingInactiveDeployment(stop <-chan struct{}) {
213+
func (i *DeploymentInteractor) runClosingInactiveDeployment(stop <-chan struct{}) {
214214
ctx := context.Background()
215215

216216
ticker := time.NewTicker(time.Minute)

internal/interactor/deployment_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"github.com/gitploy-io/gitploy/pkg/e"
1818
)
1919

20-
func newMockDeploymentsInteractor(store Store, scm SCM) *DeploymentsInteractor {
21-
return &DeploymentsInteractor{
20+
func newMockDeploymentInteractor(store Store, scm SCM) *DeploymentInteractor {
21+
return &DeploymentInteractor{
2222
store: store,
2323
scm: scm,
2424
log: zap.L(),
@@ -44,7 +44,7 @@ func TestInteractor_IsApproved(t *testing.T) {
4444
},
4545
}, nil)
4646

47-
i := newMockDeploymentsInteractor(store, scm)
47+
i := newMockDeploymentInteractor(store, scm)
4848

4949
expected := false
5050
if ret := i.IsApproved(context.Background(), &ent.Deployment{}); ret != expected {
@@ -75,7 +75,7 @@ func TestInteractor_Deploy(t *testing.T) {
7575
store := mock.NewMockStore(ctrl)
7676
scm := mock.NewMockSCM(ctrl)
7777

78-
i := newMockDeploymentsInteractor(store, scm)
78+
i := newMockDeploymentInteractor(store, scm)
7979

8080
_, err := i.Deploy(context.Background(), &ent.User{}, &ent.Repo{}, input.d, input.e)
8181
if !e.HasErrorCode(err, e.ErrorCodeEntityUnprocessable) {
@@ -93,7 +93,7 @@ func TestInteractor_Deploy(t *testing.T) {
9393
HasLockOfRepoForEnv(ctx, gomock.AssignableToTypeOf(&ent.Repo{}), "").
9494
Return(true, nil)
9595

96-
i := newMockDeploymentsInteractor(store, scm)
96+
i := newMockDeploymentInteractor(store, scm)
9797

9898
_, err := i.Deploy(context.Background(), &ent.User{}, &ent.Repo{}, &ent.Deployment{}, &extent.Env{})
9999
if !e.HasErrorCode(err, e.ErrorCodeDeploymentLocked) {
@@ -159,7 +159,7 @@ func TestInteractor_Deploy(t *testing.T) {
159159
EXPECT().
160160
CreateDeploymentStatus(ctx, gomock.AssignableToTypeOf(&ent.DeploymentStatus{}))
161161

162-
i := newMockDeploymentsInteractor(store, scm)
162+
i := newMockDeploymentInteractor(store, scm)
163163

164164
d, err := i.Deploy(context.Background(), &ent.User{}, &ent.Repo{}, input.d, input.e)
165165
if err != nil {
@@ -243,7 +243,7 @@ func TestInteractor_Deploy(t *testing.T) {
243243
CreateEvent(ctx, gomock.AssignableToTypeOf(&ent.Event{})).
244244
Return(&ent.Event{}, nil)
245245

246-
i := newMockDeploymentsInteractor(store, scm)
246+
i := newMockDeploymentInteractor(store, scm)
247247

248248
d, err := i.Deploy(context.Background(), &ent.User{}, &ent.Repo{}, input.d, input.e)
249249
if err != nil {
@@ -281,7 +281,7 @@ func TestInteractor_DeployToRemote(t *testing.T) {
281281
store := mock.NewMockStore(ctrl)
282282
scm := mock.NewMockSCM(ctrl)
283283

284-
i := newMockDeploymentsInteractor(store, scm)
284+
i := newMockDeploymentInteractor(store, scm)
285285

286286
_, err := i.DeployToRemote(context.Background(), &ent.User{}, &ent.Repo{}, input.d, input.e)
287287
if !e.HasErrorCode(err, e.ErrorCodeDeploymentStatusInvalid) {
@@ -345,7 +345,7 @@ func TestInteractor_DeployToRemote(t *testing.T) {
345345
EXPECT().
346346
CreateDeploymentStatus(ctx, gomock.AssignableToTypeOf(&ent.DeploymentStatus{}))
347347

348-
i := newMockDeploymentsInteractor(store, scm)
348+
i := newMockDeploymentInteractor(store, scm)
349349

350350
d, err := i.DeployToRemote(context.Background(), &ent.User{}, &ent.Repo{}, input.d, input.e)
351351
if err != nil {

internal/interactor/event.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ const (
1515
)
1616

1717
type (
18-
EventsInteractor struct {
18+
EventInteractor struct {
1919
*service
2020

2121
events evbus.Bus
2222
}
2323
)
2424

25-
func (i *EventsInteractor) SubscribeEvent(fn func(e *ent.Event)) error {
25+
func (i *EventInteractor) SubscribeEvent(fn func(e *ent.Event)) error {
2626
return i.events.SubscribeAsync(gitployEvent, fn, false)
2727
}
2828

29-
func (i *EventsInteractor) UnsubscribeEvent(fn func(e *ent.Event)) error {
29+
func (i *EventInteractor) UnsubscribeEvent(fn func(e *ent.Event)) error {
3030
return i.events.Unsubscribe(gitployEvent, fn)
3131
}
3232

33-
func (i *EventsInteractor) runPublishingEvents(stop <-chan struct{}) {
33+
func (i *EventInteractor) runPublishingEvents(stop <-chan struct{}) {
3434
ctx := context.Background()
3535

3636
// Read events periodically and publish to subscribers.

0 commit comments

Comments
 (0)