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 the set project logic higher in the read method #2503

Merged
merged 1 commit into from
Nov 20, 2018
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
15 changes: 8 additions & 7 deletions google/resource_compute_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error
return handleNotFoundError(err, d, fmt.Sprintf("ComputeAddress %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Address: %s", err)
}

if err := d.Set("address", flattenComputeAddressAddress(res["address"])); err != nil {
return fmt.Errorf("Error reading Address: %s", err)
}
Expand Down Expand Up @@ -244,13 +252,6 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading Address: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Address: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err
return handleNotFoundError(err, d, fmt.Sprintf("ComputeAutoscaler %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Autoscaler: %s", err)
}

if err := d.Set("creation_timestamp", flattenComputeAutoscalerCreationTimestamp(res["creationTimestamp"])); err != nil {
return fmt.Errorf("Error reading Autoscaler: %s", err)
}
Expand All @@ -266,13 +274,6 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading Autoscaler: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Autoscaler: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_backend_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{})
return handleNotFoundError(err, d, fmt.Sprintf("ComputeBackendBucket %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading BackendBucket: %s", err)
}

if err := d.Set("bucket_name", flattenComputeBackendBucketBucketName(res["bucketName"])); err != nil {
return fmt.Errorf("Error reading BackendBucket: %s", err)
}
Expand All @@ -181,13 +189,6 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{})
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading BackendBucket: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading BackendBucket: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
return err
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}

if err := d.Set("label_fingerprint", flattenComputeDiskLabelFingerprint(res["labelFingerprint"])); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}
Expand Down Expand Up @@ -614,13 +622,6 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error
return handleNotFoundError(err, d, fmt.Sprintf("ComputeFirewall %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Firewall: %s", err)
}

if err := d.Set("allow", flattenComputeFirewallAllow(res["allowed"])); err != nil {
return fmt.Errorf("Error reading Firewall: %s", err)
}
Expand Down Expand Up @@ -407,13 +415,6 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading Firewall: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading Firewall: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
return handleNotFoundError(err, d, fmt.Sprintf("ComputeForwardingRule %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}

if err := d.Set("creation_timestamp", flattenComputeForwardingRuleCreationTimestamp(res["creationTimestamp"])); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
Expand Down Expand Up @@ -347,13 +355,6 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_global_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{})
return handleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalAddress %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading GlobalAddress: %s", err)
}

if err := d.Set("address", flattenComputeGlobalAddressAddress(res["address"])); err != nil {
return fmt.Errorf("Error reading GlobalAddress: %s", err)
}
Expand All @@ -194,13 +202,6 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{})
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading GlobalAddress: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading GlobalAddress: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ func resourceComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) er
return handleNotFoundError(err, d, fmt.Sprintf("ComputeHealthCheck %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HealthCheck: %s", err)
}

if err := d.Set("check_interval_sec", flattenComputeHealthCheckCheckIntervalSec(res["checkIntervalSec"])); err != nil {
return fmt.Errorf("Error reading HealthCheck: %s", err)
}
Expand Down Expand Up @@ -378,13 +386,6 @@ func resourceComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) er
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading HealthCheck: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HealthCheck: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_http_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{}
return handleNotFoundError(err, d, fmt.Sprintf("ComputeHttpHealthCheck %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HttpHealthCheck: %s", err)
}

if err := d.Set("check_interval_sec", flattenComputeHttpHealthCheckCheckIntervalSec(res["checkIntervalSec"])); err != nil {
return fmt.Errorf("Error reading HttpHealthCheck: %s", err)
}
Expand Down Expand Up @@ -252,13 +260,6 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{}
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading HttpHealthCheck: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HttpHealthCheck: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_https_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{
return handleNotFoundError(err, d, fmt.Sprintf("ComputeHttpsHealthCheck %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
}

if err := d.Set("check_interval_sec", flattenComputeHttpsHealthCheckCheckIntervalSec(res["checkIntervalSec"])); err != nil {
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
}
Expand Down Expand Up @@ -252,13 +260,6 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading HttpsHealthCheck: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_interconnect_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
return handleNotFoundError(err, d, fmt.Sprintf("ComputeInterconnectAttachment %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}

if err := d.Set("cloud_router_ip_address", flattenComputeInterconnectAttachmentCloudRouterIpAddress(res["cloudRouterIpAddress"])); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
Expand Down Expand Up @@ -238,13 +246,6 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_region_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{
return handleNotFoundError(err, d, fmt.Sprintf("ComputeRegionAutoscaler %q", d.Id()))
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading RegionAutoscaler: %s", err)
}

if err := d.Set("creation_timestamp", flattenComputeRegionAutoscalerCreationTimestamp(res["creationTimestamp"])); err != nil {
return fmt.Errorf("Error reading RegionAutoscaler: %s", err)
}
Expand All @@ -265,13 +273,6 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading RegionAutoscaler: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading RegionAutoscaler: %s", err)
}

return nil
}
Expand Down
15 changes: 8 additions & 7 deletions google/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
return err
}

project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}

if err := d.Set("label_fingerprint", flattenComputeRegionDiskLabelFingerprint(res["labelFingerprint"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
Expand Down Expand Up @@ -366,13 +374,6 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
project, err := getProject(d, config)
if err != nil {
return err
}
if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}

return nil
}
Expand Down
Loading