Skip to content

Commit 8929186

Browse files
chore: cleanup and populate approval records
1 parent 286cd28 commit 8929186

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

apps/workspace-engine/pkg/workspace/populate_workspace.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ func PopulateWorkspaceWithInitialState(ctx context.Context, ws *Workspace) error
5656
}
5757
}
5858
for _, githubEntity := range initialWorkspaceState.GithubEntities() {
59-
if err := ws.GithubEntities().Upsert(ctx, githubEntity); err != nil {
60-
return err
61-
}
59+
ws.GithubEntities().Upsert(ctx, githubEntity)
60+
}
61+
for _, userApprovalRecord := range initialWorkspaceState.UserApprovalRecords() {
62+
ws.UserApprovalRecords().Upsert(ctx, userApprovalRecord)
6263
}
6364

6465
return nil

apps/workspace-engine/pkg/workspace/store/github_entities.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ func (g *GithubEntities) key(slug string, installationId int) string {
2222
return fmt.Sprintf("%s-%d", slug, installationId)
2323
}
2424

25-
func (g *GithubEntities) Upsert(ctx context.Context, githubEntity *oapi.GithubEntity) error {
25+
func (g *GithubEntities) Upsert(ctx context.Context, githubEntity *oapi.GithubEntity) {
2626
key := g.key(githubEntity.Slug, githubEntity.InstallationId)
2727
g.repo.GithubEntities.Set(key, githubEntity)
2828
if cs, ok := changeset.FromContext[any](ctx); ok {
2929
cs.Record(changeset.ChangeTypeUpsert, githubEntity)
3030
}
31-
return nil
3231
}
3332

3433
func (g *GithubEntities) Get(slug string, installationId int) (*oapi.GithubEntity, bool) {

apps/workspace-engine/pkg/workspace/workspace.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ func (w *Workspace) GithubEntities() *store.GithubEntities {
9898
return w.store.GithubEntities
9999
}
100100

101+
func (w *Workspace) UserApprovalRecords() *store.UserApprovalRecords {
102+
return w.store.UserApprovalRecords
103+
}
104+
101105
func (w *Workspace) GobEncode() ([]byte, error) {
102106
return w.store.GobEncode()
103107
}
@@ -119,10 +123,6 @@ func (w *Workspace) GobDecode(data []byte) error {
119123
return nil
120124
}
121125

122-
func (w *Workspace) UserApprovalRecords() *store.UserApprovalRecords {
123-
return w.store.UserApprovalRecords
124-
}
125-
126126
func (w *Workspace) RelationshipRules() *store.RelationshipRules {
127127
return w.store.Relationships
128128
}

0 commit comments

Comments
 (0)