From 79481ed7ecb085a66600e06fd75f9cd3b800bd48 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 5 Mar 2021 15:44:04 -0500 Subject: [PATCH] Add vendored components map as opposed to removing code generation for command/plugin.go --- command/plugin.go | 19 +++---------- command/vendored_plugins.go | 55 +++++++++++++++++++++++++++++++++++++ go.mod | 1 - go.sum | 2 -- main.go | 1 + vendor/modules.txt | 2 -- 6 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 command/vendored_plugins.go diff --git a/command/plugin.go b/command/plugin.go index cb378dec3..2e039ed6c 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -1,3 +1,7 @@ +// +// This file is automatically generated by scripts/generate-plugins.go -- Do not edit! +// + package command import ( @@ -9,16 +13,6 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/plugin" - // 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, until packer v1.8.0 - 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" - - // These components are still built into the packer core repo alicloudecsbuilder "github.com/hashicorp/packer/builder/alicloud/ecs" amazonchrootbuilder "github.com/hashicorp/packer/builder/amazon/chroot" amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs" @@ -126,7 +120,6 @@ var Builders = map[string]packersdk.Builder{ "azure-dtl": new(azuredtlbuilder.Builder), "cloudstack": new(cloudstackbuilder.Builder), "digitalocean": new(digitaloceanbuilder.Builder), - "docker": new(dockerbuilder.Builder), "file": new(filebuilder.Builder), "googlecompute": new(googlecomputebuilder.Builder), "hcloud": new(hcloudbuilder.Builder), @@ -197,10 +190,6 @@ var PostProcessors = map[string]packersdk.PostProcessor{ "checksum": new(checksumpostprocessor.PostProcessor), "compress": new(compresspostprocessor.PostProcessor), "digitalocean-import": new(digitaloceanimportpostprocessor.PostProcessor), - "docker-import": new(dockerimportpostprocessor.PostProcessor), - "docker-push": new(dockerpushpostprocessor.PostProcessor), - "docker-save": new(dockersavepostprocessor.PostProcessor), - "docker-tag": new(dockertagpostprocessor.PostProcessor), "exoscale-import": new(exoscaleimportpostprocessor.PostProcessor), "googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor), "googlecompute-import": new(googlecomputeimportpostprocessor.PostProcessor), diff --git a/command/vendored_plugins.go b/command/vendored_plugins.go new file mode 100644 index 000000000..57427ba81 --- /dev/null +++ b/command/vendored_plugins.go @@ -0,0 +1,55 @@ +package command + +import ( + 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, until packer v1.8.0 + 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" +) + +// VendoredBuilders are builder components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredBuilders = map[string]packersdk.Builder{ + "docker": new(dockerbuilder.Builder), +} + +// VendoredProvisioners are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredProvisioners = map[string]packersdk.Provisioner{} + +// VendoredPostProcessors are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredPostProcessors = map[string]packersdk.PostProcessor{ + "docker-import": new(dockerimportpostprocessor.PostProcessor), + "docker-push": new(dockerpushpostprocessor.PostProcessor), + "docker-save": new(dockersavepostprocessor.PostProcessor), + "docker-tag": new(dockertagpostprocessor.PostProcessor), +} + +// Upon init lets load up any plugins that were vendored manually into the default +// set of plugins. +func init() { + for k, v := range VendoredBuilders { + if _, ok := Builders[k]; ok { + continue + } + Builders[k] = v + } + + for k, v := range VendoredProvisioners { + if _, ok := Provisioners[k]; ok { + continue + } + Provisioners[k] = v + } + + for k, v := range VendoredPostProcessors { + if _, ok := PostProcessors[k]; ok { + continue + } + PostProcessors[k] = v + } +} diff --git a/go.mod b/go.mod index 17e938235..858ad2f70 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,6 @@ require ( github.com/mitchellh/cli v1.1.0 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed - github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/mapstructure v1.4.0 github.com/mitchellh/panicwrap v1.0.0 github.com/mitchellh/prefixedio v0.0.0-20151214002211-6e6954073784 diff --git a/go.sum b/go.sum index fecf30140..ca566554a 100644 --- a/go.sum +++ b/go.sum @@ -570,11 +570,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUt github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.1+incompatible h1:2LwXWdbjXwyDgq26Yy/OT4xozlpmssQfy/rtfhWb0bY= github.com/shirou/gopsutil v3.21.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= diff --git a/main.go b/main.go index f358c2f05..f7806b0bc 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,6 @@ // This is the main package for the `packer` application. +//go:generate go run ./scripts/generate-plugins.go package main import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 2150e74c8..1f1316bf4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -559,8 +559,6 @@ github.com/mitchellh/go-testing-interface github.com/mitchellh/go-vnc # github.com/mitchellh/go-wordwrap v1.0.0 github.com/mitchellh/go-wordwrap -# github.com/mitchellh/gox v1.0.1 -## explicit # github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/iochan # github.com/mitchellh/mapstructure v1.4.0