Simplify manual cleaning to directory targets
This commit is contained in:
@@ -93,16 +93,16 @@ func cleanSelectedSession(ctx context.Context, input *cleanCommandInput, deps co
|
||||
}
|
||||
defer func() { err = errors.Join(err, store.ReleaseWorkspaceLock(lock)) }()
|
||||
}
|
||||
appendTarget := func(root, target, policy string, directory bool) error {
|
||||
appendTarget := func(root, target, policy string) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
action, err := cleanScopedTarget(root, target, policy, directory, input.DryRun)
|
||||
action, err := cleanScopedTarget(root, target, policy, input.DryRun)
|
||||
report.Actions = append(report.Actions, action)
|
||||
return err
|
||||
}
|
||||
if input.All {
|
||||
if err := appendTarget(pipeline.Workspace.Root, filepath.Join(pipeline.Workspace.Root, config.PathWorkDirSegment), "clean.workspace.all", true); err != nil {
|
||||
if err := appendTarget(pipeline.Workspace.Root, filepath.Join(pipeline.Workspace.Root, config.PathWorkDirSegment), "clean.workspace.all"); err != nil {
|
||||
return report, err
|
||||
}
|
||||
return report, nil
|
||||
@@ -114,15 +114,15 @@ func cleanSelectedSession(ctx context.Context, input *cleanCommandInput, deps co
|
||||
report.Campaign = cfg.Session.Campaign
|
||||
report.SessionID = cfg.Session.SessionID
|
||||
work := artifacts.SessionWorkDirForCampaign(pipeline.Workspace.Root, report.Campaign, report.SessionID)
|
||||
if err := appendTarget(pipeline.Workspace.Root, work, "clean.workspace.session", true); err != nil {
|
||||
if err := appendTarget(pipeline.Workspace.Root, work, "clean.workspace.session"); err != nil {
|
||||
return report, err
|
||||
}
|
||||
return report, nil
|
||||
}
|
||||
|
||||
func cleanScopedTarget(root, target, policy string, directory, dryRun bool) (cleanAction, error) {
|
||||
func cleanScopedTarget(root, target, policy string, dryRun bool) (cleanAction, error) {
|
||||
action := cleanAction{Path: target, Status: "failed"}
|
||||
scoped, err := validateScopedTarget(root, target, policy, directory)
|
||||
scoped, err := validateScopedDir(root, target, policy)
|
||||
if err != nil {
|
||||
action.Error = err.Error()
|
||||
return action, err
|
||||
|
||||
Reference in New Issue
Block a user