Skip to content

Commit

Permalink
Removing deprecated fields (#2436)
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 authored and rileykarson committed Nov 11, 2019
1 parent b47312f commit 8402a21
Show file tree
Hide file tree
Showing 28 changed files with 389 additions and 710 deletions.
29 changes: 0 additions & 29 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2718,16 +2718,6 @@ objects:
description: |
A BackendService to receive the matched traffic. This is used only
for INTERNAL load balancing.
- !ruby/object:Api::Type::Enum
name: 'ipVersion'
deprecation_message: >-
ipVersion is not used for regional forwarding rules. Please remove
this field if you are using it.
description: |
ipVersion is not a valid field for regional forwarding rules.
values:
- :IPV4
- :IPV6
- !ruby/object:Api::Type::Enum
name: 'loadBalancingScheme'
description: |
Expand Down Expand Up @@ -5934,25 +5924,6 @@ objects:
name: 'id'
description: 'The unique identifier for the resource.'
output: true
- !ruby/object:Api::Type::String
name: 'ipv4_range'
# We override this in api.yaml so that the name is more aesthetic
api_name: 'IPv4Range'
deprecation_message: >-
Legacy Networks are deprecated and you will no longer be able to
create them using this field from Feb 1, 2020 onwards.
input: true
conflicts:
- autoCreateSubnetworks
description: |
If this field is specified, a deprecated legacy network is created.
You will no longer be able to create a legacy network on Feb 1, 2020.
See the [legacy network docs](https://cloud.google.com/vpc/docs/legacy)
for more details.
The range of internal addresses that are legal on this legacy network.
This range is a CIDR specification, for example: `192.168.0.0/16`.
The resource must be recreated to modify this field.
- !ruby/object:Api::Type::String
name: 'name'
description: |
Expand Down
5 changes: 2 additions & 3 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
network_name: "website-net"
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/labels.erb
extra_schema_entry: templates/terraform/extra_schema_entry/forwarding_rule.erb
properties:
id: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
Expand Down Expand Up @@ -923,9 +924,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
default_value: True
# autoCreateSubnetworks defaults to true, so we need to disable it explicitly
conflicts: []
ipv4_range: !ruby/object:Overrides::Terraform::PropertyOverride
# autoCreateSubnetworks defaults to true, so we need to disable it explicitly
conflicts: []
routingConfig: !ruby/object:Overrides::Terraform::PropertyOverride
flatten_object: true
routingConfig.routingMode: !ruby/object:Overrides::Terraform::PropertyOverride
Expand All @@ -939,6 +937,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
default_from_api: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/compute_network_delete_default_route.erb
extra_schema_entry: templates/terraform/extra_schema_entry/network.erb
encoder: templates/terraform/encoders/network.erb
NetworkEndpoint: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "{{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}"
Expand Down
1 change: 0 additions & 1 deletion products/monitoring/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
group_display_name: "uptime-check-group"
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/self_link_as_name.erb
decoder: 'templates/terraform/decoders/monitoring_uptime_check_internal.go.erb'
extra_schema_entry: 'templates/terraform/extra_schema_entry/monitoring_uptime_check_config_internal.go.erb'
post_create: templates/terraform/post_create/set_computed_name.erb
properties:
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion templates/terraform/extra_schema_entry/alert_policy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
Elem: &schema.Schema{
Type: schema.TypeString,
},
Deprecated: "labels is removed as it was never used. See user_labels for the correct field",
Removed: "labels is removed as it was never used. See user_labels for the correct field",
},
19 changes: 19 additions & 0 deletions templates/terraform/extra_schema_entry/forwarding_rule.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%# The license inside this block applies to this file.
# Copyright 2019 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
"ip_version": {
Type: schema.TypeString,
Optional: true,
Removed: "ipVersion is not used for regional forwarding rules. Please remove this field if you are using it.",
},
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,38 @@
"is_internal": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
"internal_checkers": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"display_name": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
"gcp_zone": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
"name": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
"network": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
"peer_project_id": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Removed: "This field never worked, and will be removed in 3.0.0.",
},
},
},
Expand Down
19 changes: 19 additions & 0 deletions templates/terraform/extra_schema_entry/network.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%# The license inside this block applies to this file.
# Copyright 2019 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
"ipv4_range": {
Type: schema.TypeString,
Optional: true,
Removed: "Legacy Networks are deprecated and you will no longer be able to create them using this field from Feb 1, 2020 onwards.",
},
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ func dataSourceGoogleContainerEngineVersions() *schema.Resource {
"location": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"zone", "region"},
},
"zone": {
Type: schema.TypeString,
Optional: true,
Deprecated: "Use location instead",
ConflictsWith: []string{"region", "location"},
Removed: "Use location instead",
},
"region": {
Type: schema.TypeString,
Optional: true,
Deprecated: "Use location instead",
ConflictsWith: []string{"zone", "location"},
Removed: "Use location instead",
},
"default_cluster_version": {
Type: schema.TypeString,
Expand Down Expand Up @@ -76,7 +73,7 @@ func dataSourceGoogleContainerEngineVersionsRead(d *schema.ResourceData, meta in
return err
}
if len(location) == 0 {
return fmt.Errorf("Cannot determine location: set location, zone, or region in this data source or at provider-level")
return fmt.Errorf("Cannot determine location: set location in this data source or at provider-level")
}

location = fmt.Sprintf("projects/%s/locations/%s", project, location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ func resourceComputeNetworkPeering() *schema.Resource {
DiffSuppressFunc: compareSelfLinkRelativePaths,
},
// The API only accepts true as a value for exchange_subnet_routes or auto_create_routes (of which only one can be set in a valid request).
// Also, you can't set auto_create_routes if you use the networkPeering object. auto_create_routes is also deprecated
// Also, you can't set auto_create_routes if you use the networkPeering object. auto_create_routes is also removed
"auto_create_routes": {
Type: schema.TypeBool,
Optional: true,
Deprecated: "auto_create_routes has been deprecated because it's redundant and not user-configurable. It can safely be removed from your config",
Removed: "auto_create_routes has been removed because it's redundant and not user-configurable. It can safely be removed from your config",
ForceNew: true,
Default: true,
},
"state": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
<% if version == 'ga' -%>
"update_strategy": &schema.Schema{
Type: schema.TypeString,
Deprecated: "This field will be replaced by `update_policy` in 3.0.0",
Removed: "This field is removed.",
Optional: true,
ConflictsWith: []string{"update_policy"},
},
<% end -%>

Expand Down
101 changes: 5 additions & 96 deletions third_party/terraform/resources/resource_container_cluster.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,18 @@ func resourceContainerCluster() *schema.Resource {
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"zone", "region"},
},

"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "Use location instead",
ConflictsWith: []string{"zone", "location"},
Removed: "Use location instead",
},

"zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "Use location instead",
ConflictsWith: []string{"region", "location"},
Removed: "Use location instead",
},

"node_locations": {
Expand All @@ -162,8 +155,7 @@ func resourceContainerCluster() *schema.Resource {
"additional_zones": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Deprecated: "Use node_locations instead",
Removed: "Use node_locations instead",
Elem: &schema.Schema{Type: schema.TypeString},
},

Expand Down Expand Up @@ -1005,14 +997,6 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
return err
}

// When parsing a subnetwork by name, we expect region or zone to be set.
// Users may have set location to either value, so set that value.
if isZone(location) {
d.Set("zone", location)
} else {
d.Set("region", location)
}

clusterName := d.Get("name").(string)

cluster := &containerBeta.Cluster{
Expand Down Expand Up @@ -1072,20 +1056,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
if v, ok := d.GetOk("node_locations"); ok {
locationsSet := v.(*schema.Set)
if locationsSet.Contains(location) {
return fmt.Errorf("when using a multi-zonal cluster, additional_zones should not contain the original 'zone'")
}

// GKE requires a full list of node locations
// but when using a multi-zonal cluster our schema only asks for the
// additional zones, so append the cluster location if it's a zone
if isZone(location) {
locationsSet.Add(location)
}
cluster.Locations = convertStringSet(locationsSet)
} else if v, ok := d.GetOk("additional_zones"); ok {
locationsSet := v.(*schema.Set)
if locationsSet.Contains(location) {
return fmt.Errorf("when using a multi-zonal cluster, additional_zones should not contain the original 'zone'")
return fmt.Errorf("when using a multi-zonal cluster, node_locations should not contain the original 'zone'")
}

// GKE requires a full list of node locations
Expand Down Expand Up @@ -1259,16 +1230,10 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
}

d.Set("location", cluster.Location)
if isZone(cluster.Location) {
d.Set("zone", cluster.Location)
} else {
d.Set("region", cluster.Location)
}

locations := schema.NewSet(schema.HashString, convertStringArrToInterface(cluster.Locations))
locations.Remove(cluster.Zone) // Remove the original zone since we only store additional zones
d.Set("node_locations", locations)
d.Set("additional_zones", locations)

d.Set("endpoint", cluster.Endpoint)
if err := d.Set("maintenance_policy", flattenMaintenancePolicy(cluster.MaintenancePolicy)); err != nil {
Expand Down Expand Up @@ -1575,57 +1540,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
d.SetPartial("maintenance_policy")
}

// we can only ever see a change to one of additional_zones and node_locations; because
// thy conflict with each other and are each computed, Terraform will suppress the diff
// on one of them even when migrating from one to the other.
if d.HasChange("additional_zones") {
azSetOldI, azSetNewI := d.GetChange("additional_zones")
azSetNew := azSetNewI.(*schema.Set)
azSetOld := azSetOldI.(*schema.Set)
if azSetNew.Contains(location) {
return fmt.Errorf("additional_zones should not contain the original 'zone'")
}
// Since we can't add & remove zones in the same request, first add all the
// zones, then remove the ones we aren't using anymore.
azSet := azSetOld.Union(azSetNew)

if isZone(location) {
azSet.Add(location)
}

req := &containerBeta.UpdateClusterRequest{
Update: &containerBeta.ClusterUpdate{
DesiredLocations: convertStringSet(azSet),
},
}

updateF := updateFunc(req, "updating GKE cluster node locations")
// Call update serially.
if err := lockedCall(lockKey, updateF); err != nil {
return err
}

if isZone(location) {
azSetNew.Add(location)
}
if !azSet.Equal(azSetNew) {
req = &containerBeta.UpdateClusterRequest{
Update: &containerBeta.ClusterUpdate{
DesiredLocations: convertStringSet(azSetNew),
},
}

updateF := updateFunc(req, "updating GKE cluster node locations")
// Call update serially.
if err := lockedCall(lockKey, updateF); err != nil {
return err
}
}

log.Printf("[INFO] GKE cluster %s node locations have been updated to %v", d.Id(), azSet.List())

d.SetPartial("additional_zones")
} else if d.HasChange("node_locations") {
if d.HasChange("node_locations") {
azSetOldI, azSetNewI := d.GetChange("node_locations")
azSetNew := azSetNewI.(*schema.Set)
azSetOld := azSetOldI.(*schema.Set)
Expand Down Expand Up @@ -2948,12 +2863,6 @@ func resourceContainerClusterStateImporter(d *schema.ResourceData, meta interfac
}
d.Set("project", project)

d.Set("location", location)
if isZone(location) {
d.Set("zone", location)
} else {
d.Set("region", location)
}

d.Set("name", clusterName)
d.SetId(clusterName)
Expand Down
Loading

0 comments on commit 8402a21

Please sign in to comment.