| 1 | package web |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | |
| 6 | "amadan.net/oficina/alta/provision" |
| 7 | ) |
| 8 | |
| 9 | // Every state the engine records is a fixed code; this is the one place |
| 10 | // they become words. An unknown code is shown as itself, which is honest |
| 11 | // and greppable. |
| 12 | var words = map[string]string{ |
| 13 | "audit-ok": "Every environment holds exactly its recipe", |
| 14 | "instance-waking": "The instance is starting", |
| 15 | "awaiting-confirm": "Waiting for you to confirm on Home", |
| 16 | "awaiting-confirm-directory": "Waiting for you to confirm on oficina.works", |
| 17 | "awaiting-confirm-credential": "Waiting for you to confirm on id.oficina.works", |
| 18 | "window-expired": "The confirmed window closed. Continue under a new plan.", |
| 19 | "window-closed": "No window is open. Continue under a new plan.", |
| 20 | "plan-expired": "The plan expired before it was confirmed. Submit a new one.", |
| 21 | "home-busy": "Home already has a plan pending or a window open on that role", |
| 22 | "home-unavailable": "Home did not answer. Alta will try again.", |
| 23 | "home-not-initialized": "Home's directory is not initialized yet", |
| 24 | "receipt-stale": "The owner receipt aged out; a new one is taken next", |
| 25 | "owner-needed": "Retype the owner's address to continue", |
| 26 | "owner-retype-needed": "Retype the owner's address: Alta no longer holds it", |
| 27 | "owner-refused": "Home refused the owner. Have they signed in at oficina.works?", |
| 28 | "seed-refused": "Home refused the team: the label may be taken at Home", |
| 29 | "provision-refused": "Home refused the directory consumer", |
| 30 | "register-refused": "Home refused the credential consumer", |
| 31 | "record-unverified": "Home's provisioning record did not verify", |
| 32 | "awaiting-platform-keys": "Waiting for the platform to deliver mail (and relay) credentials", |
| 33 | "environment-absent": "The environment is not there yet", |
| 34 | "extra-key": "The environment holds a key the recipe does not name", |
| 35 | "host-held": "The host is held outside Alta's scope", |
| 36 | "instance-bound-elsewhere": "The instance is bound to another environment", |
| 37 | "domain-checking": "Hostname attached; the platform is checking it", |
| 38 | "domain-pending-dns": "Hostname waits for DNS", |
| 39 | "domain-issuing-cert": "Issuing the certificate", |
| 40 | "domain-unverified": "The hostname needs its ownership proved", |
| 41 | "domain-misdirected": "DNS points somewhere else", |
| 42 | "domain-failed": "The certificate is failing", |
| 43 | "domain-route": "The hostname points at another route", |
| 44 | "restarting": "Restarting after a config change", |
| 45 | "version-unreachable": "/api/version does not answer yet", |
| 46 | "version-unstamped": "The build reports no version", |
| 47 | "awaiting-box-report": "Waiting for the box to report what it serves", |
| 48 | "serving-disagrees": "The box and /api/version disagree", |
| 49 | "version-unacceptable": "/api/version answers something Home would not take as a version", |
| 50 | "no-readiness-probe": "The app has no /api/team yet (Docs: it lands with the next Docs deploy)", |
| 51 | "not-team-mode": "The app is not in team mode", |
| 52 | "awaiting-roster": "Waiting for the app's roster", |
| 53 | "attempt-expired": "The verification attempt lapsed; verifying again", |
| 54 | "console-unavailable": "The console did not answer. Alta will try again.", |
| 55 | "console-write": "The console refused a write", |
| 56 | "transient": "Something went wrong. Alta will try again.", |
| 57 | "guard": "Alta's own guard refused a request", |
| 58 | "label-used": "That label has been used before. Labels are never reused.", |
| 59 | "label-reserved": "That label is reserved: it names one of the suite's apps or its own services.", |
| 60 | "label-shape": "A label is 3–32 lower-case letters, digits and hyphens, starting with a letter and ending with a letter or digit", |
| 61 | "label-double-hyphen": "A label never has two hyphens together (that is how punycode names begin)", |
| 62 | "profile-unknown": "Choose a profile: own or outside", |
| 63 | "operator-keys-invalid": "A post-run pair is not as the app reads it: for Memoria, MEMORIA_AI is the variable on and MEMORIA_TENSORX_KEY a secret; for Equipo, EQUIPO_EXECUTION_ENABLED is 1 and EQUIPO_EXECUTION_MARKER_PATH is exactly /data/instances/<label>-equipo.<account>.oncarlos.com/execution/witness", |
| 64 | "audit-operator-partial": "A post-run pair is half set: MEMORIA_AI and MEMORIA_TENSORX_KEY go together, and so do EQUIPO_EXECUTION_ENABLED and EQUIPO_EXECUTION_MARKER_PATH", |
| 65 | "app-own-only": "Equipo and Base are for your own teams only: choose the own profile, or leave them out", |
| 66 | "label-too-long-for-base": "Base needs a label of 19 characters or fewer", |
| 67 | "base-needs-team-apps": "Base comes last: the team needs every other app, Equipo included, before Base is added", |
| 68 | "owner-retype-refused": "No app on this team needs the owner's address again, so Alta takes no retyped one", |
| 69 | "owner-forgotten-seeded": "Alta no longer holds this team's owner, and Equipo and Base write it: create them with the team instead", |
| 70 | "probe-mode-mismatch": "The app's /api/team answers in a mode this recipe was not written for", |
| 71 | "name-shape": "Give the team a name", |
| 72 | "owner-shape": "That is not a plain email address", |
| 73 | "no-apps": "Choose at least one app", |
| 74 | "environment-shape": "That label is too long for a forked environment name", |
| 75 | "label-mismatch": "Type the team's label exactly to confirm", |
| 76 | "app-retired": "That app was retired from this team and is never re-added", |
| 77 | "attestation-mismatch": "Type the sentence exactly to confirm", |
| 78 | "already-initialized": "Home's directory is already initialized", |
| 79 | "initialized-elsewhere": "Home's directory was initialized by something other than Alta", |
| 80 | "plan-refused-credential": "Home refused the plan. Has the owner signed in at oficina.works? Correct the address on the team page; the directory keeps the refused plan pending for up to 15 minutes, so a new plan waits for that.", |
| 81 | "plan-refused-directory": "Home's directory refused the plan", |
| 82 | "stream-diverged": "Home's operator stream moved without Alta", |
| 83 | "use-add-apps": "The team exists: continue with a new plan instead", |
| 84 | "audit-extra-key": "The environment holds a key the recipe does not name", |
| 85 | "audit-missing-key": "The environment is missing a recipe key", |
| 86 | "audit-value": "A value differs from the recipe", |
| 87 | "audit-store-partial": "The object store's keys are incomplete: CARLOS delivers the whole set at once", |
| 88 | "audit-kind": "A key has the wrong kind", |
| 89 | "audit-allowlist-empty": "The allowlist is empty", |
| 90 | "team-not-seeded": "The team was never created at Home", |
| 91 | "no-team": "No such team", |
| 92 | "app-not-active": "That app is not active in this team", |
| 93 | "run-finished": "That run has finished", |
| 94 | "bearer-unrecoverable": "Home's roster bearer could not be recovered", |
| 95 | "no-secrets-pubkey": "The console gave no key to seal secrets to", |
| 96 | } |
| 97 | |
| 98 | var prefixes = map[string]string{ |
| 99 | "mail-prefix-": "Mail is declared under a prefix this app does not read: ", |
| 100 | "no-credential-": "No team credential for ", |
| 101 | "environment-exists-": "An environment of that name already exists for ", |
| 102 | "fork-missing-": "No forked environment for ", |
| 103 | "instance-bound-elsewhere-": "The instance is bound to another environment: ", |
| 104 | "console-": "The console did not answer for ", |
| 105 | "home-": "Home: ", |
| 106 | "domain-slow-": "Over 30 minutes and still ", |
| 107 | "roster-": "The app's roster says ", |
| 108 | "plan-": "Plan: ", |
| 109 | "profile-differs-": "That app's environment was written under another profile or samples choice, which a run never rewrites: ", |
| 110 | } |
| 111 | |
| 112 | // knownCode admits only codes Alta itself produces, so a code typed into |
| 113 | // a URL is never shown as if Alta had said it. |
| 114 | func knownCode(code string) bool { |
| 115 | if _, ok := words[code]; ok { |
| 116 | return true |
| 117 | } |
| 118 | for _, p := range []string{"mail-prefix-", "no-credential-", "environment-exists-", "fork-missing-", "instance-bound-elsewhere-", "console-", "profile-differs-"} { |
| 119 | if strings.HasPrefix(code, p) { |
| 120 | _, ok := provision.AppBySlug(strings.TrimPrefix(code, p)) |
| 121 | return ok |
| 122 | } |
| 123 | } |
| 124 | return false |
| 125 | } |
| 126 | |
| 127 | func describe(code string) string { |
| 128 | if code == "" { |
| 129 | return "" |
| 130 | } |
| 131 | if w, ok := words[code]; ok { |
| 132 | return w |
| 133 | } |
| 134 | for prefix, w := range prefixes { |
| 135 | if strings.HasPrefix(code, prefix) { |
| 136 | return w + strings.TrimPrefix(code, prefix) |
| 137 | } |
| 138 | } |
| 139 | return code |
| 140 | } |
| 141 | |