generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write plugin index and order builder docs
- Loading branch information
1 parent
ce3b361
commit d156681
Showing
15 changed files
with
366 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# HashiCups Plugin | ||
|
||
The Hashicups plugin is part of the [Packer](https://learn.hashicorp.com/packer) Learn collection. | ||
The plugin interacts with the [HashiCorp Demo App API](https://github.com/hashicorp-demoapp/product-api-go) called HashiCups. | ||
The component of this plugin are: | ||
|
||
- [Order builder](/docs/builders/order.mdx) - The order builder is used to create custom HashiCups order. | ||
|
||
- [Toppings provisiner](/docs/provisioners/toppings.mdx) - The toppings provisioner is used add toppings to your order coffee(s). | ||
|
||
- [Receipt post-processor](/docs/post-processors/receipt.mdx) - The receipt post-processor is used to | ||
print the receipt of your order. | ||
|
||
- [Coffees data source](/docs/datasources/coffees.mdx) - The coffees data source is used to | ||
fetch all the coffees ids existent in the Hashicups menu. | ||
|
||
- [Ingredients data source](/docs/datasources/ingredients.mdx) - 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: | ||
```shell | ||
$ curl -v localhost:19090/coffees | jq | ||
``` | ||
|
||
The following api call requires authorization. | ||
|
||
First, sing in with previously created account: | ||
```shell | ||
$ curl -X POST localhost:19090/signin -d '{"username":"education", "password":"test123"}' | ||
``` | ||
|
||
Then, export the return JWT token to HASHICUPS_TOKEN: | ||
```shell | ||
$ export HASHICUPS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTU5ODcxNzgsInVzZXJfaWQiOjEsInVzZXJuYW1lIjoiZWR1Y2F0aW9uIn0.VJQXoxror-_ZUoNHtsG6GJ-bJCOvjU5kMZtXhSzBtP0 | ||
``` | ||
With that, you can perform authorized calls. | ||
|
||
Get the ingredients for a coffee: | ||
|
||
````shell | ||
$ curl -X GET -H "Authorization: ${HASHICUPS_TOKEN}" localhost:19090/coffees/1/ingredients | jq | ||
```` | ||
|
||
Get the created orders: | ||
```shell | ||
$ curl -X GET -H "Authorization: ${HASHICUPS_TOKEN}" localhost:19090/orders | jq | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
description: > | ||
The order builder is used to create used to create custom HashiCups order. | ||
page_title: Order - Builders | ||
sidebar_title: Order | ||
--- | ||
|
||
# Order | ||
|
||
Type: `order` | ||
|
||
The order builder is used to create used to create custom HashiCups order. A custom order is when you want to change | ||
an ingredient quantity from one of the original coffees from the Hashicups menu. See [Example Usage](#example-usage) to | ||
understand better how it works. | ||
|
||
### Required | ||
|
||
- `username` (string) - The username signed up to the Product API. | ||
- `password` (string) - The password signed up to the Product API. | ||
- `item` ([]OrderItem) - An item you would like to order. See the [order item configuration](#order-item-configuration). | ||
|
||
### Optional | ||
|
||
- `host` (string) - The Product API host. Defaults to `localhost:19090` | ||
|
||
## Order item configuration | ||
|
||
### Required | ||
|
||
- `coffee` ([]Coffee) - The item's coffee. See the [coffee configuration](#coffee-configuration). | ||
|
||
|
||
### Optional | ||
|
||
- `quantity` (int) - How many of the item you would like to order. Defaults to `1`. | ||
|
||
## Coffee configuration | ||
|
||
### Required | ||
|
||
- `id` (string) - The id of the coffee you would like to customize. The ID should exist in the Hashicups menu. | ||
- `name` (string) - The name of your customization. Should be different from the original coffee's name. | ||
- `ingredient` ([]Ingredient) - The ingredients you'd like to change the quantity of. | ||
See the [ingredient configuration](#ingredient-configuration). | ||
|
||
## Ingredient configuration | ||
|
||
### Required | ||
|
||
- `id` (string) - The id of the coffee ingredient you would like to customize. The ID should exist in the Hashicups menu. | ||
- `quantity` (int) - The new quantity amount you'd like your coffee to have from the ingredient. | ||
|
||
|
||
### Example Usage | ||
|
||
In the Hashicups menu you can find a Packer Spiced Latter (id 1) with **40ml** of espresso (id 1) and **300ml** of semi skimmed milk (id 2). | ||
Let's pretend you want to customized it to have **50ml** of espresso and **200ml** of semi skimmed milk instead. Also, you would like | ||
to order two of that. | ||
Your packer configuration will be: | ||
|
||
```hcl | ||
source "hashicups-order" "my-custom-order" { | ||
username = "education" | ||
password = "test123" | ||
item { | ||
coffee { | ||
id = 1 | ||
name = "My Custom Packer Spiced Latter" | ||
ingredient { | ||
id = 1 | ||
quantity = 50 | ||
} | ||
ingredient { | ||
id = 2 | ||
quantity = 200 | ||
} | ||
} | ||
quantity = 2 | ||
} | ||
} | ||
build { | ||
sources = ["sources.hashicups-order.my-custom-order"] | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
description: > | ||
The coffees data source is used to | ||
fetch all the coffees ids existent in the Hashicups menu. | ||
page_title: Coffees - Data Sources | ||
sidebar_title: Coffees | ||
--- | ||
|
||
# Coffees | ||
|
||
Type: `coffees` | ||
|
||
The coffees data source is used to fetch all the coffees ids existent in the Hashicups menu. | ||
|
||
### Required | ||
|
||
- `username` (string) - The username signed up to the Product API. | ||
- `password` (string) - The password signed up to the Product API. | ||
|
||
### Optional | ||
|
||
- `host` (string) - The Product API host. Defaults to `localhost:19090` | ||
|
||
### OutPut | ||
|
||
- `map` (map[string]string) - A map of coffee name to coffee id. | ||
|
||
### Example Usage | ||
|
||
|
||
```hcl | ||
data "hashicups-coffees" "coffees" { | ||
username = "education" | ||
password = "test123" | ||
} | ||
locals { | ||
vagrante_espresso = data.hashicups-coffees.coffees.map["Vagrante espresso"] | ||
} | ||
source "hashicups-order" "my-custom-order" { | ||
username = "education" | ||
password = "test123" | ||
item { | ||
coffee { | ||
id = local.vagrante_espresso | ||
name = "my custom vagrante" | ||
ingredient { | ||
id = 1 | ||
quantity = 50 | ||
} | ||
} | ||
} | ||
} | ||
build { | ||
sources = ["sources.hashicups-order.my-custom-order"] | ||
} | ||
``` | ||
|
||
|
Oops, something went wrong.