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

hcl2template: only iterate on known HCP datasource #11883

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions hcl2template/types.build.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ func (p *Parser) decodeBuildConfig(block *hcl.Block, cfg *PackerConfig) (*BuildB
}

for _, value := range dsValues.AsValueMap() {
// Only try to check ancestry if we have fetched the
// data from HCP for the data source.
//
// NOTE: this will happen especially during validate as
// when we reach this point, we haven't fetched the
// data from HCP.
//
// TODO: maybe move this HCP-related logic outside that
// decode block so it's only executed during build?
if !value.IsKnown() {
Comment on lines +274 to +276
Copy link
Contributor

Choose a reason for hiding this comment

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

The information needed to deduce this association is currently only within the PackerConfig which is not directly accessible to the build command step. Originally I had this logic further up in the call stack but opted to place it here as it is dependent on the hcp packer bucket bits being available.

Not the best location for sure but hoping the code next to it provides some relevance.

continue
}

values := value.AsValueMap()
imgID, itID := values["id"], values["iteration_id"]
cfg.bucket.SourceImagesToParentIterations[imgID.AsString()] = itID.AsString()
Expand Down