mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-14 19:20:04 -04:00
hcp: replace packersdk.Build by *CoreBuild
As the rest of the build process was updated to remove references to the Build interface exposed by the SDK, we change the usage of such types in the hcp internal package, so they are typed with *CoreBuild too.
This commit is contained in:
parent
98198b5af8
commit
62befd70bf
4 changed files with 14 additions and 25 deletions
|
|
@ -65,30 +65,19 @@ func (h *HCLRegistry) PopulateVersion(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// StartBuild is invoked when one build for the configuration is starting to be processed
|
||||
func (h *HCLRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) error {
|
||||
name := build.Name()
|
||||
cb, ok := build.(*packer.CoreBuild)
|
||||
if ok {
|
||||
name = cb.Type
|
||||
}
|
||||
|
||||
return h.bucket.startBuild(ctx, name)
|
||||
func (h *HCLRegistry) StartBuild(ctx context.Context, build *packer.CoreBuild) error {
|
||||
return h.bucket.startBuild(ctx, build.Type)
|
||||
}
|
||||
|
||||
// CompleteBuild is invoked when one build for the configuration has finished
|
||||
func (h *HCLRegistry) CompleteBuild(
|
||||
ctx context.Context,
|
||||
build sdkpacker.Build,
|
||||
build *packer.CoreBuild,
|
||||
artifacts []sdkpacker.Artifact,
|
||||
buildErr error,
|
||||
) ([]sdkpacker.Artifact, error) {
|
||||
buildName := build.Name()
|
||||
cb, ok := build.(*packer.CoreBuild)
|
||||
if ok {
|
||||
buildName = cb.Type
|
||||
}
|
||||
|
||||
buildMetadata, envMetadata := cb.GetMetadata(), h.metadata
|
||||
buildName := build.Type
|
||||
buildMetadata, envMetadata := build.GetMetadata(), h.metadata
|
||||
err := h.bucket.Version.AddMetadataToBuild(ctx, buildName, buildMetadata, envMetadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -84,20 +84,19 @@ func (h *JSONRegistry) PopulateVersion(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// StartBuild is invoked when one build for the configuration is starting to be processed
|
||||
func (h *JSONRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) error {
|
||||
name := build.Name()
|
||||
return h.bucket.startBuild(ctx, name)
|
||||
func (h *JSONRegistry) StartBuild(ctx context.Context, build *packer.CoreBuild) error {
|
||||
return h.bucket.startBuild(ctx, build.Name())
|
||||
}
|
||||
|
||||
// CompleteBuild is invoked when one build for the configuration has finished
|
||||
func (h *JSONRegistry) CompleteBuild(
|
||||
ctx context.Context,
|
||||
build sdkpacker.Build,
|
||||
build *packer.CoreBuild,
|
||||
artifacts []sdkpacker.Artifact,
|
||||
buildErr error,
|
||||
) ([]sdkpacker.Artifact, error) {
|
||||
buildName := build.Name()
|
||||
buildMetadata, envMetadata := build.(*packer.CoreBuild).GetMetadata(), h.metadata
|
||||
buildMetadata, envMetadata := build.GetMetadata(), h.metadata
|
||||
err := h.bucket.Version.AddMetadataToBuild(ctx, buildName, buildMetadata, envMetadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"context"
|
||||
|
||||
sdkpacker "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
)
|
||||
|
||||
// nullRegistry is a special handler that does nothing
|
||||
|
|
@ -16,13 +17,13 @@ func (r nullRegistry) PopulateVersion(context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r nullRegistry) StartBuild(context.Context, sdkpacker.Build) error {
|
||||
func (r nullRegistry) StartBuild(context.Context, *packer.CoreBuild) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r nullRegistry) CompleteBuild(
|
||||
ctx context.Context,
|
||||
build sdkpacker.Build,
|
||||
build *packer.CoreBuild,
|
||||
artifacts []sdkpacker.Artifact,
|
||||
buildErr error,
|
||||
) ([]sdkpacker.Artifact, error) {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import (
|
|||
// Registry is an entity capable to orchestrate a Packer build and upload metadata to HCP
|
||||
type Registry interface {
|
||||
PopulateVersion(context.Context) error
|
||||
StartBuild(context.Context, sdkpacker.Build) error
|
||||
CompleteBuild(ctx context.Context, build sdkpacker.Build, artifacts []sdkpacker.Artifact, buildErr error) ([]sdkpacker.Artifact, error)
|
||||
StartBuild(context.Context, *packer.CoreBuild) error
|
||||
CompleteBuild(ctx context.Context, build *packer.CoreBuild, artifacts []sdkpacker.Artifact, buildErr error) ([]sdkpacker.Artifact, error)
|
||||
VersionStatusSummary()
|
||||
Metadata() Metadata
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue