Skip to content

Migrate expandConfidentialInstanceConfig, flattenConfidentialInstanceConfig functions in compute_instance_helpers.go.tmpl to use direct HTTP rather than a client library#17721

Open
nsamartsev wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
nsamartsev:resource-compute-region-instance-ConfidentialInstanceConfig-migration
Open

Migrate expandConfidentialInstanceConfig, flattenConfidentialInstanceConfig functions in compute_instance_helpers.go.tmpl to use direct HTTP rather than a client library#17721
nsamartsev wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
nsamartsev:resource-compute-region-instance-ConfidentialInstanceConfig-migration

Conversation

@nsamartsev
Copy link
Copy Markdown
Contributor

@nsamartsev nsamartsev commented May 25, 2026

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

compute: Migrate `expandConfidentialInstanceConfig`, `flattenConfidentialInstanceConfig` functions in `compute_instance_helpers.go.tmpl` to use direct HTTP rather than a client library

@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 25, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 8c8be03:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 1 file changed, 7 insertions(+), 7 deletions(-)
google-beta provider View Diff 1 file changed, 7 insertions(+), 7 deletions(-)
terraform-google-conversion View Diff 2 files changed, 14 insertions(+), 14 deletions(-)

Errors

google provider:

  • The diff processor failed to build. This is usually due to the downstream provider failing to compile.

google-beta provider:

  • The diff processor failed to build. This is usually due to the downstream provider failing to compile.

Step 1: Replaying Mode

Caution

Build Failure during VCR tests

🔴 REPLAYING mode: The following packages failed to build:

  • compute

Please fix the compilation errors to complete your PR.

View the build log

@nsamartsev VCR tests complete for 8c8be03!

@nsamartsev nsamartsev force-pushed the resource-compute-region-instance-ConfidentialInstanceConfig-migration branch from 8c8be03 to e54f1f8 Compare May 25, 2026 13:26
@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 25, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit e54f1f8:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 83 insertions(+), 62 deletions(-)
google-beta provider View Diff 4 files changed, 87 insertions(+), 66 deletions(-)
terraform-google-conversion View Diff 2 files changed, 14 insertions(+), 14 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1457 1363 93 1
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccComputeRegionInstanceTemplate_ConfidentialInstanceConfigMain

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccComputeRegionInstanceTemplate_ConfidentialInstanceConfigMain

🟢 All tests passed!

View the recording VCR build log or the debug logs folder for detailed results.

@nsamartsev VCR tests complete for e54f1f8!

@nsamartsev nsamartsev force-pushed the resource-compute-region-instance-ConfidentialInstanceConfig-migration branch 2 times, most recently from 193b70d to 88750fc Compare May 25, 2026 14:05
@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 25, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 193b70d:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 83 insertions(+), 62 deletions(-)
google-beta provider View Diff 4 files changed, 87 insertions(+), 66 deletions(-)
terraform-google-conversion View Diff 4 files changed, 29 insertions(+), 18 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1457 1364 93 0
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@nsamartsev VCR tests complete for 193b70d!

@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 25, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 88750fc:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 83 insertions(+), 62 deletions(-)
google-beta provider View Diff 4 files changed, 87 insertions(+), 66 deletions(-)
terraform-google-conversion View Diff 4 files changed, 54 insertions(+), 43 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1457 1364 93 0
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@nsamartsev VCR tests complete for 88750fc!

@nsamartsev nsamartsev changed the title Migrate expandConfidentialInstanceConfig, flattenConfidentialInstanceConfig functions Migrate expandConfidentialInstanceConfig, flattenConfidentialInstanceConfig functions in compute_instance_helpers.go.tmpl to use direct HTTP rather than a client library May 25, 2026
@nsamartsev nsamartsev force-pushed the resource-compute-region-instance-ConfidentialInstanceConfig-migration branch from 88750fc to 34598af Compare May 28, 2026 09:39
@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 28, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 34598af:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 83 insertions(+), 62 deletions(-)
google-beta provider View Diff 4 files changed, 87 insertions(+), 66 deletions(-)
terraform-google-conversion View Diff 4 files changed, 54 insertions(+), 43 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1462 1369 93 0
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@nsamartsev VCR tests complete for 34598af!

@nsamartsev nsamartsev marked this pull request as ready for review May 28, 2026 11:05
@github-actions github-actions Bot requested a review from slevenick May 28, 2026 11:05
@github-actions
Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

{{- end }}
}, nil
}
if cic := expandConfidentialInstanceConfig(d); cic != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the change in handling confidential instance config here?

Copy link
Copy Markdown
Contributor Author

@nsamartsev nsamartsev May 28, 2026

Choose a reason for hiding this comment

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

Hello @slevenick

expandConfidentialInstanceConfig now returns map[string]interface{} instead of *compute.ConfidentialInstanceConfig, but this resource still builds an Apiary struct.

The post-struct block is the adapter needed to convert the map back to the pointer type - without it there's a compile error.

hclData["description"] = instance.Description
hclData["hostname"] = instance.Hostname
hclData["confidential_instance_config"] = flattenConfidentialInstanceConfig(instance.ConfidentialInstanceConfig)
if instance.ConfidentialInstanceConfig != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the guard here? It may make sense if we were starting from scratch, but changing behavior may cause unintended consequences

Copy link
Copy Markdown
Contributor Author

@nsamartsev nsamartsev May 28, 2026

Choose a reason for hiding this comment

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

The same.

The guard is needed because we can no longer pass the Apiary struct directly to flattenConfidentialInstanceConfig (type changed to map[string]interface{}), so we have to build the map from struct fields manually - which requires a nil check.

You're right about the behavioral change.
I can fix it by always writing to hclData.
For example:

var cicFlat []map[string]interface{}
if instance.ConfidentialInstanceConfig != nil {
    cicFlat = flattenConfidentialInstanceConfig(map[string]interface{}{...})
}
hclData["confidential_instance_config"] = cicFlat

@nsamartsev nsamartsev force-pushed the resource-compute-region-instance-ConfidentialInstanceConfig-migration branch from 34598af to 34c70ae Compare May 28, 2026 17:41
@github-actions github-actions Bot requested a review from slevenick May 28, 2026 17:44
@modular-magician
Copy link
Copy Markdown
Collaborator

modular-magician commented May 28, 2026

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 34c70ae:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 83 insertions(+), 62 deletions(-)
google-beta provider View Diff 4 files changed, 87 insertions(+), 66 deletions(-)
terraform-google-conversion View Diff 4 files changed, 54 insertions(+), 43 deletions(-)

Test report

Analytics

Total Tests Passed Skipped Affected
1462 1369 93 0
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

🟢 All tests passed in Replaying mode! No Recording was needed.

View the replaying VCR build log

@nsamartsev, @slevenick VCR tests complete for 34c70ae!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants