Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Quick start repository for creating a Packer plugin.

License

NotificationsYou must be signed in to change notification settings

QubitPi/packer-plugin-scaffolding

 
 

Repository files navigation

This repository is a template for a Packer multi-component plugin. It is intended as a starting point for creating Packer plugins, containing:

These folders contain boilerplate code that you will need to edit to create your own Packer multi-component plugin.A full guide to creating Packer plugins can be found atExtending Packer.

In this repository you will also find a pre-defined GitHub Action configuration for the release workflow(.goreleaser.yml and.github/workflows/release.yml). The release workflow configuration makes sure the GitHubrelease artifacts are created with the correct binaries and naming conventions.

Please see theGitHub template repository documentationfor how to create a new repository from this template on GitHub.

Packer plugin projects

Here's a non exaustive list of Packer plugins that you can checkout:

Looking at their code will give you good examples.

Setup

The Go Workspace

Go expects a single workspace for third-party Go tools installed viago install. By default, this workspace is locatedin$HOME/go with source code for these tools stored in$HOME/go/src and the compiled binaries in$HOME/go/bin. Set$GOPATH environment variable to this path first:

export GOPATH=$HOME/goexport PATH=$PATH:$GOPATH/bin

Build from source

  1. Clone this GitHub repository locally.

  2. Run this command from the root directory:

go build -ldflags="-X github.com/hashicorp/packer-plugin-scaffolding/version.VersionPrerelease=dev" -o packer-plugin-scaffolding
  1. After you successfully compile, thepacker-plugin-scaffolding plugin binary file is in the root directory.

  2. To install the compiled plugin, run the following command

packer plugins install --path packer-plugin-scaffolding github.com/hashicorp/scaffolding

Tip

If executing thepacker plugins install reports an error, please make sure the version ofpacker command is thelatest. To upgrade to the latest version, please refer toPacker's documentation

Build on *nix systems

Unix like systems with the make, sed, and grep commands installed can use themake dev to execute the build from source steps.

Build on Windows Powershell

The preferred solution for building on Windows are steps 2-4 listed above.If you would prefer to script the building process you can use the following as a guide

$MODULE_NAME= (Get-Content go.mod|Where-Object {$_-match"^module"  })-replace'module',''$FQN=$MODULE_NAME-replace'packer-plugin-',''go build-ldflags="-X$MODULE_NAME/version.VersionPrerelease=dev"-opacker-plugin-scaffolding.exepacker plugins install--pathpacker-plugin-scaffolding.exe$FQN

Running Acceptance Tests

Make sure to install the plugin locally using the steps inBuild from source.

Once everything needed is set up, run:

PACKER_ACC=1 go test -count 1 -v ./... -timeout=120m

This will run the acceptance tests for all plugins in this set.

Caution

Please make sure the acceptance tests are running against the local version by deleting all previously installedversions under$HOME/. config/packer/plugins directory. Otherwise, the tests will pick up the old released versionif they were installed before. Deletinggithub.com/QubitPi/hashicorp-aws, for example, would be

rm -rf ~/.config/packer/plugins/github.com/QubitPi/hashicorp-aws

Registering Plugin as Packer Integration

Partner and community plugins can be hard to find if a user doesn't know whatthey are looking for. To assist with plugin discovery Packer offers an integrationportal athttps://developer.hashicorp.com/packer/integrations to list known integrationsthat work with the latest release of Packer.

Registering a plugin as an integration requiresmetadata configuration within the pluginrepository and approval by the Packer team. To initiate the process of registering yourplugin as a Packer integration refer to theDeveloping Plugins page.

Requirements

Packer Compatibility

This scaffolding template is compatible with Packer >= v1.11.0

About

Quick start repository for creating a Packer plugin.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go60.1%
  • HCL18.0%
  • Shell17.7%
  • Makefile4.2%

[8]ページ先頭

©2009-2025 Movatter.jp