From 3c282de6c318a632a435bd2565e426e193ce3cb5 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 5 Mar 2021 15:27:03 -0500 Subject: [PATCH] Add maps for statically vendored components This change adds a new set of maps for builders, provisioners, and post-processors that store reference to components that were once part of Packer and are now vendored. This file acts as a single place for defining this vendored components, which are then merged into the main components maps to be used in Packer. Quick test to ensure the exoscale-import post-processor is still loaded ``` // Validate that exoscale-import is in the know post-procoessors list ~> packer.test build docker_centos_shell_provisioner.pkr.hcl Error: Unknown post-processor type "badlynamed-import" on docker_centos_shell_provisioner.pkr.hcl line 18: (source code not available) known post-processors: [ucloud-import digitalocean-import docker-push googlecompute-export manifest vsphere-template docker-tag vsphere checksum docker-import exoscale-import yandex-export compress googlecompute-import yandex-import vagrant-cloud alicloud-import amazon-import artifice shell-local docker-save vagrant] // Validate that exoscale-import get loaded ~> packer.test build docker_centos_shell_provisioner.pkr.hcl Error: Failed preparing post-processor-block "exoscale-import" "" on docker_centos_shell_provisioner.pkr.hcl line 18: (source code not available) 4 error(s) occurred: * api_key must be set * api_secret must be set * image_bucket must be set * template_zone must be set ==> Wait completed after 2 microseconds ==> Builds finished but no artifacts were created. ``` --- command/plugin.go | 4 ++++ command/vendored_plugins.go | 14 ++++++++------ main.go | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/command/plugin.go b/command/plugin.go index edfeca617..b5c08b185 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 ( diff --git a/command/vendored_plugins.go b/command/vendored_plugins.go index 19762365a..4c4d6498a 100644 --- a/command/vendored_plugins.go +++ b/command/vendored_plugins.go @@ -6,6 +6,7 @@ import ( // 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 + exoscaleimportpostprocessor "github.com/exoscale/packer-plugin-exoscale/post-processor/exoscale-import" 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" @@ -26,14 +27,15 @@ 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{ - "docker-import": new(dockerimportpostprocessor.PostProcessor), - "docker-push": new(dockerpushpostprocessor.PostProcessor), - "docker-save": new(dockersavepostprocessor.PostProcessor), - "docker-tag": new(dockertagpostprocessor.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), } -// Upon init lets us load up any plugins that were vendored manually into the -// default set of plugins. +// 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 { 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 (