Skip to content

hashicorp/packer-sdk-migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

packer-sdk-migrator

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.

Installation

go install github.com/hashicorp/packer-sdk-migrator
$GOBIN/packer-sdk-migrator

packer-sdk-migrator check: check eligibility for migration

Checks 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:

  • Go version used in plugin (soft requirement)
  • Whether the plugin uses Go modules
  • Version of hashicorp/packer used
  • Whether the plugin uses any hashicorp/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 SDK

Migrates 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.
  • rewrite import paths in all plugin .go files (except in vendor/) accordingly
  • run go mod tidy

If you use vendored Go dependencies, you should run go mod vendor afterwards.

About

cli tool to help plugin maintainers update from packer v1.5.0 style plugins to packer style v1.7.0 plugins

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published