mirror of
https://github.com/hashicorp/packer.git
synced 2026-02-24 18:30:41 -05:00
* add basic docs for plugins command * refactor docs Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com> * add plugins command * add plugins subcommands they do nothing for now * add plugins installed command + tests * add plugins install command * add remove plugin command * better docs for the plugins install command * remove duplicate content * better output for installed plugins * add plugins required command * Update plugins_install.go * add newline after `Usage:` * Update plugins_remove.go * Update plugins_required.go * Update plugins_remove.go * Update plugins_installed.go * Update plugins_install.go * add docs * Update plugins_install.go * fix typos * Update plugins_test.go * fix typos Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com> * Update core_wrapper.go Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com> * Update website/content/docs/commands/plugins/remove.mdx Co-authored-by: Wilken Rivera <wilken@hashicorp.com> * Update website/content/docs/commands/plugins/required.mdx Co-authored-by: Wilken Rivera <wilken@hashicorp.com> * Update website/content/docs/commands/plugins/required.mdx Co-authored-by: Wilken Rivera <wilken@hashicorp.com> * Update plugins_required.go * Update install.mdx * Update required.mdx * plugins requirement, warn when no plugin was found * Update website/content/docs/commands/plugins/required.mdx Co-authored-by: Wilken Rivera <wilken@hashicorp.com> Co-authored-by: Wilken Rivera <1749304+nywilken@users.noreply.github.com> Co-authored-by: Wilken Rivera <wilken@hashicorp.com>
68 lines
2 KiB
Go
68 lines
2 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2"
|
|
packerregistry "github.com/hashicorp/packer/internal/registry"
|
|
"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 plugins currently only works with HCL2 configuration templates",
|
|
Detail: "Please manually install plugins with the plugins command or use a HCL2 configuration that will do that for you.",
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
|
|
// ConfiguredArtifactMetadataPublisher returns a configured image bucket that can be used for publishing
|
|
// build image artifacts to a configured Packer Registry destination.
|
|
func (c *CoreWrapper) ConfiguredArtifactMetadataPublisher() (*packerregistry.Bucket, hcl.Diagnostics) {
|
|
bucket := c.Core.GetRegistryBucket()
|
|
|
|
// If at this point the bucket is nil, it means the HCP Packer registry is not enabled
|
|
if bucket == nil {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Publishing build artifacts to HCP Packer Registry not enabled",
|
|
Detail: "No Packer Registry configuration detected; skipping all publishing steps " +
|
|
"See publishing to a Packer registry for Packer configuration details",
|
|
Severity: hcl.DiagWarning,
|
|
},
|
|
}
|
|
}
|
|
|
|
err := bucket.Validate()
|
|
if err != nil {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Invalid HCP Packer Registry configuration",
|
|
Detail: err.Error(),
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
|
|
return bucket, nil
|
|
}
|