Packer
HashiCups
@hashicorp
The HashiCups plugin is a reference plugin for learning how to use HashiCorp Packer.
- Official
Updated 2 years ago
- GitHub(opens in new tab)
HashiCups
The HashiCups plugin is part of the Packer Learn collection. The plugin interacts with the HashiCorp Demo App API called HashiCups.
Installation
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
Components
Builders
- Order builder - The order builder is used to create custom HashiCups order.
Provisioners
- Toppings provisioner - The toppings provisioner is used to add toppings to your order coffee(s).
Post-processors
- Receipt post-processor - The receipt post-processor is used to print the receipt of your order.
Data Sources
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.
The HashiCups menu and orders
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