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.
docs: Upgrade plugin to integrations framework
- Loading branch information
Showing
18 changed files
with
690 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Ensure Docs are Compiled | ||
on: | ||
push: | ||
jobs: | ||
ensure-docs-compiled: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎 | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | ||
- shell: bash | ||
run: make build-docs | ||
- shell: bash | ||
run: | | ||
if [[ -z "$(git status -s)" ]]; then | ||
echo "OK" | ||
else | ||
echo "Docs have been updated, but the compiled docs have not been committed." | ||
echo "Run 'make build-docs', and commit the result to resolve this error." | ||
exit 1 | ||
fi | ||
46 changes: 46 additions & 0 deletions
46
.github/workflows/notify-integration-release-via-manual.yaml
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,46 @@ | ||
name: Notify Integration Release (Manual) | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The release version (semver)" | ||
default: 0.0.1 | ||
required: false | ||
branch: | ||
description: "A branch or SHA" | ||
default: 'main' | ||
required: false | ||
jobs: | ||
notify-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
# Ensure that Docs are Compiled | ||
- uses: actions/setup-go@v4 | ||
- shell: bash | ||
run: make build-docs | ||
- shell: bash | ||
run: | | ||
if [[ -z "$(git status -s)" ]]; then | ||
echo "OK" | ||
else | ||
echo "Docs have been updated, but the compiled docs have not been committed." | ||
echo "Run 'make build-docs', and commit the result to resolve this error." | ||
exit 1 | ||
fi | ||
# Perform the Release | ||
- name: Checkout integration-release-action | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
repository: hashicorp/integration-release-action | ||
path: ./integration-release-action | ||
- name: Notify Release | ||
uses: ./integration-release-action | ||
with: | ||
integration_identifier: 'packer/hashicorp/hashicups' | ||
release_version: ${{ github.event.inputs.version }} | ||
release_sha: ${{ github.event.inputs.branch }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
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,40 @@ | ||
name: Notify Integration Release (Tag) | ||
on: | ||
push: | ||
tags: | ||
- '*.*.*' # Proper releases | ||
- '*.*.*-*' # Pre releases | ||
jobs: | ||
notify-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
ref: ${{ github.ref }} | ||
# Ensure that Docs are Compiled | ||
- uses: actions/setup-go@v4 | ||
- shell: bash | ||
run: make build-docs | ||
- shell: bash | ||
run: | | ||
if [[ -z "$(git status -s)" ]]; then | ||
echo "OK" | ||
else | ||
echo "Docs have been updated, but the compiled docs have not been committed." | ||
echo "Run 'make build-docs', and commit the result to resolve this error." | ||
exit 1 | ||
fi | ||
# Perform the Release | ||
- name: Checkout integration-release-action | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
repository: hashicorp/integration-release-action | ||
path: ./integration-release-action | ||
- name: Notify Release | ||
uses: ./integration-release-action | ||
with: | ||
integration_identifier: 'packer/hashicorp/hashicups' | ||
release_version: ${{ github.ref_name }} | ||
release_sha: ${{ github.ref }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
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,77 @@ | ||
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. | ||
|
||
### Installation | ||
|
||
To install this plugin, copy and paste this code into your Packer configuration, then run [`packer init`](https://www.packer.io/docs/commands/init). | ||
|
||
```hcl | ||
packer { | ||
required_plugins { | ||
hashicups = { | ||
source = "github.com/hashicorp/hashicups" | ||
version = "~> 1" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Alternatively, you can use `packer plugins install` to manage installation of this plugin. | ||
|
||
```sh | ||
$ packer plugins install github.com/hashicorp/hashicups | ||
``` | ||
|
||
### Components | ||
|
||
#### Builders | ||
|
||
- [Order builder](/packer/integrations/hashicorp/hashicups/latest/components/builder/order) - The order builder is used to create custom HashiCups order. | ||
|
||
#### Provisioners | ||
|
||
- [Toppings provisioner](/packer/integrations/hashicorp/hashicups/latest/components/provisioner/toppings) - The toppings provisioner is used to add toppings to your order coffee(s). | ||
|
||
#### Post-processors | ||
|
||
- [Receipt post-processor](/packer/integrations/hashicorp/hashicups/latest/components/post-processor/receipt) - The receipt post-processor is used to | ||
print the receipt of your order. | ||
|
||
#### Data Sources | ||
|
||
- [Coffees data source](/packer/integrations/hashicorp/hashicups/latest/components/data-source/coffees) - The coffees data source is used to | ||
fetch all the coffees ids existent in the HashiCups menu. | ||
|
||
- [Ingredients data source](/packer/integrations/hashicorp/hashicups/latest/components/data-source/ingredients) - 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, sign-in with previously created account: | ||
```shell | ||
$ curl -X POST localhost:19090/signin -d '{"username":"education", "password":"test123"}' | ||
``` | ||
|
||
Then, export the returned 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 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,89 @@ | ||
Type: `hashicups-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 | ||
|
||
<!-- Code generated from the comments of the AuthConfig struct in common/auth.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `username` (string) - The username signed up to the Product API. | ||
|
||
- `password` (string) - The password for the username signed up to the Product API. | ||
|
||
<!-- End of code generated from the comments of the AuthConfig struct in common/auth.go; --> | ||
|
||
|
||
- `item` ([]OrderItem) - An item you would like to order. See the [order item configuration](#order-item-configuration). | ||
|
||
## Optional | ||
|
||
<!-- Code generated from the comments of the AuthConfig struct in common/auth.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `host` (string) - The Product API host URL. Defaults to `localhost:19090` | ||
|
||
<!-- End of code generated from the comments of the AuthConfig struct in common/auth.go; --> | ||
|
||
|
||
## 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,61 @@ | ||
Type: `hashicups-coffees` | ||
|
||
The coffees data source is used to fetch all the coffees ids existent in the HashiCups menu. | ||
|
||
## Required | ||
|
||
<!-- Code generated from the comments of the AuthConfig struct in common/auth.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `username` (string) - The username signed up to the Product API. | ||
|
||
- `password` (string) - The password for the username signed up to the Product API. | ||
|
||
<!-- End of code generated from the comments of the AuthConfig struct in common/auth.go; --> | ||
|
||
|
||
## Optional | ||
|
||
<!-- Code generated from the comments of the AuthConfig struct in common/auth.go; DO NOT EDIT MANUALLY --> | ||
|
||
- `host` (string) - The Product API host URL. Defaults to `localhost:19090` | ||
|
||
<!-- End of code generated from the comments of the AuthConfig struct in common/auth.go; --> | ||
|
||
|
||
## 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.