-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update structure to match integrations
- Loading branch information
1 parent
7b50b93
commit ccc68a1
Showing
13 changed files
with
400 additions
and
7 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,55 @@ | ||
<!-- | ||
Include a short overview about the plugin. | ||
This document is a great location for creating a table of contents for each | ||
of the components the plugin may provide. This document should load automatically | ||
when navigating to the docs directory for a plugin. | ||
--> | ||
|
||
### 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 { | ||
name = { | ||
# source represents the GitHub URI to the plugin repository without the `packer-plugin-` prefix. | ||
source = "github.com/organization/name" | ||
version = ">=0.0.1" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Alternatively, you can use `packer plugins install` to manage installation of this plugin. | ||
|
||
```sh | ||
$ packer plugins install github.com/organization/plugin-name | ||
``` | ||
|
||
### Components | ||
|
||
The Scaffolding plugin is intended as a starting point for creating Packer plugins | ||
|
||
#### Builders | ||
|
||
- [builder](/packer/integrations/hashicorp/scaffolding/latest/components/builder/builder-name) - The scaffolding builder is used to create endless Packer | ||
plugins using a consistent plugin structure. | ||
|
||
#### Provisioners | ||
|
||
- [provisioner](/packer/integrations/hashicorp/scaffolding/latest/components/provisioner/provisioner-name) - The scaffolding provisioner is used to provisioner | ||
Packer builds. | ||
|
||
#### Post-processors | ||
|
||
- [post-processor](/packer/integrations/hashicorp/scaffolding/latest/components/post-processor/postprocessor-name) - The scaffolding post-processor is used to | ||
export scaffolding builds. | ||
|
||
#### Data Sources | ||
|
||
- [data source](/packer/integrations/hashicorp/scaffolding/latest/components/datasource/datasource-name) - The scaffolding data source is used to | ||
export scaffolding data. | ||
|
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,48 @@ | ||
Include a short description about the builder. This is a good place | ||
to call out what the builder does, and any requirements for the given | ||
builder environment. See https://www.packer.io/docs/builder/null | ||
--> | ||
|
||
The scaffolding builder is used to create endless Packer plugins using | ||
a consistent plugin structure. | ||
|
||
|
||
<!-- Builder Configuration Fields --> | ||
|
||
**Required** | ||
|
||
- `mock` (string) - The name of the mock to use for the Scaffolding API. | ||
|
||
|
||
<!-- | ||
Optional Configuration Fields | ||
Configuration options that are not required or have reasonable defaults | ||
should be listed under the optionals section. Defaults values should be | ||
noted in the description of the field | ||
--> | ||
|
||
**Optional** | ||
|
||
- `mock_api_url` (string) - The Scaffolding API endpoint to connect to. | ||
Defaults to https://example.com | ||
|
||
|
||
|
||
<!-- | ||
A basic example on the usage of the builder. Multiple examples | ||
can be provided to highlight various build configurations. | ||
--> | ||
### Example Usage | ||
|
||
|
||
```hcl | ||
source "scaffolding" "example" { | ||
mock = "bird" | ||
} | ||
build { | ||
sources = ["source.scaffolding.example"] | ||
} | ||
``` |
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,63 @@ | ||
Include a short description about the data source. This is a good place | ||
to call out what the data source does, and any requirements for the given | ||
data source environment. See https://www.packer.io/docs/data-source/amazon-ami | ||
--> | ||
|
||
The scaffolding data source is used to create endless Packer plugins using | ||
a consistent plugin structure. | ||
|
||
|
||
<!-- Data source Configuration Fields --> | ||
|
||
**Required** | ||
|
||
- `mock` (string) - The name of the mock to use for the Scaffolding API. | ||
|
||
|
||
<!-- | ||
Optional Configuration Fields | ||
Configuration options that are not required or have reasonable defaults | ||
should be listed under the optionals section. Defaults values should be | ||
noted in the description of the field | ||
--> | ||
|
||
**Optional** | ||
|
||
- `mock_api_url` (string) - The Scaffolding API endpoint to connect to. | ||
Defaults to https://example.com | ||
|
||
|
||
|
||
<!-- | ||
A basic example on the usage of the data source. Multiple examples | ||
can be provided to highlight various build configurations. | ||
--> | ||
|
||
### OutPut | ||
|
||
- `foo` (string) - The Scaffolding output foo value. | ||
- `bar` (string) - The Scaffolding output bar value. | ||
|
||
<!-- | ||
A basic example on the usage of the data source. Multiple examples | ||
can be provided to highlight various build configurations. | ||
--> | ||
|
||
### Example Usage | ||
|
||
|
||
```hcl | ||
data "scaffolding" "example" { | ||
mock = "bird" | ||
} | ||
source "scaffolding" "example" { | ||
mock = data.scaffolding.example.foo | ||
} | ||
build { | ||
sources = ["source.scaffolding.example"] | ||
} | ||
``` |
46 changes: 46 additions & 0 deletions
46
.web-docs/components/post-processor/post-processor/README.md
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 @@ | ||
Include a short description about the post-processor. This is a good place | ||
to call out what the post-processor does, and any additional text that might | ||
be helpful to a user. See https://www.packer.io/docs/provisioner/null | ||
--> | ||
|
||
The scaffolding post-processor is used to export Packer Scaffolding builds. | ||
|
||
|
||
<!-- Post-Processor Configuration Fields --> | ||
|
||
**Required** | ||
|
||
- `mock` (string) - The output path where to save exported build to. | ||
|
||
<!-- | ||
Optional Configuration Fields | ||
Configuration options that are not required or have reasonable defaults | ||
should be listed under the optionals section. Defaults values should be | ||
noted in the description of the field | ||
--> | ||
|
||
**Optional** | ||
|
||
|
||
<!-- | ||
A basic example on the usage of the post-processor. Multiple examples | ||
can be provided to highlight various configurations. | ||
--> | ||
### Example Usage | ||
|
||
|
||
```hcl | ||
source "scaffolding" "example" { | ||
mock = "jay" | ||
} | ||
build { | ||
sources = ["source.scaffolding.example"] | ||
post-processor "scaffolding" { | ||
mock = "builds/scaffolding.box" | ||
} | ||
} | ||
``` |
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 @@ | ||
Include a short description about the provisioner. This is a good place | ||
to call out what the provisioner does, and any additional text that might | ||
be helpful to a user. See https://www.packer.io/docs/provisioner/null | ||
--> | ||
|
||
The scaffolding provisioner is used to provisioner Packer builds. | ||
|
||
|
||
<!-- Provisioner Configuration Fields --> | ||
|
||
**Required** | ||
|
||
- `mock` (string) - The name of the mock string to display. | ||
|
||
|
||
<!-- | ||
Optional Configuration Fields | ||
Configuration options that are not required or have reasonable defaults | ||
should be listed under the optionals section. Defaults values should be | ||
noted in the description of the field | ||
--> | ||
|
||
**Optional** | ||
|
||
|
||
<!-- | ||
A basic example on the usage of the provisioner. Multiple examples | ||
can be provided to highlight various configurations. | ||
--> | ||
### Example Usage | ||
|
||
|
||
```hcl | ||
source "null" "example" { | ||
communicator = "none" | ||
} | ||
build { | ||
source "null.example" { | ||
name = "jay" | ||
} | ||
provisioner "scaffolding" { | ||
mock = "mocking ${source.name}" | ||
} | ||
} | ||
``` |
File renamed without changes.
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,132 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
|
||
# Converts the folder name that the component documentation file | ||
# is stored in into the integration slug of the component. | ||
componentTypeFromFolderName() { | ||
if [[ "$1" = "builders" ]]; then | ||
echo "builder" | ||
elif [[ "$1" = "provisioners" ]]; then | ||
echo "provisioner" | ||
elif [[ "$1" = "post-processors" ]]; then | ||
echo "post-processor" | ||
elif [[ "$1" = "datasources" ]]; then | ||
echo "data-source" | ||
else | ||
echo "" | ||
fi | ||
} | ||
|
||
# $1: The content to adjust links | ||
# $2: The organization of the integration | ||
rewriteLinks() { | ||
local result="$1" | ||
local organization="$2" | ||
|
||
urlSegment="([^/]+)" | ||
urlAnchor="(#[^/]+)" | ||
|
||
# Rewrite Component Index Page links to the Integration root page. | ||
# | ||
# (\1) (\2) (\3) | ||
# /packer/plugins/datasources/amazon#anchor-tag--> | ||
# /packer/integrations/hashicorp/amazon#anchor-tag | ||
local find="\(\/packer\/plugins\/$urlSegment\/$urlSegment$urlAnchor?\)" | ||
local replace="\(\/packer\/integrations\/$organization\/\2\3\)" | ||
result="$(echo "$result" | sed -E "s/$find/$replace/g")" | ||
|
||
|
||
# Rewrite Component links to the Integration component page | ||
# | ||
# (\1) (\2) (\3) (\4) | ||
# /packer/plugins/datasources/amazon/parameterstore#anchor-tag --> | ||
# /packer/integrations/{organization}/amazon/latest/components/datasources/parameterstore | ||
local find="\(\/packer\/plugins\/$urlSegment\/$urlSegment\/$urlSegment$urlAnchor?\)" | ||
local replace="\(\/packer\/integrations\/$organization\/\2\/latest\/components\/\1\/\3\4\)" | ||
result="$(echo "$result" | sed -E "s/$find/$replace/g")" | ||
|
||
# Rewrite the Component URL segment from the Packer Plugin format | ||
# to the Integrations format | ||
result="$(echo "$result" \ | ||
| sed "s/\/datasources\//\/data-source\//g" \ | ||
| sed "s/\/builders\//\/builder\//g" \ | ||
| sed "s/\/post-processors\//\/post-processor\//g" \ | ||
| sed "s/\/provisioners\//\/provisioner\//g" \ | ||
)" | ||
|
||
echo "$result" | ||
} | ||
|
||
# $1: Docs Dir | ||
# $2: Web Docs Dir | ||
# $3: Component File | ||
# $4: The org of the integration | ||
processComponentFile() { | ||
local docsDir="$1" | ||
local webDocsDir="$2" | ||
local componentFile="$3" | ||
|
||
local escapedDocsDir="$(echo "$docsDir" | sed 's/\//\\\//g' | sed 's/\./\\\./g')" | ||
local componentTypeAndSlug="$(echo "$componentFile" | sed "s/$escapedDocsDir\///g" | sed 's/\.mdx//g')" | ||
|
||
# Parse out the Component Slug & Component Type | ||
local componentSlug="$(echo "$componentTypeAndSlug" | cut -d'/' -f 2)" | ||
local componentType="$(componentTypeFromFolderName "$(echo "$componentTypeAndSlug" | cut -d'/' -f 1)")" | ||
if [[ "$componentType" = "" ]]; then | ||
echo "Failed to process '$componentFile', unexpected folder name." | ||
echo "Documentation for components must be stored in one of:" | ||
echo "builders, provisioners, post-processors, datasources" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Calculate the location of where this file will ultimately go | ||
local webDocsFolder="$webDocsDir/components/$componentType/$componentSlug" | ||
mkdir -p "$webDocsFolder" | ||
local webDocsFile="$webDocsFolder/README.md" | ||
local webDocsFileTmp="$webDocsFolder/README.md.tmp" | ||
|
||
# Copy over the file to its webDocsFile location | ||
cp "$componentFile" "$webDocsFile" | ||
|
||
# Remove the Header | ||
local lastMetadataLine="$(grep -n -m 2 '^\-\-\-' "$componentFile" | tail -n1 | cut -d':' -f1)" | ||
cat "$webDocsFile" | tail -n +"$(($lastMetadataLine+2))" > "$webDocsFileTmp" | ||
mv "$webDocsFileTmp" "$webDocsFile" | ||
|
||
# Remove the top H1, as this will be added automatically on the web | ||
cat "$webDocsFile" | tail -n +3 > "$webDocsFileTmp" | ||
mv "$webDocsFileTmp" "$webDocsFile" | ||
|
||
# Rewrite Links | ||
rewriteLinks "$(cat "$webDocsFile")" "$4" > "$webDocsFileTmp" | ||
mv "$webDocsFileTmp" "$webDocsFile" | ||
} | ||
|
||
# Compiles the Packer SDC compiled docs folder down | ||
# to a integrations-compliant folder (web docs) | ||
# | ||
# $1: The directory of the plugin | ||
# $2: The directory of the SDC compiled docs files | ||
# $3: The output directory to place the web-docs files | ||
# $4: The org of the integration | ||
compileWebDocs() { | ||
local docsDir="$1/$2" | ||
local webDocsDir="$1/$3" | ||
|
||
echo "Compiling MDX docs in '$2' to Markdown in '$3'..." | ||
# Create the web-docs directory if it hasn't already been created | ||
mkdir -p "$webDocsDir" | ||
|
||
# Copy the README over | ||
cp "$docsDir/README.md" "$webDocsDir/README.md" | ||
|
||
# Process all MDX component files (exclude index files, which are unsupported) | ||
for file in $(find "$docsDir" | grep "$docsDir/.*/.*\.mdx" | grep --invert-match "index.mdx"); do | ||
processComponentFile "$docsDir" "$webDocsDir" "$file" "$4" | ||
done | ||
} | ||
|
||
compileWebDocs "$1" "$2" "$3" "$4" |
Oops, something went wrong.