@@ -66,6 +66,8 @@ type WorkspaceOperations interface {
66
66
BackupWorkspace (ctx context.Context , opts BackupOptions ) (* csapi.GitStatus , error )
67
67
// DeleteWorkspace deletes the content of the workspace from disk
68
68
DeleteWorkspace (ctx context.Context , instanceID string ) error
69
+ // WipeWorkspace deletes all references to the workspace. Does not fail if parts are already gone, or state is incosistent.
70
+ WipeWorkspace (ctx context.Context , instanceID string ) error
69
71
// SnapshotIDs generates the name and url for a snapshot
70
72
SnapshotIDs (ctx context.Context , instanceID string ) (snapshotUrl , snapshotName string , err error )
71
73
// Snapshot takes a snapshot of the workspace
@@ -285,6 +287,36 @@ func (wso *DefaultWorkspaceOperations) DeleteWorkspace(ctx context.Context, inst
285
287
return nil
286
288
}
287
289
290
+ func (wso * DefaultWorkspaceOperations ) WipeWorkspace (ctx context.Context , instanceID string ) error {
291
+ ws , err := wso .provider .GetAndConnect (ctx , instanceID )
292
+ if err != nil {
293
+ // we have to assume everything is fine, and this workspace has already been completely wiped
294
+ return nil
295
+ }
296
+
297
+ if err = ws .Dispose (ctx , wso .provider .hooks [session .WorkspaceDisposed ]); err != nil {
298
+ glog .WithError (err ).WithFields (ws .OWI ()).Error ("cannot dispose session" )
299
+ return err
300
+ }
301
+
302
+ // remove workspace daemon directory in the node
303
+ if err := os .RemoveAll (ws .ServiceLocDaemon ); err != nil {
304
+ glog .WithError (err ).WithFields (ws .OWI ()).Error ("cannot delete workspace daemon directory" )
305
+ return err
306
+ }
307
+
308
+ // remove workspace daemon node directory in the node
309
+ // TODO(gpl): Is this used at all? Can't find any reference
310
+ if err := os .RemoveAll (ws .ServiceLocNode ); err != nil {
311
+ glog .WithError (err ).WithFields (ws .OWI ()).Error ("cannot delete workspace daemon node directory" )
312
+ return err
313
+ }
314
+
315
+ wso .provider .Remove (ctx , instanceID )
316
+
317
+ return nil
318
+ }
319
+
288
320
func (wso * DefaultWorkspaceOperations ) SnapshotIDs (ctx context.Context , instanceID string ) (snapshotUrl , snapshotName string , err error ) {
289
321
sess , err := wso .provider .GetAndConnect (ctx , instanceID )
290
322
if err != nil {
0 commit comments