|
1 | 1 | # Hippo Client |
2 | 2 |
|
3 | | -`hippo` is an **experimental** client for the [Hippo PaaS](https://github.com/deislabs/hippo) and [Bindle](https://github.com/deislabs/bindle). |
| 3 | +`hippo` is an **experimental** client for the [Hippo |
| 4 | +PaaS](https://github.com/deislabs/hippo). |
4 | 5 |
|
5 | | -The `hippo` tool processes an application's `HIPPOFACTS` (Hippo |
6 | | -artifacts) file and generates a bindle that it can either push directly |
7 | | -or can later be uploaded using `bindle push`. |
| 6 | +The `hippo` tool interacts directly with the Hippo API. Its primary purpose is |
| 7 | +to interact with the various endpoints provided by the |
| 8 | +[hippo-openapi](https://github.com/fermyon/hippo-openapi) project. |
8 | 9 |
|
9 | | -## The HIPPOFACTS file |
| 10 | +Users seeking to build, deploy, and run applications should look at |
| 11 | +[spin](https://github.com/fermyon/spin/). |
10 | 12 |
|
11 | | -HIPPOFACTS is a TOML file with the following structure: |
| 13 | +## Using the Hippo Client |
12 | 14 |
|
13 | | -```toml |
14 | | -[bindle] |
15 | | -name = "birdsondemand" |
16 | | -version = "1.2.3" |
17 | | -description = "provides birds as a service" # optional |
18 | | -authors = ["Joan Q Programmer"] # optional |
| 15 | +### Logging in |
19 | 16 |
|
20 | | -[[handler]] |
21 | | -route = "/birds/flightless" |
22 | | -name = "bin/penguin.wasm" |
23 | | -files = ["photo/adelie.png", "photo/rockhopper.png", "stock/*.jpg"] |
24 | | - |
25 | | -[[handler]] |
26 | | -route = "/birds/irritable/fighty" |
27 | | -name = "bin/cassowary.wasm" |
28 | | -# entrypoint key is optional |
29 | | -# files key is optional |
30 | | - |
31 | | -[[handler]] |
32 | | -route = "/birds/naughty" |
33 | | -name = "bin/kea.wasm" |
34 | | -entrypoint = "steal_wipers" |
35 | | -files = ["stock/kea.jpg", "stock/wipers.jpg"] |
| 17 | +```console |
| 18 | +$ hippo login |
| 19 | +Enter username: bacongobbler |
| 20 | +Enter password: [hidden] |
| 21 | +Logged in as bacongobbler |
36 | 22 | ``` |
37 | 23 |
|
38 | | -The `bindle` section is copied directly to `invoice.toml`, _except_ that in development |
39 | | -mode a prerelease segment is appended to the version to make it unique. |
40 | | - |
41 | | -Each `handler` table is processed as follows: |
| 24 | +Authentication is handled through `hippo login`, which logs into Hippo. With |
| 25 | +`hippo login`, the Hippo URL is specified in the `--url` flag. Hippo requires |
| 26 | +authentication: if `--username` or `--password` are not provided, the CLI will |
| 27 | +prompt for that information. |
42 | 28 |
|
43 | | -* A group for the handler is added to the invoice |
44 | | -* The `name` value is looked up in the file system, and a parcel is entered into the invoice |
45 | | - for the corresponding file. The parcel's `conditions.requires` is set to the handler group. |
46 | | -* If the handler has a `files` key, all patterns in that array are matched against the file |
47 | | - system, and a parcel is entered into the invoice for the corresponding file. The parcel |
48 | | - `label.name` is the relative path of the file to the `HIPPOFACTS` file.The parcel's |
49 | | - `conditions.memberOf` is set to a list of _all_ handler groups that contained patterns that |
50 | | - the file matched - this may be more than one if multiple handler file patterns matched the |
51 | | - same file. |
| 29 | +Logging out can be performed with `hippo logout`, which logs out of Hippo. |
52 | 30 |
|
53 | | -For example, given the following file structure: |
54 | | - |
55 | | -``` |
56 | | -|- HIPPOFACTS |
57 | | -|- src |
58 | | -| |- main.rs |
59 | | -| |- utils.rs |
60 | | -|- bin |
61 | | -| |- cassowary.wasm |
62 | | -| |- kea.wasm |
63 | | -| |- kokako.wasm |
64 | | -| |- penguin.wasm |
65 | | -|- photo |
66 | | -| |- adelie.png |
67 | | -| |- emperor.png |
68 | | -| |- rockhopper.png |
69 | | -|- stock |
70 | | - |- kea.jpg |
71 | | - |- little-blue.jpg |
72 | | - |- little-blue.png |
73 | | - |- wipers.jpg |
| 31 | +```console |
| 32 | +$ hippo logout |
| 33 | +Logged out |
74 | 34 | ``` |
75 | 35 |
|
76 | | -the previous `HIPPOFACTS` would create the following invoice (omitting some details |
77 | | -and adding comments): |
78 | | - |
79 | | -```toml |
80 | | -bindleVersion = '1.0.0' |
81 | | - |
82 | | -[bindle] |
83 | | -name = 'birdsondemand' |
84 | | -version = '1.2.3-ivan-2021.05.31.16.49.09.990' |
85 | | -description = 'provides birds as a service' |
86 | | -authors = ['Joan Q Programmer'] |
87 | | - |
88 | | -# Parcels representing handler WASM modules have a `requires` attribute |
89 | | -# and a `wagi.route` feature, and a `wagi.entrypoint` if specified in |
90 | | -# the source spec |
91 | | - |
92 | | -[[parcel]] |
93 | | -[parcel.label] |
94 | | -sha256 = '0a4346f806b28b3ce94905c3ac56fcd5ee2337d8613161696aba52eb0c3551cc' |
95 | | -name = 'bin/penguin.wasm' |
96 | | -[parcel.label.feature.wagi] |
97 | | -file = 'false' |
98 | | -route = '/birds/flightless' |
99 | | -[parcel.conditions] |
100 | | -requires = ['bin/penguin.wasm-files'] |
| 36 | +If you want to skip server TLS verification, pass the `-k` flag to `hippo |
| 37 | +login`. This can be useful if you are running development services with |
| 38 | +self-signed certificates. |
101 | 39 |
|
102 | | -[[parcel]] |
103 | | -[parcel.label] |
104 | | -sha256 = '1f71511371129511321c45be058c60e23cf9ba898d8a3f3309555985b5027490' |
105 | | -name = 'bin/cassowary.wasm' |
106 | | -[parcel.label.feature.wagi] |
107 | | -file = 'false' |
108 | | -route = '/birds/irritable/fighty' |
109 | | -[parcel.conditions] |
110 | | -requires = ['bin/cassowary.wasm-files'] |
| 40 | +**Note: the `-k` and `--danger-accept-invalid-certs` flags are a security risk. |
| 41 | +Do not use them in production.** |
111 | 42 |
|
112 | | -[[parcel]] |
113 | | -[parcel.label] |
114 | | -sha256 = 'bab02c178882085bf20defd15c0e8971edd95488a1ecb4a6273e6afcfb3c4030' |
115 | | -name = 'bin/kea.wasm' |
116 | | -[parcel.label.feature.wagi] |
117 | | -entrypoint = 'steal_wipers' |
118 | | -file = 'false' |
119 | | -route = '/birds/naughty' |
120 | | -[parcel.conditions] |
121 | | -requires = ['bin/kea.wasm-files'] |
| 43 | +### Creating an Application |
122 | 44 |
|
123 | | -# Parcels derived from `files` patterns have a `memberOf` attribute and a |
124 | | -# `wagi.file` feature of "true" |
125 | | - |
126 | | -[[parcel]] |
127 | | -[parcel.label] |
128 | | -sha256 = 'e99f19705a23cbeeeade5d2b4f8b83fff09beb093552e82073cdb302ee10eb76' |
129 | | -name = 'photo/adelie.png' |
130 | | -[parcel.label.feature.wagi] |
131 | | -file = 'true' |
132 | | -[parcel.conditions] |
133 | | -memberOf = ['bin/penguin.wasm-files'] |
134 | | - |
135 | | -[[parcel]] |
136 | | -[parcel.label] |
137 | | -sha256 = 'e8f7b60dfe5ee560edd1ac616463a0682a0e7c57a5ce2a8fe5c0990e500d0ac5' |
138 | | -name = 'photo/rockhopper.png' |
139 | | -[parcel.label.feature.wagi] |
140 | | -file = 'true' |
141 | | -[parcel.conditions] |
142 | | -memberOf = ['bin/penguin.wasm-files'] |
143 | | - |
144 | | -[[parcel]] |
145 | | -[parcel.label] |
146 | | -sha256 = '843baaf5a63cbc38d4d4c00036b95e435254eece7480fb717c8a17dcdc2aeefc' |
147 | | -name = 'stock/little-blue.jpg' |
148 | | -[parcel.label.feature.wagi] |
149 | | -file = 'true' |
150 | | -[parcel.conditions] |
151 | | -memberOf = ['bin/penguin.wasm-files'] |
152 | | - |
153 | | -# Some files are matched by more than one handler's patterns |
154 | | - |
155 | | -[[parcel]] |
156 | | -[parcel.label] |
157 | | -sha256 = '6451ab5be799a6aa52ce8b8a084a12066bb2dd8e1a73a692627bb96b4b9a72f0' |
158 | | -name = 'stock/wipers.jpg' |
159 | | -[parcel.label.feature.wagi] |
160 | | -file = 'true' |
161 | | -[parcel.conditions] |
162 | | -memberOf = [ |
163 | | - 'bin/penguin.wasm-files', |
164 | | - 'bin/kea.wasm-files', |
165 | | -] |
166 | | - |
167 | | -[[parcel]] |
168 | | -[parcel.label] |
169 | | -sha256 = '93c3a391d842e3b8032d560db4870b5426c5c05a9f2a60b187e567ae69d8e658' |
170 | | -name = 'stock/kea.jpg' |
171 | | -[parcel.label.feature.wagi] |
172 | | -file = 'true' |
173 | | -[parcel.conditions] |
174 | | -memberOf = [ |
175 | | - 'bin/penguin.wasm-files', |
176 | | - 'bin/kea.wasm-files', |
177 | | -] |
178 | | - |
179 | | -# Group per handler |
180 | | - |
181 | | -[[group]] |
182 | | -name = 'bin/penguin.wasm-files' |
| 45 | +```console |
| 46 | +$ hippo app add helloworld helloworld |
| 47 | +Added App helloworld (ID = 'e4a30d14-4536-4f4a-81d5-80e961e7710c') |
| 48 | +IMPORTANT: save this App ID for later - you will need it to update and/or delete the App |
| 49 | +``` |
183 | 50 |
|
184 | | -[[group]] |
185 | | -name = 'bin/cassowary.wasm-files' |
| 51 | +### Creating a Channel |
186 | 52 |
|
187 | | -[[group]] |
188 | | -name = 'bin/kea.wasm-files' |
| 53 | +```console |
| 54 | +$ hippo channel add latest e4a30d14-4536-4f4a-81d5-80e961e7710c |
| 55 | +Added Channel latest (ID = '685ff7d8-7eef-456f-ad5a-4c5c39975588') |
| 56 | +IMPORTANT: save this Channel ID for later - you will need it to update and/or delete the Channel |
189 | 57 | ``` |
190 | 58 |
|
191 | | -`hippo` does not currently support Bindle's `parcel.label.feature` or `signature` features. |
| 59 | +If not specified, Hippo to deploys the latest revision. This can be changed by |
| 60 | +either providing a different `--range-rule`, or by specifying a `--revision-id`. |
192 | 61 |
|
193 | | -### External handlers |
| 62 | +By default, Hippo will bind the channel to a domain with the address |
| 63 | +`<channel_name>.<app_name>.<platform_domain>`. In this case, |
| 64 | +`latest.helloworld.hippofactory.local`. If you want to change this domain, |
| 65 | +use the `--domain` flag. |
194 | 66 |
|
195 | | -It is sometimes useful to have routes handled by 'library' parcels that perform common |
196 | | -functions like serving static assets from the filesystem. To do this, rather than |
197 | | -copying the Wasm handler locally, you can reference it directly from your HIPPOFACTS. |
198 | | -To do this: |
| 67 | +### Creating a Revision |
199 | 68 |
|
200 | | -* The library parcel but have an annotation named `wagi_handler_id`. This is the ID by |
201 | | - which HIPPOFACTS will refer to it - this decouples the reference from volatile details |
202 | | - like parcel name or SHA. |
203 | | -* Instead of a `name` in your `handler` table, you specify a `bindleId` and `handlerId`. |
204 | | -* Do not specify an `entrypoint` - this is defined by the library parcel. |
| 69 | +If you pushed a bindle to bindle-server called `helloworld/1.0.0`: |
205 | 70 |
|
206 | | -For example: |
207 | | - |
208 | | -```toml |
209 | | -[[handler]] |
210 | | -external.bindleId = "deislabs/fileserver/1.0.0" |
211 | | -external.handlerId = "static" |
212 | | -route = "/images" |
213 | | -files = ["birds/*.jpg"] |
| 71 | +```console |
| 72 | +$ hippo revision add helloworld 1.0.0 |
| 73 | +Added Revision 1.0.0 |
214 | 74 | ``` |
215 | 75 |
|
216 | | -The Hippo client will locate the specified `wagi_handler_id` in the given bindle, and create a |
217 | | -parcel in your invoice that points to the same blob but with a `requires` condition for |
218 | | -the handler group. It also creates parcels for any parcels that the handler `requires` |
219 | | -in its original bindle. |
220 | | - |
221 | | -### Reusable library modules |
| 76 | +If any applications use that storage ID, all its channels will be re-evaluated |
| 77 | +to determine if they need to be re-schedule the new revision to the job |
| 78 | +scheduler. |
222 | 79 |
|
223 | | -To create a 'library' parcel that can be referenced as an external handler, provide an |
224 | | -`export` section. This is similar to a local handler except instead of a `route` it |
225 | | -has an `id` - this is the name by which it can be referenced (it gets mapped to the |
226 | | -`wagi_handler_id` annotation). For example: |
| 80 | +### Adding an Environment Variable |
227 | 81 |
|
228 | | -```toml |
229 | | -[[export]] |
230 | | -name = "gallery.wasm" |
231 | | -id = "gallery" |
232 | | -files = ["cache/*.db"] |
| 82 | +```console |
| 83 | +$ hippo env add HELLO world 685ff7d8-7eef-456f-ad5a-4c5c39975588 |
| 84 | +Added Environment Variable HELLO (ID = 'c97f9855-d998-4dac-889b-11b553f53bea') |
| 85 | +IMPORTANT: save this Environment Variable ID for later - you will need it to update and/or delete the Environment Variable |
233 | 86 | ``` |
234 | 87 |
|
235 | | -**NOTE:** If your spec consists only of exports, you should not notify Hippo, because |
236 | | -there will be no application mapped to the resultant bindle. Pass `-a bindle` to |
237 | | -push to the Bindle server but not register it with Hippo. |
238 | | - |
239 | | -## Running the Hippo Client |
240 | | - |
241 | | -As a developer you can run `hippo push .` in your `HIPPOFACTS` directory to |
242 | | -assemble all matching files and publish them as a bindle. In this mode, |
243 | | -`hippo`: |
244 | | - |
245 | | -* Mangles the version with a prerelease segment |
246 | | -* Stages to a temporary directory |
247 | | -* Pushes to the Bindle server |
248 | | -* Notifies Hippo that a new bindle version is available |
249 | | - |
250 | | -Authentication is handled through two commands: |
251 | | - |
252 | | -- `hippo auth login`, which logs into Hippo |
253 | | -- `hippo bindle login`, which logs into Bindle |
254 | | - |
255 | | -With `hippo auth login`, the Hippo URL is specified in the `--url` flag. Hippo requires authentication: |
256 | | -if `--username` or `--password` are not provided, the CLI will prompt for that information. |
257 | | - |
258 | | -With `hippo bindle login`, the Bindle server is specified with the `--url` flag. If the Bindle server |
259 | | -requires authentication, specify this via the `--username` and `--password` options. Note that Bindle |
260 | | -authentication is independent of Hippo authentication, and in some cases (e.g. if `bindle-server` is |
261 | | -provided the `--unauthenticated` flag), no authentication is necessary! |
262 | | - |
263 | | -If you want to review the proposed bindle rather than pushing it, pass |
264 | | -`hippo bindle prepare -d <staging_dir> .`. This will stage the bindle to the specified directory but |
265 | | -_not_ push it. If you want to push the generated bindle but not notify Hippo, use |
266 | | -`hippo bindle push .`. |
267 | | - |
268 | | -In a CI environment you can supply the `-v production` option to suppress version mangling. |
269 | | -This will create and upload the bindle with the version from `HIPPOFACTS`, without the |
270 | | -prerelease segment. |
271 | | - |
272 | | -If you want to skip server TLS verification, pass the `-k` flag to either `login` command. This can be |
273 | | -useful if you are running development services with self-signed certificates. |
274 | | -**This is a security risk: do not use it in production.** |
275 | | - |
276 | | -Logging out can be performed with |
277 | | - |
278 | | -- `hippo auth logout`, which logs out of Hippo |
279 | | -- `hippo bindle logout`, which logs out of Bindle |
280 | | - |
281 | 88 | ## Building from source |
282 | 89 |
|
283 | | -* Known link failure on WSL: workaround is to build once with `RUSTFLAGS='-C opt-level=0' cargo build` |
284 | | -(after which plain `cargo build` seems to work) |
| 90 | +```console |
| 91 | +cargo build --release |
| 92 | +``` |
285 | 93 |
|
286 | 94 | ## Contributing |
287 | 95 |
|
288 | | -This project welcomes contributions and suggestions. Most contributions require you to agree to a |
289 | | -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us |
290 | | -the rights to use your contribution. For details, visit https://cla.microsoft.com. |
291 | | - |
292 | | -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide |
293 | | -a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions |
294 | | -provided by the bot. You will only need to do this once across all repos using our CLA. |
295 | | - |
296 | | -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). |
297 | | -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or |
298 | | -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
| 96 | +This project welcomes contributions and suggestions. Most contributions require |
| 97 | +you to agree to a Contributor License Agreement (CLA) declaring that you have |
| 98 | +the right to, and actually do, grant us the rights to use your contribution. For |
| 99 | +details, visit https://cla.microsoft.com. |
| 100 | + |
| 101 | +When you submit a pull request, a CLA-bot will automatically determine whether |
| 102 | +you need to provide a CLA and decorate the PR appropriately (e.g., label, |
| 103 | +comment). Simply follow the instructions provided by the bot. You will only need |
| 104 | +to do this once across all repos using our CLA. |
| 105 | + |
| 106 | +This project has adopted the [Microsoft Open Source Code of |
| 107 | +Conduct](https://opensource.microsoft.com/codeofconduct/). For more information |
| 108 | +see the [Code of Conduct |
| 109 | +FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact |
| 110 | +[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional |
| 111 | +questions or comments. |
0 commit comments