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

Make zone field consistent and truly optional for all resources #914

Merged
merged 1 commit into from
Jan 3, 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
2 changes: 2 additions & 0 deletions google/data_source_google_compute_instance_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ func dataSourceGoogleComputeInstanceGroup() *schema.Resource {
"zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"description": {
Expand Down
7 changes: 7 additions & 0 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func resourceBigtableInstance() *schema.Resource {
"zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -152,6 +153,11 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
return err
}

zone, err := getZone(d, config)
if err != nil {
return err
}

c, err := config.bigtableClientFactory.NewInstanceAdminClient(project)
if err != nil {
return fmt.Errorf("Error starting instance admin client. %s", err)
Expand All @@ -167,6 +173,7 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
}

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

Expand Down
1 change: 1 addition & 0 deletions google/resource_compute_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func resourceComputeAutoscaler() *schema.Resource {
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

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

Expand Down Expand Up @@ -306,12 +307,10 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
disk = resource.(*compute.Disk)
}

zoneUrlParts := strings.Split(disk.Zone, "/")
typeUrlParts := strings.Split(disk.Type, "/")
d.Set("name", disk.Name)
d.Set("self_link", disk.SelfLink)
d.Set("type", typeUrlParts[len(typeUrlParts)-1])
d.Set("zone", zoneUrlParts[len(zoneUrlParts)-1])
d.Set("type", GetResourceNameFromSelfLink(disk.Type))
d.Set("zone", GetResourceNameFromSelfLink(disk.Zone))
d.Set("size", disk.SizeGb)
d.Set("users", disk.Users)
if disk.DiskEncryptionKey != nil && disk.DiskEncryptionKey.Sha256 != "" {
Expand Down
2 changes: 2 additions & 0 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func resourceComputeInstance() *schema.Resource {
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

Expand Down Expand Up @@ -861,6 +862,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
d.Set("self_link", ConvertSelfLinkToV1(instance.SelfLink))
d.Set("instance_id", fmt.Sprintf("%d", instance.Id))
d.Set("project", project)
d.Set("zone", GetResourceNameFromSelfLink(instance.Zone))
d.Set("name", instance.Name)
d.SetId(instance.Name)

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 @@ -34,6 +34,7 @@ func resourceComputeInstanceGroup() *schema.Resource {
"zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

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

return nil
Expand Down
1 change: 1 addition & 0 deletions google/resource_compute_instance_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

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

Expand Down Expand Up @@ -160,6 +161,11 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error
return err
}

zone, err := getZone(d, config)
if err != nil {
return err
}

snapshot, err := config.clientCompute.Snapshots.Get(
project, d.Id()).Do()
if err != nil {
Expand All @@ -181,6 +187,7 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error
d.Set("labels", snapshot.Labels)
d.Set("label_fingerprint", snapshot.LabelFingerprint)
d.Set("project", project)
d.Set("zone", zone)

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

Expand Down Expand Up @@ -622,6 +623,7 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
d.Set("network", cluster.Network)
d.Set("subnetwork", cluster.Subnetwork)
d.Set("node_config", flattenNodeConfig(cluster.NodeConfig))
d.Set("zone", zoneName)
d.Set("project", project)
if cluster.AddonsConfig != nil {
d.Set("addons_config", flattenClusterAddonsConfig(cluster.AddonsConfig))
Expand Down
2 changes: 2 additions & 0 deletions google/resource_container_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func resourceContainerNodePool() *schema.Resource {
"zone": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"cluster": &schema.Schema{
Expand Down Expand Up @@ -205,6 +206,7 @@ func resourceContainerNodePoolRead(d *schema.ResourceData, meta interface{}) err
d.Set(k, v)
}

d.Set("zone", zone)
d.Set("project", project)

return nil
Expand Down