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

Move shieldedvmconfig -> shieldedinstanceconfig due to rename. #3822

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func dataSourceGoogleComputeInstanceRead(d *schema.ResourceData, meta interface{
return err
}

err = d.Set("shielded_instance_config", flattenShieldedVmConfig(instance.ShieldedVmConfig))
err = d.Set("shielded_instance_config", flattenShieldedVmConfig(instance.ShieldedInstanceConfig))
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func expandComputeInstance(project string, d *schema.ResourceData, config *Confi
DeletionProtection: d.Get("deletion_protection").(bool),
Hostname: d.Get("hostname").(string),
ForceSendFields: []string{"CanIpForward", "DeletionProtection"},
ShieldedVmConfig: expandShieldedVmConfigs(d),
ShieldedInstanceConfig: expandShieldedVmConfigs(d),
DisplayDevice: expandDisplayDevice(d),
ResourcePolicies: convertStringArr(d.Get("resource_policies").([]interface{})),
}, nil
Expand Down Expand Up @@ -1098,7 +1098,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
d.Set("scratch_disk", scratchDisks)
d.Set("scheduling", flattenScheduling(instance.Scheduling))
d.Set("guest_accelerator", flattenGuestAccelerators(instance.GuestAccelerators))
d.Set("shielded_instance_config", flattenShieldedVmConfig(instance.ShieldedVmConfig))
d.Set("shielded_instance_config", flattenShieldedVmConfig(instance.ShieldedInstanceConfig))
d.Set("enable_display", flattenEnableDisplay(instance.DisplayDevice))
d.Set("cpu_platform", instance.CpuPlatform)
d.Set("min_cpu_platform", instance.MinCpuPlatform)
Expand Down Expand Up @@ -1628,7 +1628,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
if d.HasChange("shielded_instance_config") {
shieldedVmConfig := expandShieldedVmConfigs(d)

op, err := config.clientComputeBeta.Instances.UpdateShieldedVmConfig(project, zone, instance.Name, shieldedVmConfig).Do()
op, err := config.clientComputeBeta.Instances.UpdateShieldedInstanceConfig(project, zone, instance.Name, shieldedVmConfig).Do()
if err != nil {
return fmt.Errorf("Error updating shielded vm config: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac
Scheduling: scheduling,
ServiceAccounts: expandServiceAccounts(d.Get("service_account").([]interface{})),
Tags: resourceInstanceTags(d),
ShieldedVmConfig: expandShieldedVmConfigs(d),
ShieldedInstanceConfig: expandShieldedVmConfigs(d),
DisplayDevice: expandDisplayDevice(d),
}

Expand Down Expand Up @@ -1199,7 +1199,7 @@ func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{
}
}
if instanceTemplate.Properties.ShieldedVmConfig != nil {
if err = d.Set("shielded_instance_config", flattenShieldedVmConfig(instanceTemplate.Properties.ShieldedVmConfig)); err != nil {
if err = d.Set("shielded_instance_config", flattenShieldedVmConfig(instanceTemplate.Properties.ShieldedInstanceConfig)); err != nil {
return fmt.Errorf("Error setting shielded_instance_config: %s", err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions third_party/terraform/utils/compute_instance_helpers.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,21 @@ func resourceInstanceTags(d TerraformResourceData) *computeBeta.Tags {
return tags
}

func expandShieldedVmConfigs(d TerraformResourceData) *computeBeta.ShieldedVmConfig {
func expandShieldedVmConfigs(d TerraformResourceData) *computeBeta.ShieldedInstanceConfig {
if _, ok := d.GetOk("shielded_instance_config"); !ok {
return nil
}

prefix := "shielded_instance_config.0"
return &computeBeta.ShieldedVmConfig{
return &computeBeta.ShieldedInstanceConfig{
EnableSecureBoot: d.Get(prefix + ".enable_secure_boot").(bool),
EnableVtpm: d.Get(prefix + ".enable_vtpm").(bool),
EnableIntegrityMonitoring: d.Get(prefix + ".enable_integrity_monitoring").(bool),
ForceSendFields: []string{"EnableSecureBoot", "EnableVtpm", "EnableIntegrityMonitoring"},
}
}

func flattenShieldedVmConfig(shieldedVmConfig *computeBeta.ShieldedVmConfig) []map[string]bool {
func flattenShieldedVmConfig(shieldedVmConfig *computeBeta.ShieldedInstanceConfig) []map[string]bool {
if shieldedVmConfig == nil {
return nil
}
Expand Down