|
1 | 1 | # hippofactory |
2 | 2 |
|
3 | 3 | The `hippofactory` tool processes an application's `HIPPOFACTS` (Hippo |
4 | | -artifacts) file and generates a standalone Bindle that can be uploaded |
5 | | -using `bindle push`. |
| 4 | +artifacts) file and generates a bindle that it can either push directly |
| 5 | +or can later be uploaded using `bindle push`. |
6 | 6 |
|
| 7 | +## The HIPPOFACTS file |
| 8 | + |
| 9 | +HIPPOFACTS is a TOML file with the following structure: |
| 10 | + |
| 11 | +```toml |
| 12 | +[bindle] |
| 13 | +name = "birdsondemand" |
| 14 | +version = "1.2.3" |
| 15 | +description = "provides birds as a service" # optional |
| 16 | +authors = ["Joan Q Programmer"] # optional |
| 17 | + |
| 18 | +[[handler]] |
| 19 | +route = "/birds/flightless" |
| 20 | +name = "bin/penguin.wasm" |
| 21 | +files = ["photo/adelie.png", "photo/rockhopper.png", "stock/*.jpg"] |
| 22 | + |
| 23 | +[[handler]] |
| 24 | +route = "/birds/irritable/fighty" |
| 25 | +name = "bin/cassowary.wasm" |
| 26 | +# files key is optional |
| 27 | + |
| 28 | +[[handler]] |
| 29 | +route = "/birds/naughty" |
| 30 | +name = "bin/kea.wasm" |
| 31 | +files = ["stock/kea.jpg", "stock/wipers.jpg"] |
| 32 | +``` |
| 33 | + |
| 34 | +The `bindle` section is copied directly to `invoice.toml`, _except_ that in development |
| 35 | +mode a prerelease segment is appended to the version to make it unique. |
| 36 | + |
| 37 | +Each `handler` table is processed as follows: |
| 38 | + |
| 39 | +* A group for the handler is added to the invoice |
| 40 | +* The `name` value is looked up in the file system, and a parcel is entered into the invoice |
| 41 | + for the corresponding file. The parcel's `conditions.requires` is set to the handler group. |
| 42 | +* If the handler has a `files` key, all patterns in that array are matched against the file |
| 43 | + system, and a parcel is entered into the invoice for the corresponding file. The parcel |
| 44 | + `label.name` is the relative path of the file to the `HIPPOFACTS` file.The parcel's |
| 45 | + `conditions.memberOf` is set to a list of _all_ handler groups that contained patterns that |
| 46 | + the file matched - this may be more than one if multiple handler file patterns matched the |
| 47 | + same file. |
| 48 | + |
| 49 | +For example, given the following file structure: |
| 50 | + |
| 51 | +``` |
| 52 | +|- HIPPOFACTS |
| 53 | +|- src |
| 54 | +| |- main.rs |
| 55 | +| |- utils.rs |
| 56 | +|- bin |
| 57 | +| |- cassowary.wasm |
| 58 | +| |- kea.wasm |
| 59 | +| |- kokako.wasm |
| 60 | +| |- penguin.wasm |
| 61 | +|- photo |
| 62 | +| |- adelie.png |
| 63 | +| |- emperor.png |
| 64 | +| |- rockhopper.png |
| 65 | +|- stock |
| 66 | + |- kea.jpg |
| 67 | + |- little-blue.jpg |
| 68 | + |- little-blue.png |
| 69 | + |- wipers.jpg |
| 70 | +``` |
| 71 | + |
| 72 | +the previous `HIPPOFACTS` would create the following invoice (omitting some details |
| 73 | +and adding comments): |
| 74 | + |
| 75 | +```toml |
| 76 | +bindleVersion = '1.0.0' |
| 77 | + |
| 78 | +[bindle] |
| 79 | +name = 'birdsondemand' |
| 80 | +version = '1.2.3-ivan-2021.05.18.10.51.09.084' |
| 81 | +description = 'provides birds as a service' |
| 82 | +authors = ['Joan Q Programmer'] |
| 83 | + |
| 84 | +# Parcels representing handler WASM modules have a `requires` attribute |
| 85 | + |
| 86 | +[[parcel]] |
| 87 | +[parcel.label] |
| 88 | +sha256 = '0a4346f806b28b3ce94905c3ac56fcd5ee2337d8613161696aba52eb0c3551cc' |
| 89 | +name = 'bin/penguin.wasm' |
| 90 | +[parcel.conditions] |
| 91 | +requires = ['bin/penguin.wasm-files'] |
| 92 | + |
| 93 | +[[parcel]] |
| 94 | +[parcel.label] |
| 95 | +sha256 = '1f71511371129511321c45be058c60e23cf9ba898d8a3f3309555985b5027490' |
| 96 | +name = 'bin/cassowary.wasm' |
| 97 | +[parcel.conditions] |
| 98 | +requires = ['bin/cassowary.wasm-files'] |
| 99 | + |
| 100 | +[[parcel]] |
| 101 | +[parcel.label] |
| 102 | +sha256 = 'bab02c178882085bf20defd15c0e8971edd95488a1ecb4a6273e6afcfb3c4030' |
| 103 | +name = 'bin/kea.wasm' |
| 104 | +[parcel.conditions] |
| 105 | +requires = ['bin/kea.wasm-files'] |
| 106 | + |
| 107 | +# Parcels derived from `files` patterns have a `memberOf` attribute |
| 108 | + |
| 109 | +[[parcel]] |
| 110 | +[parcel.label] |
| 111 | +sha256 = 'e99f19705a23cbeeeade5d2b4f8b83fff09beb093552e82073cdb302ee10eb76' |
| 112 | +name = 'photo/adelie.png' |
| 113 | +[parcel.conditions] |
| 114 | +memberOf = ['bin/penguin.wasm-files'] |
| 115 | + |
| 116 | +[[parcel]] |
| 117 | +[parcel.label] |
| 118 | +sha256 = 'e8f7b60dfe5ee560edd1ac616463a0682a0e7c57a5ce2a8fe5c0990e500d0ac5' |
| 119 | +name = 'photo/rockhopper.png' |
| 120 | +[parcel.conditions] |
| 121 | +memberOf = ['bin/penguin.wasm-files'] |
| 122 | + |
| 123 | +[[parcel]] |
| 124 | +[parcel.label] |
| 125 | +sha256 = '843baaf5a63cbc38d4d4c00036b95e435254eece7480fb717c8a17dcdc2aeefc' |
| 126 | +name = 'stock/little-blue.jpg' |
| 127 | +[parcel.conditions] |
| 128 | +memberOf = ['bin/penguin.wasm-files'] |
| 129 | + |
| 130 | +# Some files are matched by more than one handler's patterns |
| 131 | + |
| 132 | +[[parcel]] |
| 133 | +[parcel.label] |
| 134 | +sha256 = '6451ab5be799a6aa52ce8b8a084a12066bb2dd8e1a73a692627bb96b4b9a72f0' |
| 135 | +name = 'stock/wipers.jpg' |
| 136 | +[parcel.conditions] |
| 137 | +memberOf = [ |
| 138 | + 'bin/penguin.wasm-files', |
| 139 | + 'bin/kea.wasm-files', |
| 140 | +] |
| 141 | + |
| 142 | +[[parcel]] |
| 143 | +[parcel.label] |
| 144 | +sha256 = '93c3a391d842e3b8032d560db4870b5426c5c05a9f2a60b187e567ae69d8e658' |
| 145 | +name = 'stock/kea.jpg' |
| 146 | +[parcel.conditions] |
| 147 | +memberOf = [ |
| 148 | + 'bin/penguin.wasm-files', |
| 149 | + 'bin/kea.wasm-files', |
| 150 | +] |
| 151 | + |
| 152 | +# Group per handler |
| 153 | + |
| 154 | +[[group]] |
| 155 | +name = 'bin/penguin.wasm-files' |
| 156 | + |
| 157 | +[[group]] |
| 158 | +name = 'bin/cassowary.wasm-files' |
| 159 | + |
| 160 | +[[group]] |
| 161 | +name = 'bin/kea.wasm-files' |
| 162 | +``` |
| 163 | + |
| 164 | +`hippofactory` does not currently support Bindle's `parcel.label.feature` |
| 165 | +or `signature` features. It does not yet support push options other than the server URL (e.g. auth). |
| 166 | + |
| 167 | +## Running hippofactory |
| 168 | + |
| 169 | +As a developer you can run `hippofactory .` in your `HIPPOFACTS` directory to assemble all matching |
| 170 | +files and push them to the Bindle server specified in the `BINDLE_SERVER_URL` environment variable. |
| 171 | +(If you don't want to set the environment variable, pass the `-s` argument with the URL.) |
| 172 | + |
| 173 | +In this mode, `hippofactory`: |
| 174 | + |
| 175 | +* Mangles the version with a prerelease segment |
| 176 | +* Stages to a temporary directory |
| 177 | +* Pushes to the Bindle server |
| 178 | + |
| 179 | +If you want to review the proposed bindle rather than pushing it, pass `--prepare -d <staging_dir>`. |
| 180 | +This will stage the bindle to the specified directory but _not_ push it. (If you later want |
| 181 | +to push it, you can do so using the separate `bindle` tool.) |
| 182 | + |
| 183 | +In a CI environment you can supply the `-v production` option to suppress version mangling. |
| 184 | +This will create and upload the bindle with the version from `HIPPOFACTS`, without the |
| 185 | +prerelease segment. |
7 | 186 | ## Building from source |
8 | 187 |
|
9 | 188 | * Known link failure on WSL: workaround is to build once with `RUSTFLAGS='-C opt-level=0' cargo build` |
|
0 commit comments