Skip to content

Commit

Permalink
Remove plural words in methods
Browse files Browse the repository at this point in the history
Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene committed Nov 18, 2024
1 parent f30ca4a commit 8be700b
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion api/http/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func deleteCertEndpoint(svc certs.Service) endpoint.Endpoint {
return deleteCertRes{deleted: false}, err
}

if err = svc.RemoveCerts(ctx, req.entityID); err != nil {
if err = svc.RemoveCert(ctx, req.entityID); err != nil {
return deleteCertRes{deleted: false}, err
}

Expand Down
6 changes: 3 additions & 3 deletions api/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ func (lm *loggingMiddleware) ListCerts(ctx context.Context, pm certs.PageMetadat
return lm.svc.ListCerts(ctx, pm)
}

func (lm *loggingMiddleware) RemoveCerts(ctx context.Context, entityId string) (err error) {
func (lm *loggingMiddleware) RemoveCert(ctx context.Context, entityId string) (err error) {
defer func(begin time.Time) {
message := fmt.Sprintf("Method remove_certs took %s to complete", time.Since(begin))
message := fmt.Sprintf("Method remove_cert took %s to complete", time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(message)
}(time.Now())
return lm.svc.RemoveCerts(ctx, entityId)
return lm.svc.RemoveCert(ctx, entityId)
}

func (lm *loggingMiddleware) ViewCert(ctx context.Context, serialNumber string) (cert certs.Certificate, err error) {
Expand Down
8 changes: 4 additions & 4 deletions api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ func (mm *metricsMiddleware) ListCerts(ctx context.Context, pm certs.PageMetadat
return mm.svc.ListCerts(ctx, pm)
}

func (mm *metricsMiddleware) RemoveCerts(ctx context.Context, entityId string) error {
func (mm *metricsMiddleware) RemoveCert(ctx context.Context, entityId string) error {
defer func(begin time.Time) {
mm.counter.With("method", "remove_certificates").Add(1)
mm.latency.With("method", "remove_certificates").Observe(time.Since(begin).Seconds())
mm.counter.With("method", "remove_certificate").Add(1)
mm.latency.With("method", "remove_certificate").Observe(time.Since(begin).Seconds())
}(time.Now())
return mm.svc.RemoveCerts(ctx, entityId)
return mm.svc.RemoveCert(ctx, entityId)
}

func (mm *metricsMiddleware) ViewCert(ctx context.Context, serialNumber string) (certs.Certificate, error) {
Expand Down
8 changes: 4 additions & 4 deletions certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type Service interface {
// GetChainCA retrieves the chain of CA i.e. root and intermediate cert concat together.
GetChainCA(ctx context.Context, token string) (Certificate, error)

// RemoveCerts deletes a certs for a provided entityID.
RemoveCerts(ctx context.Context, entityId string) error
// RemoveCert deletes a cert for a provided entityID.
RemoveCert(ctx context.Context, entityId string) error
}

type Repository interface {
Expand All @@ -94,6 +94,6 @@ type Repository interface {
// ListRevokedCerts retrieves revoked lists from database.
ListRevokedCerts(ctx context.Context) ([]Certificate, error)

// RemoveCerts deletes certs from database.
RemoveCerts(ctx context.Context, entityId string) error
// RemoveCert deletes cert from database.
RemoveCert(ctx context.Context, entityId string) error
}
2 changes: 1 addition & 1 deletion cli/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var cmdCerts = []cobra.Command{
logUsageCmd(*cmd, cmd.Use)
return
}
err := sdk.DeleteCerts(args[0])
err := sdk.DeleteCert(args[0])
if err != nil {
logErrorCmd(*cmd, err)
return
Expand Down
22 changes: 11 additions & 11 deletions mocks/repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion postgres/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (repo certsRepo) ListRevokedCerts(ctx context.Context) ([]certs.Certificate
return revokedCerts, nil
}

func (repo certsRepo) RemoveCerts(ctx context.Context, backendId string) error {
func (repo certsRepo) RemoveCert(ctx context.Context, backendId string) error {
q := `DELETE FROM certs WHERE entity_id = $1`

result, err := repo.db.ExecContext(ctx, q, backendId)
Expand Down
6 changes: 3 additions & 3 deletions sdk/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ func TestDeleteCert(t *testing.T) {

for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
svcCall := svc.On("RemoveCerts", mock.Anything, tc.entityID).Return(tc.svcerr)
svcCall := svc.On("RemoveCert", mock.Anything, tc.entityID).Return(tc.svcerr)

err := ctsdk.DeleteCerts(tc.entityID)
err := ctsdk.DeleteCert(tc.entityID)
assert.Equal(t, tc.err, err)
if tc.desc != "DeleteCert with empty entity id" {
ok := svcCall.Parent.AssertCalled(t, "RemoveCerts", mock.Anything, tc.entityID)
ok := svcCall.Parent.AssertCalled(t, "RemoveCert", mock.Anything, tc.entityID)
assert.True(t, ok)
}
svcCall.Unset()
Expand Down
22 changes: 11 additions & 11 deletions sdk/mocks/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ type SDK interface {
// fmt.Println(page)
ListCerts(pm PageMetadata) (CertificatePage, errors.SDKError)

// DeleteCerts deletes certificates for a given entityID.
// DeleteCert deletes certificates for a given entityID.
//
// example:
// err := sdk.DeleteCerts("entityID")
// err := sdk.DeleteCert("entityID")
// fmt.Println(err)
DeleteCerts(entityID string) errors.SDKError
DeleteCert(entityID string) errors.SDKError

// ViewCert retrieves a certificate record from the database.
//
Expand Down Expand Up @@ -298,7 +298,7 @@ func (sdk mgSDK) ListCerts(pm PageMetadata) (CertificatePage, errors.SDKError) {
return cp, nil
}

func (sdk mgSDK) DeleteCerts(entityID string) errors.SDKError {
func (sdk mgSDK) DeleteCert(entityID string) errors.SDKError {
url := fmt.Sprintf("%s/%s/%s/delete", sdk.certsURL, certsEndpoint, entityID)
_, _, sdkerr := sdk.processRequest(http.MethodDelete, url, nil, nil, http.StatusNoContent)
return sdkerr
Expand Down
4 changes: 2 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ func (s *service) ListCerts(ctx context.Context, pm PageMetadata) (CertificatePa
return certPg, nil
}

func (s *service) RemoveCerts(ctx context.Context, entityId string) error {
return s.repo.RemoveCerts(ctx, entityId)
func (s *service) RemoveCert(ctx context.Context, entityId string) error {
return s.repo.RemoveCert(ctx, entityId)
}

func (s *service) ViewCert(ctx context.Context, serialNumber string) (Certificate, error) {
Expand Down
6 changes: 3 additions & 3 deletions tracing/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ func (tm *tracingMiddleware) ListCerts(ctx context.Context, pm certs.PageMetadat
return tm.svc.ListCerts(ctx, pm)
}

func (tm *tracingMiddleware) RemoveCerts(ctx context.Context, entityId string) (err error) {
ctx, span := tm.tracer.Start(ctx, "remove_certs")
func (tm *tracingMiddleware) RemoveCert(ctx context.Context, entityId string) (err error) {
ctx, span := tm.tracer.Start(ctx, "remove_cert")
defer span.End()
return tm.svc.RemoveCerts(ctx, entityId)
return tm.svc.RemoveCert(ctx, entityId)
}

func (s *tracingMiddleware) ViewCert(ctx context.Context, serialNumber string) (certs.Certificate, error) {
Expand Down

0 comments on commit 8be700b

Please sign in to comment.