|
| 1 | += Pity (the fool) |
| 2 | +:toc: |
| 3 | +:exampleDir: examples |
| 4 | + |
| 5 | +`pity` is a tool that allows developer experience teams to provide tooling for engineers. |
| 6 | +There are two tools engineers will use directly, `pity doctor` and `pity report`. |
| 7 | + |
| 8 | +`pity doctor` runs a set of user-defined scripts to help configure, debug, and fix an engineers environment. |
| 9 | + |
| 10 | +`pity report` is used to report local execution error. |
| 11 | +This is primarily used to generate a bug report, and upload it somewhere so that the responders have all the required into to respond. |
| 12 | + |
| 13 | +== Commands |
| 14 | + |
| 15 | +=== `pity doctor` |
| 16 | + |
| 17 | +Environments are hard to maintain and can fall out of sync with exceptions quickly. |
| 18 | +`pity doctor` is a way to codify what a working environment means and tell the user how to fix it. |
| 19 | +The aim is to reduce the need for engineers to ask others to fix their environment and distribute what "working" means to everyone. |
| 20 | + |
| 21 | +=== `pity report` |
| 22 | + |
| 23 | +Sometimes you need to report an error to others. |
| 24 | +Often the responding team wants the output that failed, and some other useful debugging information. |
| 25 | + |
| 26 | +By using `pity report some-command.sh`, pity will capture all the output with timestamps and then generate a "report" that can be uploaded to multiple destinations. |
| 27 | + |
| 28 | +=== `pity-intercept` |
| 29 | + |
| 30 | +`pity-intercept` is a https://en.wikipedia.org/wiki/Shebang_(Unix)[shebang] replacement for `env`. |
| 31 | +Behind the scene `env -S` is run to execute the script, however `pity-intercept` will watch all the output and then check for KnownErrors. |
| 32 | +This allows the engineer to see, in real time, suggestions for fixing errors. |
| 33 | +It also allows the engineer to upload a bug report immediately. |
| 34 | + |
| 35 | +== Config |
| 36 | + |
| 37 | +All `pity` config files look like Kubernetes yaml, requiring: |
| 38 | + |
| 39 | +- `apiVersion` |
| 40 | +- `kind` |
| 41 | +- `metadata` |
| 42 | +- `spec` |
| 43 | + |
| 44 | +Config files live inside a `.pity` directory, and `pity` will search for this directory walking up the file tree. |
| 45 | +A user can also add a specific file or folder with arguments or environment variables. |
| 46 | + |
| 47 | +[cols="1,2"] |
| 48 | +|=== |
| 49 | +| Field |
| 50 | +| Description |
| 51 | + |
| 52 | +a| `metadata` |
| 53 | +a| Required field providing "metadata" about the resource. |
| 54 | +[cols="1,2"] |
| 55 | +!=== |
| 56 | +! Field |
| 57 | +! Description |
| 58 | + |
| 59 | +a! `name` |
| 60 | +a! (required) Name of the resource, must be unique within the `kind` |
| 61 | + |
| 62 | +a! `labels` |
| 63 | +a! A map of `string:string` that can be used by user. |
| 64 | + |
| 65 | +a! `annotations` |
| 66 | +a! A map of `string:string` that can be used by user. Pity will set some specific annotations. |
| 67 | + |
| 68 | +!=== |
| 69 | + |
| 70 | +a| `kind` |
| 71 | +a| The type of resource that's defined. The `kind` and `apiVersion` define what options the `spec` field accepts. |
| 72 | + |
| 73 | +Current supported options are: `PityDoctorCheck`, `PityReport`, `PityKnownError`. |
| 74 | + |
| 75 | +a| `apiVersion` |
| 76 | +a| The version of resource that's defined. The `kind` and `apiVersion` define what options the `spec` field accepts. |
| 77 | + |
| 78 | +The only supported value at the moment is `pity.github.com/v1alpha`. |
| 79 | + |
| 80 | +a| `spec` |
| 81 | +| A data structure that changes based on `apiVersion` and `kind`. |
| 82 | + |
| 83 | +|=== |
| 84 | + |
| 85 | + |
| 86 | +=== `PityDoctorCheck` |
| 87 | + |
| 88 | +Used to diagnose errors with an engineers environment. Used when running `pity doctor`. |
| 89 | + |
| 90 | +**Example** |
| 91 | + |
| 92 | +[source,yaml] |
| 93 | +.... |
| 94 | +include::{exampleDir}/doctor-check.yaml[] |
| 95 | +.... |
| 96 | + |
| 97 | +From the example, when the check runs it will execute `scripts/does-path-env-exist.sh` which is defined relative to the file containing the check. |
| 98 | + |
| 99 | +If the process exits non-0, the help text will be shown to the user. |
| 100 | + |
| 101 | +=== `PityKnownError` |
| 102 | + |
| 103 | +When using `pity-intercept` or `pity report`, providing a KnownError file will allow pity to tell the user about known errors. |
| 104 | +This is useful for example if the owning team knows that the output will contain a message and the user should check for something before continuing. |
| 105 | +A common example is a dependency is missing, the node modules might need to be cleaned. |
| 106 | + |
| 107 | +**Example** |
| 108 | + |
| 109 | +[source,yaml] |
| 110 | +.... |
| 111 | +include::{exampleDir}/known-error.yaml[] |
| 112 | +.... |
| 113 | + |
| 114 | +[cols="1,2"] |
| 115 | +|=== |
| 116 | +| Field |
| 117 | +| Description |
| 118 | + |
| 119 | +a| `.spec.description` |
| 120 | +| A short description of the error, for `pity config` |
| 121 | + |
| 122 | +a| `.spec.pattern` |
| 123 | +| A regex pattern to search all output for (standard error and standard out) |
| 124 | + |
| 125 | +a| `.spec.help` |
| 126 | +| The text that will be shown to a user when the pattern matches |
| 127 | +|=== |
| 128 | + |
| 129 | +=== `PityReport` |
| 130 | + |
| 131 | +When using `pity-intercept` or `pity report`, a user is able to upload the error for sharing. |
| 132 | +`PityReport` defines where to upload, and any additional commands that should be and output included in the report. |
| 133 | + |
| 134 | +**Example** |
| 135 | + |
| 136 | +[source,yaml] |
| 137 | +.... |
| 138 | +include::{exampleDir}/report.yaml[] |
| 139 | +.... |
| 140 | + |
| 141 | +[cols="1,2"] |
| 142 | +|=== |
| 143 | +| Field |
| 144 | +| Description |
| 145 | + |
| 146 | +a| `.spec.additionalData` |
| 147 | +| A map of `name` to `command`. Pity will run the command and capture the output as part of the report. |
| 148 | + |
| 149 | +a| `.spec.destination` |
| 150 | +a| Currently, supports https://github.com/orhun/rustypaste[`rustyPaste`] as a source. |
| 151 | +Additional options will be added in the future. |
| 152 | + |
| 153 | +a| `.spec.destination.rustyPaste.url` |
| 154 | +| URL to upload the report to. |
| 155 | +|=== |
0 commit comments