Skip to content

Commit 27e29c8

Browse files
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.
1 parent f875fed commit 27e29c8

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

internal/hcp/registry/hcl.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,18 @@ func (h *HCLRegistry) PopulateVersion(ctx context.Context) error {
6464
}
6565

6666
// StartBuild is invoked when one build for the configuration is starting to be processed
67-
func (h *HCLRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) error {
68-
name := build.Name()
69-
cb, ok := build.(*packer.CoreBuild)
70-
if ok {
71-
name = cb.Type
72-
}
73-
return h.bucket.startBuild(ctx, name)
67+
func (h *HCLRegistry) StartBuild(ctx context.Context, build *packer.CoreBuild) error {
68+
return h.bucket.startBuild(ctx, build.Type)
7469
}
7570

7671
// CompleteBuild is invoked when one build for the configuration has finished
7772
func (h *HCLRegistry) CompleteBuild(
7873
ctx context.Context,
79-
build sdkpacker.Build,
74+
build *packer.CoreBuild,
8075
artifacts []sdkpacker.Artifact,
8176
buildErr error,
8277
) ([]sdkpacker.Artifact, error) {
83-
name := build.Name()
84-
cb, ok := build.(*packer.CoreBuild)
85-
if ok {
86-
name = cb.Type
87-
}
88-
return h.bucket.completeBuild(ctx, name, artifacts, buildErr)
78+
return h.bucket.completeBuild(ctx, build.Type, artifacts, buildErr)
8979
}
9080

9181
// VersionStatusSummary prints a status report in the UI if the version is not yet done

internal/hcp/registry/json.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ func (h *JSONRegistry) PopulateVersion(ctx context.Context) error {
8282
}
8383

8484
// StartBuild is invoked when one build for the configuration is starting to be processed
85-
func (h *JSONRegistry) StartBuild(ctx context.Context, build sdkpacker.Build) error {
85+
func (h *JSONRegistry) StartBuild(ctx context.Context, build *packer.CoreBuild) error {
8686
return h.bucket.startBuild(ctx, build.Name())
8787
}
8888

8989
// CompleteBuild is invoked when one build for the configuration has finished
9090
func (h *JSONRegistry) CompleteBuild(
9191
ctx context.Context,
92-
build sdkpacker.Build,
92+
build *packer.CoreBuild,
9393
artifacts []sdkpacker.Artifact,
9494
buildErr error,
9595
) ([]sdkpacker.Artifact, error) {

internal/hcp/registry/null_registry.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88

99
sdkpacker "github.com/hashicorp/packer-plugin-sdk/packer"
10+
"github.com/hashicorp/packer/packer"
1011
)
1112

1213
// nullRegistry is a special handler that does nothing
@@ -16,13 +17,13 @@ func (r nullRegistry) PopulateVersion(context.Context) error {
1617
return nil
1718
}
1819

19-
func (r nullRegistry) StartBuild(context.Context, sdkpacker.Build) error {
20+
func (r nullRegistry) StartBuild(context.Context, *packer.CoreBuild) error {
2021
return nil
2122
}
2223

2324
func (r nullRegistry) CompleteBuild(
2425
ctx context.Context,
25-
build sdkpacker.Build,
26+
build *packer.CoreBuild,
2627
artifacts []sdkpacker.Artifact,
2728
buildErr error,
2829
) ([]sdkpacker.Artifact, error) {

internal/hcp/registry/registry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
// Registry is an entity capable to orchestrate a Packer build and upload metadata to HCP
1717
type Registry interface {
1818
PopulateVersion(context.Context) error
19-
StartBuild(context.Context, sdkpacker.Build) error
20-
CompleteBuild(ctx context.Context, build sdkpacker.Build, artifacts []sdkpacker.Artifact, buildErr error) ([]sdkpacker.Artifact, error)
19+
StartBuild(context.Context, *packer.CoreBuild) error
20+
CompleteBuild(ctx context.Context, build *packer.CoreBuild, artifacts []sdkpacker.Artifact, buildErr error) ([]sdkpacker.Artifact, error)
2121
VersionStatusSummary()
2222
}
2323

0 commit comments

Comments
 (0)