The HashiCups plugin is part of the Packer Learn collection. The plugin interacts with the HashiCorp Demo App API called HashiCups.
To install this plugin, copy and paste this code into your Packer configuration, then run packer init
.
packer {
required_plugins {
hashicups = {
source = "github.com/hashicorp/hashicups"
version = "~> 1"
}
}
}
Alternatively, you can use packer plugins install
to manage installation of this plugin.
$ packer plugins install github.com/hashicorp/hashicups
- Order builder - The order builder is used to create custom HashiCups order.
- Toppings provisioner - The toppings provisioner is used to add toppings to your order coffee(s).
- Receipt post-processor - The receipt post-processor is used to print the receipt of your order.
-
Coffees data source - The coffees data source is used to fetch all the coffees ids existent in the HashiCups menu.
-
Ingredients data source - The ingredients data source is used to fetch the ingredients ids for an existent coffee in the HashiCups menu.
Get the available coffees:
$ curl -v localhost:19090/coffees | jq
The following api call requires authorization.
First, sign-in with previously created account:
$ curl -X POST localhost:19090/signin -d '{"username":"education", "password":"test123"}'
Then, export the returned JWT token to HASHICUPS_TOKEN
:
$ export HASHICUPS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTU5ODcxNzgsInVzZXJfaWQiOjEsInVzZXJuYW1lIjoiZWR1Y2F0aW9uIn0.VJQXoxror-_ZUoNHtsG6GJ-bJCOvjU5kMZtXhSzBtP0
With that, you can perform authorized calls.
Get the ingredients for a coffee:
$ curl -X GET -H "Authorization: ${HASHICUPS_TOKEN}" localhost:19090/coffees/1/ingredients | jq
Get the created orders:
$ curl -X GET -H "Authorization: ${HASHICUPS_TOKEN}" localhost:19090/orders | jq