|
1 | | -# Packer Plugin Scaffolding |
| 1 | +# Packer Plugin Tencentcloud |
| 2 | +The `Tencentcloud` multi-component plugin can be used with HashiCorp [Packer](https://www.packer.io) |
| 3 | +to create custom images. For the full list of available features for this plugin see [docs](docs). |
2 | 4 |
|
3 | | -This repository is a template for a Packer multi-component plugin. It is intended as a starting point for creating Packer plugins, containing: |
4 | | -- A builder ([builder/scaffolding](builder/scaffolding)) |
5 | | -- A provisioner ([provisioner/scaffolding](provisioner/scaffolding)) |
6 | | -- A post-processor ([post-processor/scaffolding](provisioner/scaffolding)) |
7 | | -- A data source ([datasource/scaffolding](datasource/scaffolding)) |
8 | | -- Docs ([docs](docs)) |
9 | | -- A working example ([example](example)) |
| 5 | +## Installation |
10 | 6 |
|
11 | | -These folders contain boilerplate code that you will need to edit to create your own Packer multi-component plugin. |
12 | | -A full guide to creating Packer plugins can be found at [Extending Packer](https://www.packer.io/docs/plugins/creation). |
| 7 | +### Using pre-built releases |
13 | 8 |
|
14 | | -In this repository you will also find a pre-defined GitHub Action configuration for the release workflow |
15 | | -(`.goreleaser.yml` and `.github/workflows/release.yml`). The release workflow configuration makes sure the GitHub |
16 | | -release artifacts are created with the correct binaries and naming conventions. |
| 9 | +#### Using the `packer init` command |
17 | 10 |
|
18 | | -Please see the [GitHub template repository documentation](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) |
19 | | -for how to create a new repository from this template on GitHub. |
| 11 | +Starting from version 1.7, Packer supports a new `packer init` command allowing |
| 12 | +automatic installation of Packer plugins. Read the |
| 13 | +[Packer documentation](https://www.packer.io/docs/commands/init) for more information. |
20 | 14 |
|
21 | | -## Packer plugin projects |
| 15 | +To install this plugin, copy and paste this code into your Packer configuration . |
| 16 | +Then, run [`packer init`](https://www.packer.io/docs/commands/init). |
22 | 17 |
|
23 | | -Here's a non exaustive list of Packer plugins that you can checkout: |
24 | | - |
25 | | -* [github.com/hashicorp/packer-plugin-docker](https://github.com/hashicorp/packer-plugin-docker) |
26 | | -* [github.com/exoscale/packer-plugin-exoscale](https://github.com/exoscale/packer-plugin-exoscale) |
27 | | -* [github.com/sylviamoss/packer-plugin-comment](https://github.com/sylviamoss/packer-plugin-comment) |
28 | | -* [github.com/hashicorp/packer-plugin-hashicups](https://github.com/hashicorp/packer-plugin-hashicups) |
29 | | - |
30 | | -Looking at their code will give you good examples. |
31 | | - |
32 | | -## Running Acceptance Tests |
33 | | - |
34 | | -Make sure to install the plugin with `go build .` and to have Packer installed locally. |
35 | | -Then source the built binary to the plugin path with `cp packer-plugin-scaffolding ~/.packer.d/plugins/packer-plugin-scaffolding` |
36 | | -Once everything needed is set up, run: |
37 | | -``` |
38 | | -PACKER_ACC=1 go test -count 1 -v ./... -timeout=120m |
| 18 | +```hcl |
| 19 | +packer { |
| 20 | + required_plugins { |
| 21 | + tencentcloud = { |
| 22 | + version = ">= 0.0.1" |
| 23 | + source = "github.com/hashicorp/tencentcloud" |
| 24 | + } |
| 25 | + } |
| 26 | +} |
39 | 27 | ``` |
40 | 28 |
|
41 | | -This will run the acceptance tests for all plugins in this set. |
42 | | - |
43 | | -## Test Plugin Example Action |
44 | 29 |
|
45 | | -This scaffolding configures a [manually triggered plugin test action](/.github/workflows/test-plugin-example.yml). |
46 | | -By default, the action will run Packer at the latest version to init, validate, and build the example configuration |
47 | | -within the [example](example) folder. This is useful to quickly test a basic template of your plugin against Packer. |
| 30 | +#### Manual installation |
48 | 31 |
|
49 | | -The example must contain the `required_plugins` block and require your plugin at the latest or any other released version. |
50 | | -This will help test and validate plugin releases. |
| 32 | +You can find pre-built binary releases of the plugin [here](https://github.com/hashicorp/packer-plugin-tencentcloud/releases). |
| 33 | +Once you have downloaded the latest archive corresponding to your target OS, |
| 34 | +uncompress it to retrieve the plugin binary file corresponding to your platform. |
| 35 | +To install the plugin, please follow the Packer documentation on |
| 36 | +[installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins). |
51 | 37 |
|
52 | | -## Registering Documentation on Packer.io |
53 | 38 |
|
54 | | -Documentation for a plugin is maintained within the `docs` directory and served on GitHub. |
55 | | -To include plugin docs on Packer.io a global pre-hook has been added to the main scaffolding .goreleaser.yml file, that if uncommented will generate and include a docs.zip file as part of the plugin release. |
| 39 | +### From Sources |
56 | 40 |
|
57 | | -The `docs.zip` file will contain all of the `.mdx` files under the plugins root `docs/` directory that can be consumed remotely by Packer.io. |
| 41 | +If you prefer to build the plugin from sources, clone the GitHub repository |
| 42 | +locally and run the command `go build` from the root |
| 43 | +directory. Upon successful compilation, a `packer-plugin-tencentcloud` plugin |
| 44 | +binary file can be found in the root directory. |
| 45 | +To install the compiled plugin, please follow the official Packer documentation |
| 46 | +on [installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins). |
58 | 47 |
|
59 | | -Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs. |
60 | | -This is done by adding the block below for the respective plugin to the file [website/data/docs-remote-navigation.js](https://github.com/hashicorp/packer/blob/master/website/data/docs-remote-plugins.json). |
61 | 48 |
|
62 | | -```json |
63 | | -{ |
64 | | - "title": "Scaffolding", |
65 | | - "path": "scaffolding", |
66 | | - "repo": "hashicorp/packer-plugin-scaffolding", |
67 | | - "version": "latest", |
68 | | - "sourceBranch": "main" |
69 | | - } |
70 | | -``` |
71 | | - |
72 | | -If a plugin maintainer wishes to only include a specific version of released docs then the `"version"` key in the above configuration should be set to a released version of the plugin. Otherwise it should be set to `"latest"`. |
73 | | - |
74 | | -The `"sourceBranch"` key in the above configuration ensures potential contributors can link back to source files in the plugin repository from the Packer docs site. If a `"sourceBranch"` value is not present, it will default to `"main"`. |
75 | | - |
76 | | -The documentation structure needed for Packer.io can be generated manually, by creating a simple zip file called `docs.zip` of the docs directory and included in the plugin release. |
77 | | - |
78 | | -```/bin/bash |
79 | | -[[ -d docs/ ]] && zip -r docs.zip docs/ |
80 | | -``` |
| 49 | +### Configuration |
81 | 50 |
|
82 | | -Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs. |
| 51 | +For more information on how to configure the plugin, please read the |
| 52 | +documentation located in the [`docs/`](docs) directory. |
83 | 53 |
|
84 | | -# Requirements |
85 | 54 |
|
86 | | -- [packer-plugin-sdk](https://github.com/hashicorp/packer-plugin-sdk) >= v0.1.0 |
87 | | -- [Go](https://golang.org/doc/install) >= 1.16 |
| 55 | +## Contributing |
88 | 56 |
|
89 | | -## Packer Compatibility |
90 | | -This scaffolding template is compatible with Packer >= v1.7.0 |
| 57 | +* If you think you've found a bug in the code or you have a question regarding |
| 58 | + the usage of this software, please reach out to us by opening an issue in |
| 59 | + this GitHub repository. |
| 60 | +* Contributions to this project are welcome: if you want to add a feature or a |
| 61 | + fix a bug, please do so by opening a Pull Request in this GitHub repository. |
| 62 | + In case of feature contribution, we kindly ask you to open an issue to |
| 63 | + discuss it beforehand. |
0 commit comments