@@ -13,6 +13,7 @@ import (
13
13
"github.com/gofrs/flock"
14
14
15
15
rt "github.com/stacklok/toolhive/pkg/container/runtime"
16
+ "github.com/stacklok/toolhive/pkg/core"
16
17
"github.com/stacklok/toolhive/pkg/logger"
17
18
)
18
19
@@ -89,8 +90,8 @@ func (f *fileStatusManager) CreateWorkloadStatus(ctx context.Context, workloadNa
89
90
}
90
91
91
92
// GetWorkload retrieves the status of a workload by its name.
92
- func (f * fileStatusManager ) GetWorkload (ctx context.Context , workloadName string ) (Workload , error ) {
93
- result := Workload {Name : workloadName }
93
+ func (f * fileStatusManager ) GetWorkload (ctx context.Context , workloadName string ) (core. Workload , error ) {
94
+ result := core. Workload {Name : workloadName }
94
95
fileFound := false
95
96
96
97
err := f .withFileReadLock (ctx , workloadName , func (statusFilePath string ) error {
@@ -114,15 +115,15 @@ func (f *fileStatusManager) GetWorkload(ctx context.Context, workloadName string
114
115
return nil
115
116
})
116
117
if err != nil {
117
- return Workload {}, err
118
+ return core. Workload {}, err
118
119
}
119
120
120
121
// If file was found and workload is running, get additional info from runtime
121
122
if fileFound && result .Status == rt .WorkloadStatusRunning {
122
123
// TODO: Find discrepancies between the file and runtime workload.
123
124
runtimeResult , err := f .getWorkloadFromRuntime (ctx , workloadName )
124
125
if err != nil {
125
- return Workload {}, err
126
+ return core. Workload {}, err
126
127
}
127
128
// Use runtime data but preserve file-based status info
128
129
fileStatus := result .Status
@@ -144,7 +145,7 @@ func (f *fileStatusManager) GetWorkload(ctx context.Context, workloadName string
144
145
return f .getWorkloadFromRuntime (ctx , workloadName )
145
146
}
146
147
147
- func (f * fileStatusManager ) ListWorkloads (ctx context.Context , listAll bool , labelFilters []string ) ([]Workload , error ) {
148
+ func (f * fileStatusManager ) ListWorkloads (ctx context.Context , listAll bool , labelFilters []string ) ([]core. Workload , error ) {
148
149
// Parse the filters into a format we can use for matching.
149
150
parsedFilters , err := parseLabelFilters (labelFilters )
150
151
if err != nil {
@@ -170,7 +171,7 @@ func (f *fileStatusManager) ListWorkloads(ctx context.Context, listAll bool, lab
170
171
}
171
172
172
173
// Create result map to avoid duplicates and merge data
173
- workloadMap := make (map [string ]Workload )
174
+ workloadMap := make (map [string ]core. Workload )
174
175
175
176
// First, add all runtime workloads
176
177
for _ , container := range runtimeContainers {
@@ -198,7 +199,7 @@ func (f *fileStatusManager) ListWorkloads(ctx context.Context, listAll bool, lab
198
199
}
199
200
200
201
// Convert map to slice and apply filters
201
- var workloads []Workload
202
+ var workloads []core. Workload
202
203
for _ , workload := range workloadMap {
203
204
// Apply listAll filter
204
205
if ! listAll && workload .Status != rt .WorkloadStatusRunning {
@@ -386,17 +387,17 @@ func (*fileStatusManager) writeStatusFile(statusFilePath string, statusFile work
386
387
}
387
388
388
389
// getWorkloadFromRuntime retrieves workload information from the runtime.
389
- func (f * fileStatusManager ) getWorkloadFromRuntime (ctx context.Context , workloadName string ) (Workload , error ) {
390
+ func (f * fileStatusManager ) getWorkloadFromRuntime (ctx context.Context , workloadName string ) (core. Workload , error ) {
390
391
info , err := f .runtime .GetWorkloadInfo (ctx , workloadName )
391
392
if err != nil {
392
- return Workload {}, fmt .Errorf ("failed to get workload info from runtime: %w" , err )
393
+ return core. Workload {}, fmt .Errorf ("failed to get workload info from runtime: %w" , err )
393
394
}
394
395
395
396
return WorkloadFromContainerInfo (& info )
396
397
}
397
398
398
399
// getWorkloadsFromFiles retrieves all workloads from status files.
399
- func (f * fileStatusManager ) getWorkloadsFromFiles () (map [string ]Workload , error ) {
400
+ func (f * fileStatusManager ) getWorkloadsFromFiles () (map [string ]core. Workload , error ) {
400
401
// Ensure base directory exists
401
402
if err := f .ensureBaseDir (); err != nil {
402
403
return nil , fmt .Errorf ("failed to ensure base directory: %w" , err )
@@ -408,7 +409,7 @@ func (f *fileStatusManager) getWorkloadsFromFiles() (map[string]Workload, error)
408
409
return nil , fmt .Errorf ("failed to list status files: %w" , err )
409
410
}
410
411
411
- workloads := make (map [string ]Workload )
412
+ workloads := make (map [string ]core. Workload )
412
413
for _ , file := range files {
413
414
// Extract workload name from filename (remove .json extension)
414
415
workloadName := strings .TrimSuffix (filepath .Base (file ), ".json" )
@@ -421,7 +422,7 @@ func (f *fileStatusManager) getWorkloadsFromFiles() (map[string]Workload, error)
421
422
}
422
423
423
424
// Create workload from file data
424
- workload := Workload {
425
+ workload := core. Workload {
425
426
Name : workloadName ,
426
427
Status : statusFile .Status ,
427
428
StatusContext : statusFile .StatusContext ,
0 commit comments