Status returns the status of a setup task.
(ctx context.Context, key string, task Task)
| 95 | |
| 96 | // Status returns the status of a setup task. |
| 97 | func Status(ctx context.Context, key string, task Task) TaskStatus { |
| 98 | defer debug.FunctionTimer().End() |
| 99 | state := loadState(key) |
| 100 | switch { |
| 101 | case isSudo(key): |
| 102 | return TaskSudoing |
| 103 | case state.ConfirmPrompt.Asked && !state.ConfirmPrompt.Allowed: |
| 104 | return TaskUserRefused |
| 105 | case task.NeedsRun(ctx, state.LastRun): |
| 106 | return TaskNeedsRun |
| 107 | case state.LastRun.Error == "": |
| 108 | return TaskDone |
| 109 | case state.LastRun.Error != "": |
| 110 | return TaskError |
| 111 | } |
| 112 | panic("setup.Status switch isn't exhaustive") |
| 113 | } |
| 114 | |
| 115 | // Run runs a setup task and stores its state under a given key. Keys are |
| 116 | // namespaced by user. It only calls the task's Run method when NeedsRun returns |
no test coverage detected