mirror of
https://github.com/hashicorp/packer.git
synced 2026-02-20 08:20:06 -05:00
This adds the new `required_plugins` block to be nested under the packer block.
Example:
```hcl
packer {
required_plugins {
aws = {
version = ">= 2.7.0"
source = "azr/aws"
}
azure = ">= 2.7.0"
}
}
```
For example on darwin_amd64 Packer will install those under :
* "${PACKER_HOME_DIR}/plugin/github.com/azr/amazon/packer-plugin-amazon_2.7.0_x5.0_darwin_amd64"
* "${PACKER_HOME_DIR}/plugin/github.com/hashicorp/azure/packer-plugin-azure_2.7.0_x5.0_darwin_amd64_x5"
+ docs
+ tests
36 lines
916 B
Go
36 lines
916 B
Go
package command
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2"
|
|
"github.com/hashicorp/packer/packer"
|
|
plugingetter "github.com/hashicorp/packer/packer/plugin-getter"
|
|
)
|
|
|
|
// CoreWrapper wraps a packer.Core in order to have it's Initialize func return
|
|
// a diagnostic.
|
|
type CoreWrapper struct {
|
|
*packer.Core
|
|
}
|
|
|
|
func (c *CoreWrapper) Initialize(_ packer.InitializeOptions) hcl.Diagnostics {
|
|
err := c.Core.Initialize()
|
|
if err != nil {
|
|
return hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Detail: err.Error(),
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *CoreWrapper) PluginRequirements() (plugingetter.Requirements, hcl.Diagnostics) {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Packer init is supported for HCL2 configuration templates only",
|
|
Detail: "Please manually install plugins or use a HCL2 configuration that will do that for you.",
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|