Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer: add HCL2 support for telemetry #12319

Merged
merged 2 commits into from
Apr 18, 2023
Merged

Conversation

lbajolet-hashicorp
Copy link
Contributor

Packer's telemetry package captures the field names from a configuration on legacy JSON templates, but did not contain any code for handling HCL2 template configurations.

This commit adds a routine to extract the field names from a HCL2 configuration once flattened, and adds some glue code to propagate the configurations to the telemetry structures.

@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner March 17, 2023 14:30
@lbajolet-hashicorp lbajolet-hashicorp force-pushed the telemetry_hcl2 branch 2 times, most recently from 4d70d36 to 98af4ea Compare March 20, 2023 14:31
hcl2template/types.datasource.go Outdated Show resolved Hide resolved
hcl2template/types.datasource.go Outdated Show resolved Hide resolved
@@ -120,9 +120,11 @@ func (m *Meta) GetConfig(cla *MetaArgs) (packer.Handler, int) {

switch cfgType {
case ConfigTypeHCL2:
packer.CheckpointReporter.SetTemplateType(packer.HCL2Template)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

hcl2template/types.packer_config.go Outdated Show resolved Hide resolved
hcl2template/types.packer_config.go Outdated Show resolved Hide resolved
@@ -489,6 +497,8 @@ func (cfg *PackerConfig) getCoreBuildProvisioner(source SourceUseBlock, pb *Prov
return packer.CoreBuildProvisioner{}, diags
}

flatProvisionerCfg, _ := decodeHCL2Spec(pb.HCL2Ref.Rest, ectx, provisioner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this initialization closer to where it is used which right about line 521.

That said, do we want to capture details about the provisioner being wrapped?

Copy link
Contributor

@nywilken nywilken Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can disregard the question above about including the rapped provisioner info. The configuration should already contain details about the wrapped provisioner so the flattened config will already have all the information, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically it should yes! I'll test it to be sure though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I need to test this.

Packer's telemetry package captures the field names from a configuration
on legacy JSON templates, but did not contain any code for handling HCL2
template configurations.

This commit adds a routine to extract the field names from a HCL2
configuration once flattened, and adds some glue code to propagate the
configurations to the telemetry structures.
@nywilken nywilken added enhancement hcl2 backport/1.8.x Backport PR changes to `release/1.8.x` labels Apr 5, 2023
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Nicely done. We have an open conversation internally about the type/name but besides that I think we are good to go.

packer/telemetry.go Outdated Show resolved Hide resolved
The template type for a builder, provisioner, post-processor or
datasource was not tracked with telemetry data.

This commit adds the infrastructure to track this, bumping the schema
for non-crashes to `beta/packer/6' at the same time.
@github-actions
Copy link

github-actions bot commented Jun 4, 2023

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/1.8.x Backport PR changes to `release/1.8.x` enhancement hcl2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants