MCPcopy
hub / github.com/loft-sh/devpod / Delete

Method Delete

pkg/client/clientimplementation/proxy_client.go:230–279  ·  view source on GitHub ↗
(ctx context.Context, opt client.DeleteOptions)

Source from the content-addressed store, hash-verified

228}
229
230func (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
281func (s *proxyClient) Stop(ctx context.Context, opt client.StopOptions) error {
282 s.m.Lock()

Callers

nothing calls this directly

Calls 9

readLogStreamFunction · 0.85
RunCommandWithBinariesFunction · 0.85
EncodeOptionsFunction · 0.85
DeleteWorkspaceFolderFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
CloseMethod · 0.45
ProviderOptionsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected