Skip to content

Commit

Permalink
Merge pull request #240 from gabriel-samfira/deduplicate-db-code
Browse files Browse the repository at this point in the history
Deduplicate db code
  • Loading branch information
gabriel-samfira authored Mar 29, 2024
2 parents 72501ae + f9f545f commit 9cbb2f8
Show file tree
Hide file tree
Showing 24 changed files with 1,099 additions and 1,654 deletions.
39 changes: 11 additions & 28 deletions database/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ type RepoStore interface {
ListRepositories(ctx context.Context) ([]params.Repository, error)
DeleteRepository(ctx context.Context, repoID string) 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)

GetRepositoryPool(ctx context.Context, repoID, poolID string) (params.Pool, error)
DeleteRepositoryPool(ctx context.Context, repoID, poolID string) error
UpdateRepositoryPool(ctx context.Context, repoID, poolID string, param params.UpdatePoolParams) (params.Pool, error)
FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error)

ListRepoPools(ctx context.Context, repoID string) ([]params.Pool, error)
ListRepoInstances(ctx context.Context, repoID string) ([]params.Instance, error)
}

type OrgStore interface {
Expand All @@ -46,15 +36,6 @@ type OrgStore interface {
ListOrganizations(ctx context.Context) ([]params.Organization, error)
DeleteOrganization(ctx context.Context, orgID string) 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)
DeleteOrganizationPool(ctx context.Context, orgID, poolID string) error
UpdateOrganizationPool(ctx context.Context, orgID, poolID string, param params.UpdatePoolParams) (params.Pool, error)

FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error)
ListOrgPools(ctx context.Context, orgID string) ([]params.Pool, error)
ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error)
}

type EnterpriseStore interface {
Expand All @@ -64,15 +45,6 @@ type EnterpriseStore interface {
ListEnterprises(ctx context.Context) ([]params.Enterprise, error)
DeleteEnterprise(ctx context.Context, enterpriseID string) 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)
DeleteEnterprisePool(ctx context.Context, enterpriseID, poolID string) error
UpdateEnterprisePool(ctx context.Context, enterpriseID, poolID string, param params.UpdatePoolParams) (params.Pool, error)

FindEnterprisePoolByTags(ctx context.Context, enterpriseID string, tags []string) (params.Pool, error)
ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error)
ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error)
}

type PoolStore interface {
Expand Down Expand Up @@ -130,6 +102,16 @@ type JobsStore interface {
DeleteCompletedJobs(ctx context.Context) error
}

type EntityPools interface {
CreateEntityPool(ctx context.Context, entity params.GithubEntity, param params.CreatePoolParams) (params.Pool, error)
GetEntityPool(ctx context.Context, entity params.GithubEntity, poolID string) (params.Pool, error)
DeleteEntityPool(ctx context.Context, entity params.GithubEntity, poolID string) error
UpdateEntityPool(ctx context.Context, entity params.GithubEntity, poolID string, param params.UpdatePoolParams) (params.Pool, error)

ListEntityPools(ctx context.Context, entity params.GithubEntity) ([]params.Pool, error)
ListEntityInstances(ctx context.Context, entity params.GithubEntity) ([]params.Instance, error)
}

//go:generate mockery --name=Store
type Store interface {
RepoStore
Expand All @@ -139,6 +121,7 @@ type Store interface {
UserStore
InstanceStore
JobsStore
EntityPools

ControllerInfo() (params.ControllerInfo, error)
InitController() (params.ControllerInfo, error)
Expand Down
Loading

0 comments on commit 9cbb2f8

Please sign in to comment.