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

Update JSON template does not return substitute values in 1.8.6 version #12290

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

nywilken
Copy link
Contributor

This change fixes a regression introduced in Packer 1.8.6, where configurations custom builder names
, via the name attribute, would internally interpolate the proper build names, but would display the
name to STDOUT as uninterpolated values. The change updates the creation of a CoreBuild for legacy JSON templates
to use use the interpolated name as the final build type, which gets rendered to the screen.

Test Results Before Fix

~>  go test ./... -run='TestCoreBuild_buildNameIntepolation' -v
--- FAIL: TestCoreBuild_buildTypeIntepolation (0.01s)
    core_test.go:930: build type interpolation failed; expected "test.mybuild-RandomToken", got "test.{{user `build_name`}}"
    core_test.go:930: build type interpolation failed; expected "test.build-vardata", got "test.{{user `build_name`}}"
    core_test.go:930: build type interpolation failed; expected "test.build-12345", got "test.{{user `build_name`}}"
FAIL

Test Results After Fix

~>  go test ./... -run='TestCoreBuild_buildNameIntepolation' -v
=== RUN   TestCoreBuild_buildTypeIntepolation
--- PASS: TestCoreBuild_buildTypeIntepolation (0.01s)
PASS

Closes #12281

@nywilken nywilken requested a review from a team as a code owner February 27, 2023 20:04
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

Good catch, LGTM!

@nywilken nywilken added the backport/1.8.x Backport PR changes to `release/1.8.x` label Feb 28, 2023
This change fixes a regression introduced in Packer 1.8.6, where configurations custom builder names
, via the name attribute, would internally interpolate the proper build names, but would display the
name to STDOUT as uninterpolated values. The change updates the creation of a CoreBuild for legacy JSON templates
to use use the interpolated name as the final build type, which gets rendered to the screen.

Test Results Before Fix
```
~>  go test ./... -run='TestCoreBuild_buildNameIntepolation' -v
--- FAIL: TestCoreBuild_buildTypeIntepolation (0.01s)
    core_test.go:930: build type interpolation failed; expected "test.mybuild-RandomToken", got "test.{{user `build_name`}}"
    core_test.go:930: build type interpolation failed; expected "test.build-vardata", got "test.{{user `build_name`}}"
    core_test.go:930: build type interpolation failed; expected "test.build-12345", got "test.{{user `build_name`}}"
FAIL
```

Test Results After Fix
```
~>  go test ./... -run='TestCoreBuild_buildNameIntepolation' -v
=== RUN   TestCoreBuild_buildTypeIntepolation
--- PASS: TestCoreBuild_buildTypeIntepolation (0.01s)
PASS
```

Closes #12281
@nywilken nywilken force-pushed the nywilken/fix-json-build-display-bug branch from 38c7051 to 7c8d992 Compare February 28, 2023 18:59
@nywilken nywilken merged commit 8f67444 into main Mar 1, 2023
@nywilken nywilken deleted the nywilken/fix-json-build-display-bug branch March 1, 2023 20:19
@github-actions
Copy link

github-actions bot commented Apr 1, 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 Apr 1, 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` bug regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON template does not return substitute values in 1.8.6 version
2 participants