(ctx context.Context, opt client.DeleteOptions)
| 228 | } |
| 229 | |
| 230 | func (s *proxyClient) Delete(ctx context.Context, opt client.DeleteOptions) error { |
| 231 | s.m.Lock() |
| 232 | defer s.m.Unlock() |
| 233 | |
| 234 | reader, writer := io.Pipe() |
| 235 | defer writer.Close() |
| 236 | go func() { |
| 237 | readLogStream(reader, s.log) |
| 238 | }() |
| 239 | |
| 240 | var gracePeriod *time.Duration |
| 241 | if opt.GracePeriod != "" { |
| 242 | duration, err := time.ParseDuration(opt.GracePeriod) |
| 243 | if err == nil { |
| 244 | gracePeriod = &duration |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // kill the command after the grace period |
| 249 | if gracePeriod != nil { |
| 250 | var cancel context.CancelFunc |
| 251 | ctx, cancel = context.WithTimeout(ctx, *gracePeriod) |
| 252 | defer cancel() |
| 253 | } |
| 254 | |
| 255 | err := RunCommandWithBinaries( |
| 256 | ctx, |
| 257 | "delete", |
| 258 | s.config.Exec.Proxy.Delete, |
| 259 | s.workspace.Context, |
| 260 | s.workspace, |
| 261 | nil, |
| 262 | s.devPodConfig.ProviderOptions(s.config.Name), |
| 263 | s.config, |
| 264 | EncodeOptions(opt, DevPodFlagsDelete), |
| 265 | nil, |
| 266 | writer, |
| 267 | writer, |
| 268 | s.log, |
| 269 | ) |
| 270 | if err != nil { |
| 271 | if !opt.Force { |
| 272 | return fmt.Errorf("error deleting workspace: %w", err) |
| 273 | } |
| 274 | |
| 275 | s.log.Errorf("Error deleting workspace: %v", err) |
| 276 | } |
| 277 | |
| 278 | return DeleteWorkspaceFolder(s.workspace.Context, s.workspace.ID, s.workspace.SSHConfigPath, s.log) |
| 279 | } |
| 280 | |
| 281 | func (s *proxyClient) Stop(ctx context.Context, opt client.StopOptions) error { |
| 282 | s.m.Lock() |
nothing calls this directly
no test coverage detected