From 21b37d4f8a202eeba867647eb5f5907376ecdb52 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 13 Jan 2021 12:13:41 -0800 Subject: [PATCH 1/3] Co-authored-by: Sylvia Moss Co-authored-by: Wilken Rivera Review comments --- .../content/guides/1.7-plugin-upgrade/index.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/website/content/guides/1.7-plugin-upgrade/index.mdx b/website/content/guides/1.7-plugin-upgrade/index.mdx index 09a1aa2b9..a37e71fc7 100644 --- a/website/content/guides/1.7-plugin-upgrade/index.mdx +++ b/website/content/guides/1.7-plugin-upgrade/index.mdx @@ -15,13 +15,13 @@ Packer is currently backwards compatible with the old API because the plugin API ### How to update plugins to use the packer-plugin-SDK -In a best-case scenario, all you'll have to do is replace all the places you import +In a best-case scenario, all you'll have to do is update the packer imports to use the packer-plugin-sdk import path github.com/hashicorp/packer with github.com/hashicorp/packer-plugin-sdk. -But some of the import paths have changed more than that because we've refactored the SDK some to make it easier to discover and use helpful modules. Here are a few common paths below: +But some of the import paths have changed more than that because we've refactored the SDK some to make it easier to discover and use helpful modules. Below are a few common import paths. For a full list of available imports see [Packer Plugin SDK Docs](https://pkg.go.dev/github.com/hashicorp/packer-plugin-sdk/)``` -github.com/hashicorp/packer-plugin-sdk/template/config => github.com/hashicorp/packer-plugin-sdk/template/config +github.com/hashicorp/packer/template/config => github.com/hashicorp/packer-plugin-sdk/template/config github.com/hashicorp/packer/packer => github.com/hashicorp/packer-plugin-sdk/packer github.com/hashicorp/packer/template/interpolate => github.com/hashicorp/packer-plugin-sdk/template/interpolate @@ -63,7 +63,7 @@ github.com/hashicorp/packer/common/uuid => github.com/hashicorp/packer-plugin-sd **new** github.com/hashicorp/packer-plugin-sdk/version -When in doubt you can search the packer-plugin-sdk repo for the name of your imported structs or functions to see where they exist in the sdk now; we have not changed struct or function names. +When in doubt you can search the packer-plugin-sdk repo for the name of your imported structs or functions to see where they exist in the SDK now; we have not changed struct or function names. Or refer to the [Packer Plugin SDK Docs](https://pkg.go.dev/github.com/hashicorp/packer-plugin-sdk/) for help. ## Upgrade plugins to use new multi-plugin rpc server @@ -73,13 +73,13 @@ The goal of this server is to enable multiple related plugins, for example plugi ### Do I have to upgrade? -For now, you do to have to upgrade your plugin. Packer will continue to understand how to discover and launch old-style plugins. However, you will not be able to register your plugin with HashiCorp until you have upgraded the plugin. +For now, you do not have to upgrade your plugin, but we recommend doing it. Packer will continue to understand how to discover and launch old-style plugins. However, you will not be able to register your plugin with HashiCorp until you have upgraded the plugin. ### How to upgrade the plugin -We've created a scaffolding repository over at https://github.com/hashicorp/packer-plugin-scaffolding/tree/main/builder/scaffolding +We've created a scaffolding repository over at https://github.com/hashicorp/packer-plugin-scaffolding/ -If you already have a working plugin, this should look pretty familiar. You'll notice that there are some changes to main.go. +If you already have a working plugin, the [builder plugin scaffolding](https://github.com/hashicorp/packer-plugin-scaffolding/tree/main/builder/scaffolding) should look pretty familiar. You'll notice that there are some changes to main.go. Previously, you may have had a main.go that looks something like: @@ -179,4 +179,4 @@ And then reference your plugin in the Packer template using "vsphere-iso" and "v You can still use the `DEFAULT_NAME` constant with a set implementation; in this example, whatever you register with the DEFAULT_NAME will be referenced in the Packer template as "vsphere". You can only register one plugin per plugin set using the DEFAULT_NAME -We will soon write a follow-up guide explaining how to register you new plugin set with HashiCorp. \ No newline at end of file +We will soon write a follow-up guide explaining how to register you new plugin set with HashiCorp. From f43bb2f0c646f7e60e6ae59b900c7732b2f66435 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 13 Jan 2021 13:05:22 -0800 Subject: [PATCH 2/3] make table from import changes --- .../guides/1.7-plugin-upgrade/index.mdx | 78 ++++++++++--------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/website/content/guides/1.7-plugin-upgrade/index.mdx b/website/content/guides/1.7-plugin-upgrade/index.mdx index a37e71fc7..2c777b509 100644 --- a/website/content/guides/1.7-plugin-upgrade/index.mdx +++ b/website/content/guides/1.7-plugin-upgrade/index.mdx @@ -21,46 +21,50 @@ github.com/hashicorp/packer with github.com/hashicorp/packer-plugin-sdk. But some of the import paths have changed more than that because we've refactored the SDK some to make it easier to discover and use helpful modules. Below are a few common import paths. For a full list of available imports see [Packer Plugin SDK Docs](https://pkg.go.dev/github.com/hashicorp/packer-plugin-sdk/)``` -github.com/hashicorp/packer/template/config => github.com/hashicorp/packer-plugin-sdk/template/config -github.com/hashicorp/packer/packer => github.com/hashicorp/packer-plugin-sdk/packer -github.com/hashicorp/packer/template/interpolate => github.com/hashicorp/packer-plugin-sdk/template/interpolate +| Old Path | New Path | +| ---------| -------- | +| github.com/hashicorp/packer/template/config | github.com/hashicorp/packer-plugin-sdk/template/config | +| github.com/hashicorp/packer/packer | github.com/hashicorp/packer-plugin-sdk/packer | +| github.com/hashicorp/packer/template/interpolate | github.com/hashicorp/packer-plugin-sdk/template/interpolate | Here is a more comprehensive list of old imports and their new replacements: -github.com/hashicorp/packer/helper/builder/testing => github.com/hashicorp/packer-plugin-sdk/acctest -**new** github.com/hashicorp/packer-plugin-sdk/acctest/provisioneracc -github.com/hashicorp/packer/helper/tests => github.com/hashicorp/packer-plugin-sdk/acctest/testutils -github.com/hashicorp/packer/common/adapter => github.com/hashicorp/packer-plugin-sdk/adapter -github.com/hashicorp/packer/common/bootcommand => github.com/hashicorp/packer-plugin-sdk/bootcommand -github.com/hashicorp/packer/common/chroot => github.com/hashicorp/packer-plugin-sdk/chroot -github.com/hashicorp/packer/common => github.com/hashicorp/packer-plugin-sdk/common -github.com/hashicorp/packer/helper/communicator => github.com/hashicorp/packer-plugin-sdk/communicator -github.com/hashicorp/packer/helper/config => github.com/hashicorp/packer-plugin-sdk/template/config -github.com/hashicorp/packer/template/interpolate => github.com/hashicorp/packer-plugin-sdk/template/interpolate -github.com/hashicorp/packer/communicator/ssh => github.com/hashicorp/packer-plugin-sdk/communicator/ssh -github.com/hashicorp/packer/helper/communicator/sshkey => github.com/hashicorp/packer-plugin-sdk/communicator/sshkey -github.com/hashicorp/packer/provisioner => github.com/hashicorp/packer-plugin-sdk/guestexec -github.com/hashicorp/packer/common/json => github.com/hashicorp/packer-plugin-sdk/json -github.com/hashicorp/packer/helper/multistep => github.com/hashicorp/packer-plugin-sdk/multistep -steps from github.com/hashicorp/packer/common => github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps -github.com/hashicorp/packer/common/net => github.com/hashicorp/packer-plugin-sdk/net -github.com/hashicorp/packer/packer => github.com/hashicorp/packer-plugin-sdk/packer -github.com/hashicorp/packer/builder => github.com/hashicorp/packer-plugin-sdk/packerbuilderdata -github.com/hashicorp/packer/packer => github.com/hashicorp/packer-plugin-sdk/pathing -github.com/hashicorp/packer/packer/plugin => github.com/hashicorp/packer-plugin-sdk/plugin -github.com/hashicorp/packer/common/random => github.com/hashicorp/packer-plugin-sdk/random -github.com/hashicorp/packer/common => github.com/hashicorp/packer-plugin-sdk/retry -github.com/hashicorp/packer/packer/rpc => github.com/hashicorp/packer-plugin-sdk/rpc -github.com/hashicorp/packer/communicator => github.com/hashicorp/packer-plugin-sdk/sdk-internals/communicator -github.com/hashicorp/packer/common/shell => github.com/hashicorp/packer-plugin-sdk/shell -github.com/hashicorp/packer/common/shell-local => github.com/hashicorp/packer-plugin-sdk/shell-local -github.com/hashicorp/packer/helper/builder/localexec => github.com/hashicorp/packer-plugin-sdk/shell-local/localexec -github.com/hashicorp/packer/common/shutdowncommand => github.com/hashicorp/packer-plugin-sdk/shutdowncommand -github.com/hashicorp/packer/template => github.com/hashicorp/packer-plugin-sdk/template -github.com/hashicorp/packer/packer/tmp => github.com/hashicorp/packer-plugin-sdk/tmp -github.com/hashicorp/packer/helper/useragent => github.com/hashicorp/packer-plugin-sdk/useragent -github.com/hashicorp/packer/common/uuid => github.com/hashicorp/packer-plugin-sdk/uuid -**new** github.com/hashicorp/packer-plugin-sdk/version +| Old Path | New Path | +| ---------| -------- | +| github.com/hashicorp/packer/helper/builder/testing | github.com/hashicorp/packer-plugin-sdk/acctest | +| **new** | github.com/hashicorp/packer-plugin-sdk/acctest/provisioneracc +| github.com/hashicorp/packer/helper/tests | github.com/hashicorp/packer-plugin-sdk/acctest/testutils | +| github.com/hashicorp/packer/common/adapter | github.com/hashicorp/packer-plugin-sdk/adapter | +| github.com/hashicorp/packer/common/bootcommand | github.com/hashicorp/packer-plugin-sdk/bootcommand | +| github.com/hashicorp/packer/common/chroot | github.com/hashicorp/packer-plugin-sdk/chroot | +| github.com/hashicorp/packer/common | github.com/hashicorp/packer-plugin-sdk/common | +| github.com/hashicorp/packer/helper/communicator | github.com/hashicorp/packer-plugin-sdk/communicator | +| github.com/hashicorp/packer/helper/config | github.com/hashicorp/packer-plugin-sdk/template/config | +| github.com/hashicorp/packer/template/interpolate | github.com/hashicorp/packer-plugin-sdk/template/interpolate | +| github.com/hashicorp/packer/communicator/ssh | github.com/hashicorp/packer-plugin-sdk/communicator/ssh | +| github.com/hashicorp/packer/helper/communicator/sshkey | github.com/hashicorp/packer-plugin-sdk/communicator/sshkey | +| github.com/hashicorp/packer/provisioner | github.com/hashicorp/packer-plugin-sdk/guestexec | +| github.com/hashicorp/packer/common/json | github.com/hashicorp/packer-plugin-sdk/json | +| github.com/hashicorp/packer/helper/multistep | github.com/hashicorp/packer-plugin-sdk/multistep | +| steps from github.com/hashicorp/packer/common | github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps | +| github.com/hashicorp/packer/common/net | github.com/hashicorp/packer-plugin-sdk/net | +| github.com/hashicorp/packer/packer | github.com/hashicorp/packer-plugin-sdk/packer | +| github.com/hashicorp/packer/builder | github.com/hashicorp/packer-plugin-sdk/packerbuilderdata | +| github.com/hashicorp/packer/packer | github.com/hashicorp/packer-plugin-sdk/pathing | +| github.com/hashicorp/packer/packer/plugin | github.com/hashicorp/packer-plugin-sdk/plugin | +| github.com/hashicorp/packer/common/random | github.com/hashicorp/packer-plugin-sdk/random | +| github.com/hashicorp/packer/common | github.com/hashicorp/packer-plugin-sdk/retry | +| github.com/hashicorp/packer/packer/rpc | github.com/hashicorp/packer-plugin-sdk/rpc | +| github.com/hashicorp/packer/communicator | github.com/hashicorp/packer-plugin-sdk/sdk-internals/communicator | +| github.com/hashicorp/packer/common/shell | github.com/hashicorp/packer-plugin-sdk/shell | +| github.com/hashicorp/packer/common/shell-local | github.com/hashicorp/packer-plugin-sdk/shell-local | +| github.com/hashicorp/packer/helper/builder/localexec | github.com/hashicorp/packer-plugin-sdk/shell-local/localexec | +| github.com/hashicorp/packer/common/shutdowncommand | github.com/hashicorp/packer-plugin-sdk/shutdowncommand | +| github.com/hashicorp/packer/template | github.com/hashicorp/packer-plugin-sdk/template | +| github.com/hashicorp/packer/packer/tmp | github.com/hashicorp/packer-plugin-sdk/tmp | +| github.com/hashicorp/packer/helper/useragent | github.com/hashicorp/packer-plugin-sdk/useragent | +| github.com/hashicorp/packer/common/uuid | github.com/hashicorp/packer-plugin-sdk/uuid | +| **new** | github.com/hashicorp/packer-plugin-sdk/version When in doubt you can search the packer-plugin-sdk repo for the name of your imported structs or functions to see where they exist in the SDK now; we have not changed struct or function names. Or refer to the [Packer Plugin SDK Docs](https://pkg.go.dev/github.com/hashicorp/packer-plugin-sdk/) for help. From 368eb4aa00a938786c3de221ef6864c2860dc314 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 13 Jan 2021 13:19:10 -0800 Subject: [PATCH 3/3] add more context to intro --- website/content/guides/1.7-plugin-upgrade/index.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/content/guides/1.7-plugin-upgrade/index.mdx b/website/content/guides/1.7-plugin-upgrade/index.mdx index 2c777b509..5a2ee53ed 100644 --- a/website/content/guides/1.7-plugin-upgrade/index.mdx +++ b/website/content/guides/1.7-plugin-upgrade/index.mdx @@ -3,7 +3,10 @@ page_title: Upgrading your plugin to use the Packer plugin sdk sidebar_title: Upgrade Your Plugin to use the Packer plugin sdk --- -# Upgrading your plugin to be compatible with Packer v1.7.0 +# Upgrading your plugin to be compatible with Packer v1.7.0 and later + +In version v1.7.0 the Packer plugin development model was split into two separate packages: the Packer core +and the Packer plugin SDK. Prior to version 1.7.0, the Packer core repository (https://github.com/hashicorp/packer) contained the libraries and interfaces used by Packer plugins. In version 1.7.0, these libraries were moved into their own repository (https://github.com/hashicorp/packer-plugin-sdk). If you authored a plugin prior to the v1.7.0 release using the API version 4, you should switch to the Packer Plugin SDK. ## Update plugins to use the new SDK