update return type of list to use pointer

jobatzil/rename
Vistaar Juneja 2023-08-10 16:52:39 +01:00
parent 01fffd56a3
commit c1ebb1837a
9 changed files with 19 additions and 20 deletions

View File

@ -20,7 +20,7 @@ func (c *Controller) List(
spaceRef string,
pipelineUID string,
pagination types.Pagination,
) ([]types.Execution, int64, error) {
) ([]*types.Execution, int64, error) {
space, err := c.spaceStore.FindByRef(ctx, spaceRef)
if err != nil {
return nil, 0, fmt.Errorf("failed to find parent space: %w", err)
@ -36,7 +36,7 @@ func (c *Controller) List(
}
var count int64
var executions []types.Execution
var executions []*types.Execution
err = dbtx.New(c.db).WithTx(ctx, func(ctx context.Context) (err error) {
var dbErr error

View File

@ -20,7 +20,7 @@ func (c *Controller) ListPipelines(
session *auth.Session,
spaceRef string,
pagination types.Pagination,
) ([]types.Pipeline, int64, error) {
) ([]*types.Pipeline, int64, error) {
space, err := c.spaceStore.FindByRef(ctx, spaceRef)
if err != nil {
return nil, 0, fmt.Errorf("failed to find parent space: %w", err)
@ -32,7 +32,7 @@ func (c *Controller) ListPipelines(
}
var count int64
var pipelines []types.Pipeline
var pipelines []*types.Pipeline
err = dbtx.New(c.db).WithTx(ctx, func(ctx context.Context) (err error) {
count, err = c.pipelineStore.Count(ctx, space.ID, pagination)

View File

@ -20,7 +20,7 @@ func (c *Controller) ListSecrets(
session *auth.Session,
spaceRef string,
pagination types.Pagination,
) ([]types.Secret, int64, error) {
) ([]*types.Secret, int64, error) {
space, err := c.spaceStore.FindByRef(ctx, spaceRef)
if err != nil {
return nil, 0, fmt.Errorf("failed to find parent space: %w", err)
@ -32,7 +32,7 @@ func (c *Controller) ListSecrets(
}
var count int64
var secrets []types.Secret
var secrets []*types.Secret
err = dbtx.New(c.db).WithTx(ctx, func(ctx context.Context) (err error) {
count, err = c.secretStore.Count(ctx, space.ID, pagination)

View File

@ -453,7 +453,7 @@ type (
Update(ctx context.Context, pipeline *types.Pipeline) error
// List lists the pipelines present in a parent space ID in the datastore.
List(ctx context.Context, spaceID int64, pagination types.Pagination) ([]types.Pipeline, error)
List(ctx context.Context, spaceID int64, pagination types.Pagination) ([]*types.Pipeline, error)
// UpdateOptLock updates the pipeline using the optimistic locking mechanism.
UpdateOptLock(ctx context.Context, pipeline *types.Pipeline,
@ -499,7 +499,7 @@ type (
DeleteByUID(ctx context.Context, spaceID int64, uid string) error
// List lists the secrets in a given space
List(ctx context.Context, spaceID int64, filter types.Pagination) ([]types.Secret, error)
List(ctx context.Context, spaceID int64, filter types.Pagination) ([]*types.Secret, error)
}
ExecutionStore interface {
@ -517,7 +517,7 @@ type (
mutateFn func(execution *types.Execution) error) (*types.Execution, error)
// List lists the executions for a given pipeline ID
List(ctx context.Context, pipelineID int64, pagination types.Pagination) ([]types.Execution, error)
List(ctx context.Context, pipelineID int64, pagination types.Pagination) ([]*types.Execution, error)
// Delete deletes an execution given a pipeline ID and an execution number
Delete(ctx context.Context, pipelineID int64, num int64) error

View File

@ -249,7 +249,7 @@ func (s *executionStore) List(
ctx context.Context,
pipelineID int64,
pagination types.Pagination,
) ([]types.Execution, error) {
) ([]*types.Execution, error) {
stmt := database.Builder.
Select(executionColumns).
From("executions").
@ -265,7 +265,7 @@ func (s *executionStore) List(
db := dbtx.GetAccessor(ctx, s.db)
dst := []types.Execution{}
dst := []*types.Execution{}
if err = db.SelectContext(ctx, &dst, sql, args...); err != nil {
return nil, database.ProcessSQLErrorf(err, "Failed executing custom list query")
}

View File

@ -173,7 +173,7 @@ func (s *pipelineStore) List(
ctx context.Context,
parentID int64,
pagination types.Pagination,
) ([]types.Pipeline, error) {
) ([]*types.Pipeline, error) {
stmt := database.Builder.
Select(pipelineColumns).
From("pipelines").
@ -193,7 +193,7 @@ func (s *pipelineStore) List(
db := dbtx.GetAccessor(ctx, s.db)
dst := []types.Pipeline{}
dst := []*types.Pipeline{}
if err = db.SelectContext(ctx, &dst, sql, args...); err != nil {
return nil, database.ProcessSQLErrorf(err, "Failed executing custom list query")
}

View File

@ -152,7 +152,8 @@ func (s *secretStore) Update(ctx context.Context, secret *types.Secret) error {
// UpdateOptLock updates the pipeline using the optimistic locking mechanism.
func (s *secretStore) UpdateOptLock(ctx context.Context,
secret *types.Secret,
mutateFn func(secret *types.Secret) error) (*types.Secret, error) {
mutateFn func(secret *types.Secret) error,
) (*types.Secret, error) {
for {
dup := *secret
@ -177,7 +178,7 @@ func (s *secretStore) UpdateOptLock(ctx context.Context,
}
// List lists all the secrets present in a space.
func (s *secretStore) List(ctx context.Context, parentID int64, pagination types.Pagination) ([]types.Secret, error) {
func (s *secretStore) List(ctx context.Context, parentID int64, pagination types.Pagination) ([]*types.Secret, error) {
stmt := database.Builder.
Select(secretColumns).
From("secrets").
@ -197,7 +198,7 @@ func (s *secretStore) List(ctx context.Context, parentID int64, pagination types
db := dbtx.GetAccessor(ctx, s.db)
dst := []types.Secret{}
dst := []*types.Secret{}
if err = db.SelectContext(ctx, &dst, sql, args...); err != nil {
return nil, database.ProcessSQLErrorf(err, "Failed executing custom list query")
}

View File

@ -8,10 +8,9 @@ import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
user "github.com/harness/gitness/internal/api/controller/user"
types "github.com/harness/gitness/types"
gomock "github.com/golang/mock/gomock"
)
// MockClient is a mock of Client interface.

View File

@ -8,10 +8,9 @@ import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
types "github.com/harness/gitness/types"
enum "github.com/harness/gitness/types/enum"
gomock "github.com/golang/mock/gomock"
)
// MockPrincipalStore is a mock of PrincipalStore interface.