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

Store project and region in state #784

Merged
merged 2 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions google/resource_bigquery_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func resourceBigQueryDataset() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -227,6 +228,7 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error
return handleNotFoundError(err, d, fmt.Sprintf("BigQuery dataset %q", datasetID))
}

d.Set("project", projectID)
d.Set("etag", res.Etag)
d.Set("labels", res.Labels)
d.Set("self_link", res.SelfLink)
Expand Down
2 changes: 2 additions & 0 deletions google/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func resourceBigQueryTable() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -316,6 +317,7 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error {
return handleNotFoundError(err, d, fmt.Sprintf("BigQuery table %q", tableID))
}

d.Set("project", projectID)
d.Set("description", res.Description)
d.Set("expiration_time", res.ExpirationTime)
d.Set("friendly_name", res.FriendlyName)
Expand Down
2 changes: 2 additions & 0 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func resourceBigtableInstance() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
Expand Down Expand Up @@ -160,6 +161,7 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error retrieving instance. Could not find %s. %s", d.Id(), err)
}

d.Set("project", project)
d.Set("name", instance.Name)
d.Set("display_name", instance.DisplayName)

Expand Down
3 changes: 3 additions & 0 deletions google/resource_bigtable_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func resourceBigtableTable() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
Expand Down Expand Up @@ -109,6 +110,8 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error retrieving table. Could not find %s in %s. %s", name, instanceName, err)
}

d.Set("project", project)

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func resourceComputeAddress() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -197,6 +198,7 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error
d.Set("address", addr.Address)
d.Set("self_link", ConvertSelfLinkToV1(addr.SelfLink))
d.Set("name", addr.Name)
d.Set("project", addressId.Project)
d.Set("region", GetResourceNameFromSelfLink(addr.Region))

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func resourceComputeAutoscaler() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -316,6 +317,7 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err
return nil
}

d.Set("project", project)
d.Set("self_link", scaler.SelfLink)
d.Set("name", scaler.Name)
d.Set("target", scaler.Target)
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_backend_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func resourceComputeBackendBucket() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -119,6 +120,7 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{})
d.Set("bucket_name", bucket.BucketName)
d.Set("description", bucket.Description)
d.Set("enable_cdn", bucket.EnableCdn)
d.Set("project", project)
d.Set("self_link", bucket.SelfLink)

return nil
Expand Down
3 changes: 2 additions & 1 deletion google/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func resourceComputeBackendService() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -236,7 +237,7 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{})
d.Set("backend", flattenBackends(service.Backends))
d.Set("connection_draining_timeout_sec", service.ConnectionDraining.DrainingTimeoutSec)
d.Set("iap", flattenIap(service.Iap))

d.Set("project", project)
d.Set("health_checks", service.HealthChecks)

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func resourceComputeDisk() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -313,6 +314,7 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
d.Set("snapshot", disk.SourceSnapshot)
d.Set("labels", disk.Labels)
d.Set("label_fingerprint", disk.LabelFingerprint)
d.Set("project", project)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_global_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func resourceComputeGlobalAddress() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -98,6 +99,7 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{})
d.Set("name", addr.Name)
d.Set("ip_version", addr.IpVersion)
d.Set("address", addr.Address)
d.Set("project", project)
d.Set("self_link", ConvertSelfLinkToV1(addr.SelfLink))

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_global_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -288,6 +289,7 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf
d.Set("self_link", ConvertSelfLinkToV1(frule.SelfLink))
d.Set("labels", frule.Labels)
d.Set("label_fingerprint", frule.LabelFingerprint)
d.Set("project", project)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_https_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func resourceComputeHttpsHealthCheck() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -220,6 +221,7 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{
d.Set("port", hchk.Port)
d.Set("timeout_sec", hchk.TimeoutSec)
d.Set("unhealthy_threshold", hchk.UnhealthyThreshold)
d.Set("project", project)
d.Set("self_link", hchk.SelfLink)

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func resourceComputeImage() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -204,6 +205,7 @@ func resourceComputeImageRead(d *schema.ResourceData, meta interface{}) error {
d.Set("self_link", image.SelfLink)
d.Set("labels", image.Labels)
d.Set("label_fingerprint", image.LabelFingerprint)
d.Set("project", project)

return nil
}
Expand Down
7 changes: 7 additions & 0 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func resourceComputeInstance() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -786,6 +787,11 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

project, err := getProject(d, config)
if err != nil {
return err
}

instance, err := getInstance(config, d)
if err != nil || instance == nil {
return err
Expand Down Expand Up @@ -956,6 +962,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
d.Set("min_cpu_platform", instance.MinCpuPlatform)
d.Set("self_link", ConvertSelfLinkToV1(instance.SelfLink))
d.Set("instance_id", fmt.Sprintf("%d", instance.Id))
d.Set("project", project)
d.SetId(instance.Name)

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_instance_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func resourceComputeInstanceGroup() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -232,6 +233,7 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{})
// Set computed fields
d.Set("network", instanceGroup.Network)
d.Set("size", instanceGroup.Size)
d.Set("project", project)
d.Set("self_link", instanceGroup.SelfLink)

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func resourceComputeNetwork() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -117,6 +118,7 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error
d.Set("self_link", network.SelfLink)
d.Set("name", network.Name)
d.Set("auto_create_subnetworks", network.AutoCreateSubnetworks)
d.Set("project", project)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_project_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func resourceComputeProjectMetadata() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
Expand Down Expand Up @@ -115,6 +116,7 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("Error setting metadata: %s", err)
}

d.Set("project", project)
d.SetId("common_metadata")

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_project_metadata_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func resourceComputeProjectMetadataItem() *schema.Resource {
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
Expand Down Expand Up @@ -80,6 +81,7 @@ func resourceComputeProjectMetadataItemRead(d *schema.ResourceData, meta interfa
return nil
}

d.Set("project", projectID)
d.Set("key", d.Id())
d.Set("value", val)

Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_region_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func resourceComputeRegionAutoscaler() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -125,6 +126,7 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{
d.Set("target", scaler.Target)
d.Set("region", GetResourceNameFromSelfLink(scaler.Region))
d.Set("description", scaler.Description)
d.Set("project", project)
if scaler.AutoscalingPolicy != nil {
d.Set("autoscaling_policy", flattenAutoscalingPolicy(scaler.AutoscalingPolicy))
}
Expand Down
4 changes: 4 additions & 0 deletions google/resource_compute_region_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func resourceComputeRegionBackendService() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand All @@ -83,6 +84,7 @@ func resourceComputeRegionBackendService() *schema.Resource {
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -211,6 +213,8 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf
d.Set("self_link", service.SelfLink)
d.Set("backend", flattenBackends(service.Backends))
d.Set("health_checks", service.HealthChecks)
d.Set("project", project)
d.Set("region", region)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func resourceComputeRoute() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -217,6 +218,7 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error {
d.Set("next_hop_vpn_tunnel", route.NextHopVpnTunnel)
d.Set("tags", route.Tags)
d.Set("next_hop_network", route.NextHopNetwork)
d.Set("project", project)
d.Set("self_link", route.SelfLink)

return nil
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func resourceComputeSnapshot() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -174,6 +175,7 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error

d.Set("labels", snapshot.Labels)
d.Set("label_fingerprint", snapshot.LabelFingerprint)
d.Set("project", project)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_ssl_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func resourceComputeSslCertificate() *schema.Resource {
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -148,6 +149,7 @@ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{})
d.Set("description", cert.Description)
d.Set("name", cert.Name)
d.Set("certificate", cert.Certificate)
d.Set("project", project)

return nil
}
Expand Down
Loading