The Packer plugin plugin SDK, previously part of the github.com/hashicorp/packer "Core" Go module, has been moved to a new Go module, github.com/hashicorp/packer-plugin-sdk. Packer plugins should now import hashicorp/packer-plugin-sdk
.
packer-sdk-migrator
is a CLI tool which will migrate a Packer plugin to the new SDK module by rewriting import paths. packer-sdk-migrator check
checks the eligibility of the plugin for migration.
go install github.com/hashicorp/packer-sdk-migrator
$GOBIN/packer-sdk-migrator
packer-sdk-migrator check
: check eligibility for migrationChecks whether a Packer plugin is ready to migrate to the newly extracted Packer SDK package.
packer-sdk-migrator check [PATH] [--help]
Outputs a report containing:
hashicorp/packer
usedhashicorp/packer
packages that are not in hashicorp/packer-plugin-sdk
Exits 0 if the plugin meets all the hard requirements, 1 otherwise.
The Go version requirement is a "soft" requirement: it is strongly recommended to upgrade to Go version 1.12+ before migrating to the new SDK, but the migration can still be performed if this requirement is not met.
packer-sdk-migrator migrate
: migrate to standalone SDKMigrates the Packer plugin to the new extracted SDK (github.com/hashicorp/packer-plugin-sdk
), replacing references to the old SDK (github.com/hashicorp/packer
).
Note: No backup is made before modifying files. Please make sure your VCS staging area is clean.
packer-sdk-migrator migrate [PATH] [-help]
The eligibility check will be run first: migration will not proceed if this check fails.
The migration tool will then make the following changes:
go.mod
: replace github.com/hashicorp/packer
dependencies with their corresponding github.com/hashicorp/packer-plugin-sdk
references. The SDK was refactored during the extraction process, so this will not always be a direct one-to-one string replacement, though it will be in some cases. Please report any issues you find so we can update our upgrade mapping..go
files (except in vendor/
) accordinglygo mod tidy
If you use vendored Go dependencies, you should run go mod vendor
afterwards.