Skip to content

Commit 6cfac9f

Browse files
chore: more linting err fix
1 parent 24ed128 commit 6cfac9f

File tree

11 files changed

+58
-32
lines changed

11 files changed

+58
-32
lines changed

apps/workspace-engine/pkg/events/handler/resources/resourceproviders.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func HandleResourceProviderDeleted(
4848
return err
4949
}
5050

51-
ws.ResourceProviders().Remove(ctx, resourceProvider.Id)
51+
if err := ws.ResourceProviders().Remove(ctx, resourceProvider.Id); err != nil {
52+
return err
53+
}
5254

5355
return nil
5456
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ func (m *Manager) executeDeployment(ctx context.Context, releaseToDeploy *oapi.R
132132
defer span.End()
133133

134134
// Step 1: Persist the release (WRITE)
135-
m.store.Releases.Upsert(ctx, releaseToDeploy)
135+
if err := m.store.Releases.Upsert(ctx, releaseToDeploy); err != nil {
136+
span.RecordError(err)
137+
return err
138+
}
136139

137140
// Step 2: Cancel outdated jobs for this release target (WRITES)
138141
// Cancel any pending/in-progress jobs for different releases (outdated versions)
@@ -152,7 +155,11 @@ func (m *Manager) executeDeployment(ctx context.Context, releaseToDeploy *oapi.R
152155
)
153156

154157
// Step 4: Dispatch job to integration (ASYNC)
155-
go m.IntegrationDispatch(ctx, newJob)
158+
go func() {
159+
if err := m.IntegrationDispatch(ctx, newJob); err != nil {
160+
log.Error("error dispatching job to integration", "error", err.Error())
161+
}
162+
}()
156163

157164
return nil
158165
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (e *Deployments) HasResource(deploymentId string, resourceId string) bool {
119119
return false
120120
}
121121

122-
mv.WaitRecompute()
122+
_ = mv.WaitRecompute()
123123
allResources := mv.Get()
124124
if deploymentResources, ok := allResources[resourceId]; ok {
125125
return deploymentResources != nil
@@ -133,7 +133,7 @@ func (e *Deployments) Resources(deploymentId string) map[string]*oapi.Resource {
133133
return map[string]*oapi.Resource{}
134134
}
135135

136-
mv.WaitRecompute()
136+
_ = mv.WaitRecompute()
137137
allResources := mv.Get()
138138
return allResources
139139
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (e *Environments) HasResource(envId string, resourceId string) bool {
8181
return false
8282
}
8383

84-
mv.WaitRecompute()
84+
_ = mv.WaitRecompute()
8585
allResources := mv.Get()
8686
if envResources, ok := allResources[resourceId]; ok {
8787
return envResources != nil
@@ -95,7 +95,7 @@ func (e *Environments) Resources(id string) map[string]*oapi.Resource {
9595
return map[string]*oapi.Resource{}
9696
}
9797

98-
mv.WaitRecompute()
98+
_ = mv.WaitRecompute()
9999
allResources := mv.Get()
100100
return allResources
101101
}
@@ -107,7 +107,8 @@ func (e *Environments) RecomputeResources(ctx context.Context, environmentId str
107107
}
108108

109109
// RunRecompute will start a new computation or wait for an existing one
110-
return mv.RunRecompute(ctx)
110+
_ = mv.RunRecompute(ctx)
111+
return nil
111112
}
112113

113114
func (e *Environments) Upsert(ctx context.Context, environment *oapi.Environment) error {
@@ -143,7 +144,7 @@ func (e *Environments) ApplyResourceUpdate(ctx context.Context, environmentId st
143144
return fmt.Errorf("environment %s not found", environmentId)
144145
}
145146

146-
mv.StartRecompute(ctx)
147+
_ = mv.StartRecompute(ctx)
147148

148149
return nil
149150
}

apps/workspace-engine/pkg/workspace/store/materialized/view.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func New[V any](rf RecomputeFunc[V], opts ...Option[V]) *MaterializedView[V] {
4242
opt(mv)
4343
}
4444

45-
mv.StartRecompute(context.Background())
45+
_ = mv.StartRecompute(context.Background())
4646

4747
return mv
4848
}
4949

5050
// Get returns the current cached value.
5151
func (m *MaterializedView[V]) Get() V {
52-
m.WaitIfRunning()
52+
_ = m.WaitIfRunning()
5353
m.mu.RLock()
5454
defer m.mu.RUnlock()
5555
return m.val

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ type ReleaseTargets struct {
2626

2727
// CurrentState returns the current state of all release targets in the system.
2828
func (r *ReleaseTargets) Items(ctx context.Context) map[string]*oapi.ReleaseTarget {
29-
r.targets.WaitIfRunning()
29+
_ = r.targets.WaitIfRunning()
3030
return r.targets.Get()
3131
}
3232

3333
func (r *ReleaseTargets) Recompute(ctx context.Context) {
34-
r.targets.StartRecompute(ctx)
34+
_ = r.targets.StartRecompute(ctx)
3535
}
3636

3737
func (r *ReleaseTargets) computeTargets(ctx context.Context) (map[string]*oapi.ReleaseTarget, error) {

apps/workspace-engine/pkg/workspace/store/repository/repo.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ func WriteToJSONFile(r *Repository, filePath string) error {
3232
if err != nil {
3333
return err
3434
}
35-
defer f.Close()
35+
defer func() {
36+
if closeErr := f.Close(); closeErr != nil && err == nil {
37+
err = closeErr
38+
}
39+
}()
3640

3741
// Write JSON data to file.
3842
_, err = f.Write(data)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ func (r *ResourceProviders) Upsert(ctx context.Context, id string, resourceProvi
3434
}
3535
}
3636

37-
func (r *ResourceProviders) Remove(ctx context.Context, id string) {
37+
func (r *ResourceProviders) Remove(ctx context.Context, id string) error {
3838
r.repo.ResourceProviders.Remove(id)
3939
for _, resource := range r.resources.Items() {
4040
if resource.ProviderId != nil && *resource.ProviderId == id {
4141
resource.ProviderId = nil
42-
r.resources.Upsert(ctx, resource)
42+
if _, err := r.resources.Upsert(ctx, resource); err != nil {
43+
return err
44+
}
4345
}
4446
}
4547
if cs, ok := changeset.FromContext(ctx); ok {
4648
cs.Record("resource-provider", changeset.ChangeTypeDelete, id, nil)
4749
}
50+
return nil
4851
}

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"workspace-engine/pkg/changeset"
77
"workspace-engine/pkg/oapi"
88
"workspace-engine/pkg/workspace/store/repository"
9+
10+
"github.com/charmbracelet/log"
911
)
1012

1113
func NewResources(store *Store) *Resources {
@@ -29,14 +31,18 @@ func (r *Resources) Upsert(ctx context.Context, resource *oapi.Resource) (*oapi.
2931
defer wg.Done()
3032
for item := range r.store.Environments.IterBuffered() {
3133
environment := item.Val
32-
r.store.Environments.RecomputeResources(ctx, environment.Id)
34+
if err := r.store.Environments.RecomputeResources(ctx, environment.Id); err != nil {
35+
log.Error("Failed to recompute resources for environment", "environmentId", environment.Id, "error", err)
36+
}
3337
}
3438
}()
3539
go func() {
3640
defer wg.Done()
3741
for item := range r.store.Deployments.IterBuffered() {
3842
deployment := item.Val
39-
r.store.Deployments.RecomputeResources(ctx, deployment.Id)
43+
if err := r.store.Deployments.RecomputeResources(ctx, deployment.Id); err != nil {
44+
log.Error("Failed to recompute resources for deployment", "deploymentId", deployment.Id, "error", err)
45+
}
4046
}
4147
}()
4248
wg.Wait()
@@ -63,14 +69,18 @@ func (r *Resources) Remove(ctx context.Context, id string) {
6369
defer wg.Done()
6470
for item := range r.store.Environments.IterBuffered() {
6571
environment := item.Val
66-
r.store.Environments.RecomputeResources(ctx, environment.Id)
72+
if err := r.store.Environments.RecomputeResources(ctx, environment.Id); err != nil {
73+
log.Error("Failed to recompute resources for environment", "environmentId", environment.Id, "error", err)
74+
}
6775
}
6876
}()
6977
go func() {
7078
defer wg.Done()
7179
for item := range r.store.Deployments.IterBuffered() {
7280
deployment := item.Val
73-
r.store.Deployments.RecomputeResources(ctx, deployment.Id)
81+
if err := r.store.Deployments.RecomputeResources(ctx, deployment.Id); err != nil {
82+
log.Error("Failed to recompute resources for deployment", "deploymentId", deployment.Id, "error", err)
83+
}
7484
}
7585
}()
7686
wg.Wait()

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *Systems) Deployments(systemId string) map[string]*oapi.Deployment {
6767
if !ok {
6868
return map[string]*oapi.Deployment{}
6969
}
70-
mv.WaitIfRunning()
70+
_ = mv.WaitIfRunning()
7171
return mv.Get()
7272
}
7373

@@ -89,7 +89,7 @@ func (s *Systems) Environments(systemId string) map[string]*oapi.Environment {
8989
if !ok {
9090
return map[string]*oapi.Environment{}
9191
}
92-
mv.WaitIfRunning()
92+
_ = mv.WaitIfRunning()
9393
return mv.Get()
9494
}
9595

@@ -117,20 +117,19 @@ func (s *Systems) ApplyDeploymentUpdate(
117117
ctx context.Context,
118118
previousSystemId string,
119119
deployment *oapi.Deployment,
120-
) error {
120+
) {
121121
// Recompute deployments for the previous system, if it exists
122122
if oldDeployments, exists := s.deployments.Get(previousSystemId); exists {
123-
oldDeployments.StartRecompute(ctx)
123+
_ = oldDeployments.StartRecompute(ctx)
124124
}
125125

126126
deploymentHasMoved := previousSystemId != deployment.SystemId
127127
if deploymentHasMoved {
128128
if newDeployments, exists := s.deployments.Get(deployment.SystemId); exists {
129-
newDeployments.StartRecompute(ctx)
129+
_ = newDeployments.StartRecompute(ctx)
130130
}
131131
}
132132

133-
return nil
134133
}
135134

136135
// ApplyEnvironmentUpdate triggers a recompute of environments for the affected systems
@@ -139,20 +138,18 @@ func (s *Systems) ApplyEnvironmentUpdate(
139138
ctx context.Context,
140139
previousSystemId string,
141140
environment *oapi.Environment,
142-
) error {
141+
) {
143142
// Recompute deployments for the previous system, if it exists
144143
if oldEnvironments, exists := s.environments.Get(previousSystemId); exists {
145-
oldEnvironments.StartRecompute(ctx)
144+
_ = oldEnvironments.StartRecompute(ctx)
146145
}
147146

148147
environmentHasMoved := previousSystemId != environment.SystemId
149148
if environmentHasMoved {
150149
if newEnvironments, exists := s.environments.Get(environment.SystemId); exists {
151-
newEnvironments.StartRecompute(ctx)
150+
_ = newEnvironments.StartRecompute(ctx)
152151
}
153152
}
154-
155-
return nil
156153
}
157154

158155
func (s *Systems) Items() map[string]*oapi.System {

0 commit comments

Comments
 (0)