Skip to content

Commit

Permalink
Remove all HashiCorp vendored plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken committed Oct 24, 2023
1 parent fa5d035 commit ac71611
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 343 deletions.
27 changes: 27 additions & 0 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,30 @@ func (m *Meta) detectBundledPluginsHCL2(config *hcl2template.PackerConfig) []str

return compileBundledPluginList(bundledPlugins)
}

func generateRequiredPluginsBlock(plugins []string) string {
if len(plugins) == 0 {
return ""
}

buf := &strings.Builder{}
buf.WriteString(`
packer {
required_plugins {`)

for _, plugin := range plugins {
pluginName := strings.Replace(plugin, "github.com/hashicorp/", "", 1)
fmt.Fprintf(buf, `
%s = {
source = %q
version = "~> 1"
}`, pluginName, plugin)
}

buf.WriteString(`
}
}
`)

return buf.String()
}
207 changes: 6 additions & 201 deletions command/vendored_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,159 +4,36 @@
package command

import (
"fmt"
"log"
"strings"

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"

// Previously core-bundled components, split into their own plugins but
// still vendored with Packer for now. Importing as library instead of
// forcing use of packer init.

amazonchrootbuilder "github.com/hashicorp/packer-plugin-amazon/builder/chroot"
amazonebsbuilder "github.com/hashicorp/packer-plugin-amazon/builder/ebs"
amazonebssurrogatebuilder "github.com/hashicorp/packer-plugin-amazon/builder/ebssurrogate"
amazonebsvolumebuilder "github.com/hashicorp/packer-plugin-amazon/builder/ebsvolume"
amazoninstancebuilder "github.com/hashicorp/packer-plugin-amazon/builder/instance"
amazonamidatasource "github.com/hashicorp/packer-plugin-amazon/datasource/ami"
amazonsecretsmanagerdatasource "github.com/hashicorp/packer-plugin-amazon/datasource/secretsmanager"
anazibimportpostprocessor "github.com/hashicorp/packer-plugin-amazon/post-processor/import"
ansibleprovisioner "github.com/hashicorp/packer-plugin-ansible/provisioner/ansible"
ansiblelocalprovisioner "github.com/hashicorp/packer-plugin-ansible/provisioner/ansible-local"
azurearmbuilder "github.com/hashicorp/packer-plugin-azure/builder/azure/arm"
azurechrootbuilder "github.com/hashicorp/packer-plugin-azure/builder/azure/chroot"
azuredtlbuilder "github.com/hashicorp/packer-plugin-azure/builder/azure/dtl"
azuredtlartifactprovisioner "github.com/hashicorp/packer-plugin-azure/provisioner/azure-dtlartifact"
dockerbuilder "github.com/hashicorp/packer-plugin-docker/builder/docker"
dockerimportpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import"
dockerpushpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-push"
dockersavepostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-save"
dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag"
googlecomputebuilder "github.com/hashicorp/packer-plugin-googlecompute/builder/googlecompute"
googlecomputeexportpostprocessor "github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-export"
googlecomputeimportpostprocessor "github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-import"
qemubuilder "github.com/hashicorp/packer-plugin-qemu/builder/qemu"
vagrantbuilder "github.com/hashicorp/packer-plugin-vagrant/builder/vagrant"
vagrantpostprocessor "github.com/hashicorp/packer-plugin-vagrant/post-processor/vagrant"
vagrantcloudpostprocessor "github.com/hashicorp/packer-plugin-vagrant/post-processor/vagrant-cloud"
virtualboxisobuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/iso"
virtualboxovfbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/ovf"
virtualboxvmbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/vm"
vmwareisobuilder "github.com/hashicorp/packer-plugin-vmware/builder/vmware/iso"
vmwarevmxbuilder "github.com/hashicorp/packer-plugin-vmware/builder/vmware/vmx"
vsphereclonebuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone"
vsphereisobuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso"
vspherepostprocessor "github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere"
vspheretemplatepostprocessor "github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere-template"
)

// VendoredDatasources are datasource components that were once bundled with the
// Packer core, but are now being imported from their counterpart plugin repos
var VendoredDatasources = map[string]packersdk.Datasource{
"amazon-ami": new(amazonamidatasource.Datasource),
"amazon-secretsmanager": new(amazonsecretsmanagerdatasource.Datasource),
}
var VendoredDatasources = map[string]packersdk.Datasource{}

// VendoredBuilders are builder components that were once bundled with the
// Packer core, but are now being imported from their counterpart plugin repos
var VendoredBuilders = map[string]packersdk.Builder{
"amazon-ebs": new(amazonebsbuilder.Builder),
"amazon-chroot": new(amazonchrootbuilder.Builder),
"amazon-ebssurrogate": new(amazonebssurrogatebuilder.Builder),
"amazon-ebsvolume": new(amazonebsvolumebuilder.Builder),
"amazon-instance": new(amazoninstancebuilder.Builder),
"azure-arm": new(azurearmbuilder.Builder),
"azure-chroot": new(azurechrootbuilder.Builder),
"azure-dtl": new(azuredtlbuilder.Builder),
"docker": new(dockerbuilder.Builder),
"googlecompute": new(googlecomputebuilder.Builder),
"qemu": new(qemubuilder.Builder),
"vagrant": new(vagrantbuilder.Builder),
"vsphere-clone": new(vsphereclonebuilder.Builder),
"vsphere-iso": new(vsphereisobuilder.Builder),
"virtualbox-iso": new(virtualboxisobuilder.Builder),
"virtualbox-ovf": new(virtualboxovfbuilder.Builder),
"virtualbox-vm": new(virtualboxvmbuilder.Builder),
"vmware-iso": new(vmwareisobuilder.Builder),
"vmware-vmx": new(vmwarevmxbuilder.Builder),
}
var VendoredBuilders = map[string]packersdk.Builder{}

// VendoredProvisioners are provisioner components that were once bundled with the
// Packer core, but are now being imported from their counterpart plugin repos
var VendoredProvisioners = map[string]packersdk.Provisioner{
"azure-dtlartifact": new(azuredtlartifactprovisioner.Provisioner),
"ansible": new(ansibleprovisioner.Provisioner),
"ansible-local": new(ansiblelocalprovisioner.Provisioner),
}
var VendoredProvisioners = map[string]packersdk.Provisioner{}

// VendoredPostProcessors are post-processor components that were once bundled with the
// Packer core, but are now being imported from their counterpart plugin repos
var VendoredPostProcessors = map[string]packersdk.PostProcessor{
"amazon-import": new(anazibimportpostprocessor.PostProcessor),
"docker-import": new(dockerimportpostprocessor.PostProcessor),
"docker-push": new(dockerpushpostprocessor.PostProcessor),
"docker-save": new(dockersavepostprocessor.PostProcessor),
"docker-tag": new(dockertagpostprocessor.PostProcessor),
"googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor),
"googlecompute-import": new(googlecomputeimportpostprocessor.PostProcessor),
"vagrant": new(vagrantpostprocessor.PostProcessor),
"vagrant-cloud": new(vagrantcloudpostprocessor.PostProcessor),
"vsphere-template": new(vspheretemplatepostprocessor.PostProcessor),
"vsphere": new(vspherepostprocessor.PostProcessor),
}
var VendoredPostProcessors = map[string]packersdk.PostProcessor{}

// bundledStatus is used to know if one of the bundled components is loaded from
// an external plugin, or from the bundled plugins.
//
// We keep track of this to produce a warning if a user relies on one
// such plugin, as they will be removed in a later version of Packer.
var bundledStatus = map[string]bool{
"packer-builder-amazon-ebs": false,
"packer-builder-amazon-chroot": false,
"packer-builder-amazon-ebssurrogate": false,
"packer-builder-amazon-ebsvolume": false,
"packer-builder-amazon-instance": false,
"packer-post-processor-amazon-import": false,
"packer-datasource-amazon-ami": false,
"packer-datasource-amazon-secretsmanager": false,

"packer-provisioner-ansible": false,
"packer-provisioner-ansible-local": false,

"packer-provisioner-azure-dtlartifact": false,
"packer-builder-azure-arm": false,
"packer-builder-azure-chroot": false,
"packer-builder-azure-dtl": false,

"packer-builder-docker": false,
"packer-post-processor-docker-import": false,
"packer-post-processor-docker-push": false,
"packer-post-processor-docker-save": false,
"packer-post-processor-docker-tag": false,

"packer-builder-googlecompute": false,
"packer-post-processor-googlecompute-export": false,
"packer-post-processor-googlecompute-import": false,

"packer-builder-qemu": false,

"packer-builder-vagrant": false,
"packer-post-processor-vagrant": false,
"packer-post-processor-vagrant-cloud": false,

"packer-builder-virtualbox-iso": false,
"packer-builder-virtualbox-ovf": false,
"packer-builder-virtualbox-vm": false,

"packer-builder-vmware-iso": false,
"packer-builder-vmware-vmx": false,

"packer-builder-vsphere-clone": false,
"packer-builder-vsphere-iso": false,
"packer-post-processor-vsphere-template": false,
"packer-post-processor-vsphere": false,
}
var bundledStatus = map[string]bool{}

// TrackBundledPlugin marks a component as loaded from Packer's bundled plugins
// instead of from an externally loaded plugin.
Expand All @@ -171,52 +48,7 @@ func TrackBundledPlugin(pluginName string) {
bundledStatus[pluginName] = true
}

var componentPluginMap = map[string]string{
"packer-builder-amazon-ebs": "github.com/hashicorp/amazon",
"packer-builder-amazon-chroot": "github.com/hashicorp/amazon",
"packer-builder-amazon-ebssurrogate": "github.com/hashicorp/amazon",
"packer-builder-amazon-ebsvolume": "github.com/hashicorp/amazon",
"packer-builder-amazon-instance": "github.com/hashicorp/amazon",
"packer-post-processor-amazon-import": "github.com/hashicorp/amazon",
"packer-datasource-amazon-ami": "github.com/hashicorp/amazon",
"packer-datasource-amazon-secretsmanager": "github.com/hashicorp/amazon",

"packer-provisioner-ansible": "github.com/hashicorp/ansible",
"packer-provisioner-ansible-local": "github.com/hashicorp/ansible",

"packer-provisioner-azure-dtlartifact": "github.com/hashicorp/azure",
"packer-builder-azure-arm": "github.com/hashicorp/azure",
"packer-builder-azure-chroot": "github.com/hashicorp/azure",
"packer-builder-azure-dtl": "github.com/hashicorp/azure",

"packer-builder-docker": "github.com/hashicorp/docker",
"packer-post-processor-docker-import": "github.com/hashicorp/docker",
"packer-post-processor-docker-push": "github.com/hashicorp/docker",
"packer-post-processor-docker-save": "github.com/hashicorp/docker",
"packer-post-processor-docker-tag": "github.com/hashicorp/docker",

"packer-builder-googlecompute": "github.com/hashicorp/googlecompute",
"packer-post-processor-googlecompute-export": "github.com/hashicorp/googlecompute",
"packer-post-processor-googlecompute-import": "github.com/hashicorp/googlecompute",

"packer-builder-qemu": "github.com/hashicorp/qemu",

"packer-builder-vagrant": "github.com/hashicorp/vagrant",
"packer-post-processor-vagrant": "github.com/hashicorp/vagrant",
"packer-post-processor-vagrant-cloud": "github.com/hashicorp/vagrant",

"packer-builder-virtualbox-iso": "github.com/hashicorp/virtualbox",
"packer-builder-virtualbox-ovf": "github.com/hashicorp/virtualbox",
"packer-builder-virtualbox-vm": "github.com/hashicorp/virtualbox",

"packer-builder-vmware-iso": "github.com/hashicorp/vmware",
"packer-builder-vmware-vmx": "github.com/hashicorp/vmware",

"packer-builder-vsphere-clone": "github.com/hashicorp/vsphere",
"packer-builder-vsphere-iso": "github.com/hashicorp/vsphere",
"packer-post-processor-vsphere-template": "github.com/hashicorp/vsphere",
"packer-post-processor-vsphere": "github.com/hashicorp/vsphere",
}
var componentPluginMap = map[string]string{}

// compileBundledPluginList returns a list of plugins to import in a config
//
Expand All @@ -243,33 +75,6 @@ func compileBundledPluginList(componentMap map[string]struct{}) []string {
return pluginList
}

func generateRequiredPluginsBlock(plugins []string) string {
if len(plugins) == 0 {
return ""
}

buf := &strings.Builder{}
buf.WriteString(`
packer {
required_plugins {`)

for _, plugin := range plugins {
pluginName := strings.Replace(plugin, "github.com/hashicorp/", "", 1)
fmt.Fprintf(buf, `
%s = {
source = %q
version = "~> 1"
}`, pluginName, plugin)
}

buf.WriteString(`
}
}
`)

return buf.String()
}

// Upon init lets load up any plugins that were vendored manually into the default
// set of plugins.
func init() {
Expand Down
34 changes: 2 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ require (

require (
github.com/go-openapi/strfmt v0.21.3
github.com/hashicorp/packer-plugin-ansible v1.0.3
github.com/hashicorp/packer-plugin-azure v1.4.0
github.com/hashicorp/packer-plugin-docker v1.0.8
github.com/hashicorp/packer-plugin-googlecompute v1.1.0
github.com/hashicorp/packer-plugin-qemu v1.0.9
github.com/hashicorp/packer-plugin-vagrant v1.0.3
github.com/hashicorp/packer-plugin-virtualbox v1.0.4
github.com/hashicorp/packer-plugin-vmware v1.0.7
github.com/hashicorp/packer-plugin-vsphere v1.1.1
github.com/oklog/ulid v1.3.1
github.com/pierrec/lz4/v4 v4.1.18
github.com/shirou/gopsutil/v3 v3.23.4
Expand All @@ -79,17 +70,6 @@ require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.2 // indirect
cloud.google.com/go/storage v1.30.1 // indirect
github.com/Azure/azure-sdk-for-go v64.0.0+incompatible // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.19 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
Expand All @@ -111,9 +91,6 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/chzyer/test v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/digitalocean/go-libvirt v0.0.0-20201209184759-e2a69bcd5bd1 // indirect
github.com/digitalocean/go-qemu v0.0.0-20210326154740-ac9e0b687001 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/dylanmei/iso8601 v0.1.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.12.0 // indirect
Expand All @@ -131,21 +108,16 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hashicorp/aws-sdk-go-base v0.7.1 // indirect
github.com/hashicorp/consul/api v1.10.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-azure-helpers v0.16.5 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter/gcs/v2 v2.2.0 // indirect
github.com/hashicorp/go-getter/s3/v2 v2.2.0 // indirect
Expand All @@ -168,6 +140,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
Expand All @@ -177,31 +150,28 @@ require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/iochan v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.5 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/vmware/govmomi v0.29.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.mongodb.org/mongo-driver v1.11.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.11.1 // indirect
go.opentelemetry.io/otel/trace v1.11.1 // indirect
golang.org/x/mobile v0.0.0-20210901025245-1fde1d6c3ca1 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
Loading

0 comments on commit ac71611

Please sign in to comment.