Skip to content

Latest commit

 

History

History

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

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

Post-processors

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