Skip to content

Commit 4eb4137

Browse files
lucasmelinctrombley
authored andcommitted
Return error message when workspace is locked by a team or user
1 parent bd1cdb9 commit 4eb4137

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

errors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ var (
6363
// ErrWorkspaceLockedByRun is returned when trying to unlock a workspace locked by a run.
6464
ErrWorkspaceLockedByRun = errors.New("unable to unlock workspace locked by run")
6565

66+
// ErrWorkspaceLockedByTeam is returned when trying to unlock a workspace locked by a team.
67+
ErrWorkspaceLockedByTeam = errors.New("unable to unlock workspace locked by team")
68+
69+
// ErrWorkspaceLockedByUser is returned when trying to unlock a workspace locked by a user.
70+
ErrWorkspaceLockedByUser = errors.New("unable to unlock workspace locked by user")
71+
6672
// ErrWorkspaceStillProcessing is returned when a workspace is still processing state
6773
// to determine if it is safe to delete. "conflict" followed by newline is used to
6874
// preserve go-tfe version compatibility with the error constructed at runtime before it was

tfe.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,14 @@ func checkResponseCode(r *http.Response) error {
973973
return ErrWorkspaceLockedByRun
974974
}
975975

976+
if errorPayloadContains(errs, "is locked by Team") {
977+
return ErrWorkspaceLockedByTeam
978+
}
979+
980+
if errorPayloadContains(errs, "is locked by User") {
981+
return ErrWorkspaceLockedByUser
982+
}
983+
976984
return ErrWorkspaceNotLocked
977985
case strings.HasSuffix(r.Request.URL.Path, "actions/force-unlock"):
978986
return ErrWorkspaceNotLocked

0 commit comments

Comments
 (0)