Skip to content

Commit

Permalink
Output from magician generating into ga and beta providers (#2271)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @danawillow
  • Loading branch information
modular-magician authored and danawillow committed Oct 19, 2018
1 parent f6e6146 commit ba1a535
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
6 changes: 3 additions & 3 deletions google/iam_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import (

var IamComputeSubnetworkSchema = map[string]*schema.Schema{
"subnetwork": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"project": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

"region": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
Expand Down
20 changes: 16 additions & 4 deletions google/resource_compute_instance_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,14 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
}

manager, err := getManager(d, meta)
if err != nil || manager == nil {
if err != nil {
return err
}
if manager == nil {
log.Printf("[WARN] Instance Group Manager %q not found, removing from state.", d.Id())
d.SetId("")
return nil
}

d.Set("base_instance_name", manager.BaseInstanceName)
d.Set("instance_template", ConvertSelfLinkToV1(manager.InstanceTemplate))
Expand All @@ -452,17 +457,24 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
d.Set("description", manager.Description)
d.Set("project", project)
d.Set("target_size", manager.TargetSize)
d.Set("target_pools", manager.TargetPools)
d.Set("named_port", flattenNamedPortsBeta(manager.NamedPorts))
if err = d.Set("target_pools", manager.TargetPools); err != nil {
return fmt.Errorf("Error setting target_pools in state: %s", err.Error())
}
if err = d.Set("named_port", flattenNamedPortsBeta(manager.NamedPorts)); err != nil {
return fmt.Errorf("Error setting named_port in state: %s", err.Error())
}
d.Set("fingerprint", manager.Fingerprint)
d.Set("instance_group", ConvertSelfLinkToV1(manager.InstanceGroup))
d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink))

update_strategy, ok := d.GetOk("update_strategy")
if !ok {
update_strategy = "REPLACE"
}
d.Set("update_strategy", update_strategy.(string))
d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies))
if err = d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies)); err != nil {
return fmt.Errorf("Error setting auto_healing_policies in state: %s", err.Error())
}

if d.Get("wait_for_instances").(bool) {
conf := resource.StateChangeConf{
Expand Down
4 changes: 2 additions & 2 deletions google/resource_compute_instance_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ func TestAccInstanceGroupManager_rollingUpdatePolicy(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceGroupManagerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccInstanceGroupManager_rollingUpdatePolicy(igm),
},
// No import step because rolling updates are broken and the field will be removed in 2.0.0.
// TODO(danawillow): Remove this test once we've removed the field.
resource.TestStep{
{
Config: testAccInstanceGroupManager_rollingUpdatePolicy2(igm),
},
},
Expand Down
23 changes: 17 additions & 6 deletions google/resource_compute_region_instance_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
},

"rolling_update_policy": &schema.Schema{
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"minimal_action": &schema.Schema{
Expand Down Expand Up @@ -368,9 +368,14 @@ func waitForInstancesRefreshFunc(f getInstanceManagerFunc, d *schema.ResourceDat
func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
manager, err := getRegionalManager(d, meta)
if err != nil || manager == nil {
if err != nil {
return err
}
if manager == nil {
log.Printf("[WARN] Region Instance Group Manager %q not found, removing from state.", d.Id())
d.SetId("")
return nil
}

regionalID, err := parseRegionInstanceGroupManagerId(d.Id())
if err != nil {
Expand All @@ -384,7 +389,7 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
}

d.Set("base_instance_name", manager.BaseInstanceName)
d.Set("instance_template", manager.InstanceTemplate)
d.Set("instance_template", ConvertSelfLinkToV1(manager.InstanceTemplate))
if err := d.Set("version", flattenVersions(manager.Versions)); err != nil {
return err
}
Expand All @@ -393,11 +398,17 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
d.Set("description", manager.Description)
d.Set("project", regionalID.Project)
d.Set("target_size", manager.TargetSize)
d.Set("target_pools", manager.TargetPools)
d.Set("named_port", flattenNamedPortsBeta(manager.NamedPorts))
if err := d.Set("target_pools", manager.TargetPools); err != nil {
return fmt.Errorf("Error setting target_pools in state: %s", err.Error())
}
if err := d.Set("named_port", flattenNamedPortsBeta(manager.NamedPorts)); err != nil {
return fmt.Errorf("Error setting named_port in state: %s", err.Error())
}
d.Set("fingerprint", manager.Fingerprint)
d.Set("instance_group", ConvertSelfLinkToV1(manager.InstanceGroup))
d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies))
if err := d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies)); err != nil {
return fmt.Errorf("Error setting auto_healing_policies in state: %s", err.Error())
}
if err := d.Set("distribution_policy_zones", flattenDistributionPolicy(manager.DistributionPolicy)); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions google/resource_compute_region_instance_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ func TestAccRegionInstanceGroupManager_rollingUpdatePolicy(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceGroupManagerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccRegionInstanceGroupManager_rollingUpdatePolicy(igm),
},
// No import step because rolling updates are broken and the field will be removed in 2.0.0.
// TODO(danawillow): Remove this test once we've removed the field.
resource.TestStep{
{
Config: testAccRegionInstanceGroupManager_rollingUpdatePolicy2(igm),
},
},
Expand Down Expand Up @@ -698,6 +698,7 @@ resource "google_compute_http_health_check" "zero" {
}
`, template, target, igm, hck)
}

func testAccRegionInstanceGroupManager_versions(primaryTemplate string, canaryTemplate string, igm string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down
2 changes: 1 addition & 1 deletion google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ func resourceContainerCluster() *schema.Resource {

"private_cluster": {
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Default: false,
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
},

"master_ipv4_cidr_block": {
Expand Down

0 comments on commit ba1a535

Please sign in to comment.