mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 08:44:09 +02:00
parent
c5c2bdbf50
commit
125b68e08a
7 changed files with 207 additions and 9 deletions
56
README.md
56
README.md
|
|
@ -371,6 +371,62 @@ Additionally, the proxy allows access to the server containers trough either
|
|||
`rolling-bees-mail.haze.example.com` will give access to the smtp4dev web
|
||||
interface of the `rolling-bees` instance.
|
||||
|
||||
## Haze scripts
|
||||
|
||||
Haze scripts combine a set of instance options and a script to run in the
|
||||
instance.
|
||||
|
||||
Haze scripts are intended to way to create automated ways of running more
|
||||
complex tests are setting up more complex instances.
|
||||
|
||||
A script contains of 3 paths
|
||||
|
||||
1. An optional shebang line setting `haze` as the interperter, e.g.
|
||||
`#! /usr/bin/env haze`
|
||||
2. A shebang line setting the options for the instance creation as the
|
||||
interperter, e.g. `#! haze shell pgsql s3`
|
||||
3. The rest that is ran as a script inside the created instace.
|
||||
|
||||
For example, the following script will create an instance with `postgresql` and
|
||||
`s3` primary storage. Then creates a new file, gets the file id, read the object
|
||||
of the file from S3, validate that it contains the expected contents, and
|
||||
cleanup the instance.
|
||||
|
||||
```bash
|
||||
#! /home/robin/Projects/haze/target/debug/haze script
|
||||
#! haze shell pgsql s3
|
||||
|
||||
echo 'test' | occ file:put '-' /admin/files/test.txt
|
||||
FILE_ID=$(occ info:file /admin/files/test.txt | grep fileid: | grep -oE '[0-9]+')
|
||||
OBJECT_CONTENTS=$(occ file:object:get urn:oid:$FILE_ID -)
|
||||
if [ "$OBJECT_CONTENTS" == 'test' ]; then
|
||||
echo "object contains expected contents"
|
||||
else
|
||||
echo "object does not contains expected contents!"
|
||||
fi
|
||||
```
|
||||
|
||||
### Script modes
|
||||
|
||||
Scripts can be either `shell` or `start` scripts.
|
||||
|
||||
`shell` scripts will automatically remove the created instance once the script
|
||||
is done, just like `haze shell` will. The intended use case for this is
|
||||
performing some tests in the created instance without leaving state behind.
|
||||
|
||||
`start` scripts on the other hand will keep the instance, like `haze start`
|
||||
will. The intended use case for this is creating more complex instances without
|
||||
having to configure a dedicated preset.
|
||||
|
||||
The script mode is determined based on the shebang line. The mode set in a
|
||||
script can be overriden by running the script with
|
||||
`haze script [shell|start] path-to-script.sh`.
|
||||
|
||||
## Nushell scripts
|
||||
|
||||
By default, the script contents are executed as a `bash` script, you can instead
|
||||
execute the script as a `nushell` script by using `.nu` as the file extention.
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration is loaded from `~/.config/haze/haze.toml` and has the following
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue