diff --git a/internal/hcp/api/service_build.go b/internal/hcp/api/service_build.go index a6cbead0f03..946d8d08e42 100644 --- a/internal/hcp/api/service_build.go +++ b/internal/hcp/api/service_build.go @@ -58,7 +58,7 @@ func (c *Client) UpdateBuild( buildLabels map[string]string, buildStatus hcpPackerModels.HashicorpCloudPacker20230101BuildStatus, artifacts []*hcpPackerModels.HashicorpCloudPacker20230101ArtifactCreateBody, - metadata map[string]interface{}, + metadata *hcpPackerModels.HashicorpCloudPacker20230101BuildMetadata, ) (string, error) { params := hcpPackerAPI.NewPackerServiceUpdateBuildParamsWithContext(ctx) @@ -77,12 +77,7 @@ func (c *Client) UpdateBuild( Platform: platform, SourceExternalIdentifier: sourceExternalIdentifier, Status: &buildStatus, - } - - if metadata != nil { - params.Body.Metadata = &hcpPackerModels.HashicorpCloudPacker20230101BuildMetadata{ - Packer: metadata, - } + Metadata: metadata, } resp, err := c.Packer.PackerServiceUpdateBuild(params, nil) diff --git a/internal/hcp/registry/types.bucket.go b/internal/hcp/registry/types.bucket.go index 60f53fae7d0..f0a7c4b4353 100644 --- a/internal/hcp/registry/types.bucket.go +++ b/internal/hcp/registry/types.bucket.go @@ -214,7 +214,7 @@ func (bucket *Bucket) UpdateBuildStatus( nil, status, nil, - buildToUpdate.Metadata, + &buildToUpdate.Metadata, ) if err != nil { return err @@ -287,7 +287,7 @@ func (bucket *Bucket) markBuildComplete(ctx context.Context, name string) error buildToUpdate.Labels, status, artifacts, - buildToUpdate.Metadata, + &buildToUpdate.Metadata, ) if err != nil { return err @@ -612,8 +612,8 @@ func (bucket *Bucket) AddMetadataToBuild( return err } - preparedMetadata := make(map[string]interface{}) - preparedMetadata["version"] = metadata.PackerVersion + packerMetadata := make(map[string]interface{}) + packerMetadata["version"] = metadata.PackerVersion var pluginsMetadata []map[string]interface{} for _, plugin := range metadata.Plugins { @@ -623,9 +623,9 @@ func (bucket *Bucket) AddMetadataToBuild( } pluginsMetadata = append(pluginsMetadata, pluginMetadata) } - preparedMetadata["plugins"] = pluginsMetadata + packerMetadata["plugins"] = pluginsMetadata - buildToUpdate.Metadata = preparedMetadata + buildToUpdate.Metadata.Packer = packerMetadata return nil } diff --git a/internal/hcp/registry/types.builds.go b/internal/hcp/registry/types.builds.go index 1f6c09eb457..dc7e132762c 100644 --- a/internal/hcp/registry/types.builds.go +++ b/internal/hcp/registry/types.builds.go @@ -19,7 +19,7 @@ type Build struct { Labels map[string]string Artifacts map[string]packerSDKRegistry.Image Status hcpPackerModels.HashicorpCloudPacker20230101BuildStatus - Metadata map[string]interface{} + Metadata hcpPackerModels.HashicorpCloudPacker20230101BuildMetadata } // NewBuildFromCloudPackerBuild converts a HashicorpCloudPackerBuild to a local build that can be tracked and