feat(daemon): park repository, credential and forge-extension failures with a recovery link on the task list
This commit is contained in:
1 parent
6f57d38669
commit
afdb4b203f
7 files changed
+38
-3
No files matched your search
@@ -2186,8 +2186,23 @@ func parkBlocker(err error) taskstate.Blocker {
|
||||
if b, ok := errors.AsType[blockedPark](err); ok {
|
||||
return b.blocker
|
||||
}
|
||||
if failure, ok := errors.AsType[*forge.AccessError](err); ok && failure.Code == "operation_denied" {
|
||||
if failure, ok := errors.AsType[*forge.AccessError](err); ok {
|
||||
return accessBlocker(failure.Code)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// accessBlocker maps a repository access failure code onto what fixes it.
|
||||
func accessBlocker(code string) taskstate.Blocker {
|
||||
switch code {
|
||||
case "operation_denied":
|
||||
return taskstate.BlockerConnectionPermit
|
||||
case "repository_not_configured", "connection_required", "connection_missing":
|
||||
return taskstate.BlockerRepository
|
||||
case "credential_unavailable", "account_unverified":
|
||||
return taskstate.BlockerConnectionCredential
|
||||
case "forge_unavailable":
|
||||
return taskstate.BlockerForgeExtension
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -288,6 +288,12 @@ const (
|
||||
// BlockerConnectionPermit: the run's identity may not use the
|
||||
// repository's connection for an operation the workflow needs.
|
||||
BlockerConnectionPermit Blocker = "connection_permit"
|
||||
// BlockerRepository: the repository has no policy or no connection.
|
||||
BlockerRepository Blocker = "repository"
|
||||
// BlockerConnectionCredential: the connection's credential is unusable.
|
||||
BlockerConnectionCredential Blocker = "connection_credential"
|
||||
// BlockerForgeExtension: no running forge extension serves the connection.
|
||||
BlockerForgeExtension Blocker = "forge_extension"
|
||||
)
|
||||
|
||||
// Blocker is the persisted park blocker string.
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s *Server) handleTasks(w http.ResponseWriter, r *http.Request) {
|
||||
views := make([]taskView, len(tasks))
|
||||
for i := range tasks {
|
||||
repoURL, issueURL, prURL := taskURLs(tasks[i], forge(tasks[i]))
|
||||
views[i] = taskView{Task: tasks[i], Actions: taskstate.Actions(tasks[i].Status), Approval: taskstate.ApprovalKind(tasks[i].Status, tasks[i].ReviewGate), RepoURL: repoURL, IssueURL: issueURL, PRURL: prURL}
|
||||
views[i] = taskView{Task: tasks[i], Actions: taskstate.Actions(tasks[i].Status), Approval: taskstate.ApprovalKind(tasks[i].Status, tasks[i].ReviewGate), RepoURL: repoURL, IssueURL: issueURL, PRURL: prURL, Recovery: s.taskRecovery(r, &tasks[i])}
|
||||
}
|
||||
writeJSON(w, views)
|
||||
}
|
||||
@@ -129,6 +129,9 @@ type taskView struct {
|
||||
RepoURL string `json:"repo_url,omitempty"`
|
||||
IssueURL string `json:"issue_url,omitempty"`
|
||||
PRURL string `json:"pr_url,omitempty"`
|
||||
// Recovery is the page that fixes what a parked task lacks, present only
|
||||
// when the viewer may make that fix.
|
||||
Recovery *taskRecoveryView `json:"recovery,omitempty"`
|
||||
}
|
||||
|
||||
// forgeCoordinates locate a repository on its forge: the base URL, and the
|
||||
|
||||
@@ -35,6 +35,12 @@ func blockerRoute(t *task.Task) (recoveryRoute, bool) {
|
||||
return recoveryRoute{label: "Assign agent", page: "/org/agents", method: http.MethodPut, api: "/api/orgs/" + url.PathEscape(t.OrgOrDefault()) + "/agents/_", instance: true}, true
|
||||
case taskstate.BlockerConnectionPermit:
|
||||
return recoveryRoute{label: "Edit connection permissions", page: "/org/connections", method: http.MethodPost, api: "/api/control-plane/resources/forge-connections/commands/replace"}, true
|
||||
case taskstate.BlockerRepository:
|
||||
return recoveryRoute{label: "Set up repository", page: "/org/repositories", method: http.MethodPost, api: "/api/control-plane/resources/repository-policies/commands/replace"}, true
|
||||
case taskstate.BlockerConnectionCredential:
|
||||
return recoveryRoute{label: "Fix connection credential", page: "/org/connections", method: http.MethodPost, api: "/api/control-plane/resources/forge-connections/commands/replace"}, true
|
||||
case taskstate.BlockerForgeExtension:
|
||||
return recoveryRoute{label: "Enable forge extension", page: "/settings/extensions", method: http.MethodPut, api: "/api/extensions/_/enabled", instance: true}, true
|
||||
case taskstate.BlockerPolicyDenied:
|
||||
return recoveryRoute{label: "Edit policies", page: "/org/policies", method: http.MethodPut, api: "/api/access/policies"}, true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user