| 193 | } |
| 194 | |
| 195 | func (b WorkspaceBuildBuilder) WithTask(taskSeed database.TaskTable, appSeed *sdkproto.App) WorkspaceBuildBuilder { |
| 196 | //nolint:revive // returns modified struct |
| 197 | b.taskSeed = taskSeed |
| 198 | |
| 199 | if appSeed == nil { |
| 200 | appSeed = &sdkproto.App{} |
| 201 | } |
| 202 | |
| 203 | var err error |
| 204 | //nolint: revive // returns modified struct |
| 205 | b.taskAppID, err = uuid.Parse(takeFirst(appSeed.Id, uuid.NewString())) |
| 206 | require.NoError(b.t, err) |
| 207 | |
| 208 | return b.WithAgent(func(a []*sdkproto.Agent) []*sdkproto.Agent { |
| 209 | a[0].Apps = []*sdkproto.App{ |
| 210 | { |
| 211 | Id: b.taskAppID.String(), |
| 212 | Slug: takeFirst(appSeed.Slug, "task-app"), |
| 213 | Url: takeFirst(appSeed.Url, ""), |
| 214 | }, |
| 215 | } |
| 216 | return a |
| 217 | }) |
| 218 | } |
| 219 | |
| 220 | // Starting sets the job to running status. |
| 221 | func (b WorkspaceBuildBuilder) Starting(opts ...BuilderOption) WorkspaceBuildBuilder { |