Skip to content

Commit

Permalink
Remove google_compute_global_forwarding_rule.labels
Browse files Browse the repository at this point in the history
  • Loading branch information
rileykarson authored and modular-magician committed Nov 2, 2018
1 parent 79af789 commit bcf56e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {

"labels": &schema.Schema{
<% if version.nil? || version == 'ga' -%>
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.",
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
<% end -%>
Type: schema.TypeMap,
Optional: true,
Expand All @@ -67,6 +67,9 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
},

"label_fingerprint": &schema.Schema{
<% if version.nil? || version == 'ga' -%>
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
<% end -%>
Type: schema.TypeString,
Computed: true,
},
Expand Down Expand Up @@ -138,6 +141,7 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte
return err
}

<% unless version.nil? || version == 'ga' -%>
// If we have labels to set, try to set those too
if _, ok := d.GetOk("labels"); ok {
labels := expandLabels(d)
Expand All @@ -152,6 +156,7 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte
return err
}
}
<% end -%>

return resourceComputeGlobalForwardingRuleRead(d, meta)
}
Expand Down Expand Up @@ -183,6 +188,7 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte

d.SetPartial("target")
}
<% unless version.nil? || version == 'ga' -%>
if d.HasChange("labels") {
labels := expandLabels(d)
fingerprint := d.Get("label_fingerprint").(string)
Expand All @@ -194,6 +200,7 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte

d.SetPartial("labels")
}
<% end -%>

d.Partial(false)

Expand Down Expand Up @@ -221,8 +228,13 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf
d.Set("ip_protocol", frule.IPProtocol)
d.Set("ip_version", frule.IpVersion)
d.Set("self_link", ConvertSelfLinkToV1(frule.SelfLink))
<% unless version.nil? || version == 'ga' -%>
d.Set("labels", frule.Labels)
d.Set("label_fingerprint", frule.LabelFingerprint)
<% else -%>
// removed lists need something set
d.Set("labels", nil)
<% end -%>
d.Set("project", project)

return nil
Expand Down Expand Up @@ -251,6 +263,7 @@ func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta inte
return nil
}

<% unless version.nil? || version == 'ga' -%>
// resourceComputeGlobalForwardingRuleReadLabelFingerprint performs a read on the remote resource and returns only the
// fingerprint. Used on create when setting labels as we don't know the label fingerprint initially.
func resourceComputeGlobalForwardingRuleReadLabelFingerprint(config *Config, project, name string) (string, error) {
Expand Down Expand Up @@ -280,3 +293,4 @@ func resourceComputeGlobalForwardingRuleSetLabels(config *Config, project, name

return nil
}
<% end -%>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% autogen_exception -%>
package google

import (
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestAccComputeGlobalForwardingRule_ipv6(t *testing.T) {
})
}

<% unless version.nil? || version == 'ga' -%>
func TestAccComputeGlobalForwardingRule_labels(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -153,6 +155,7 @@ func TestAccComputeGlobalForwardingRule_labels(t *testing.T) {
},
})
}
<% end -%>

func testAccCheckComputeGlobalForwardingRuleDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
Expand Down Expand Up @@ -253,7 +256,7 @@ func testAccCheckComputeBetaGlobalForwardingRuleIpVersion(n, version string) res
return nil
}
}

<% unless version.nil? || version == 'ga' -%>
func testAccCheckComputeBetaGlobalForwardingRuleHasLabel(frule *computeBeta.ForwardingRule, key, value string) resource.TestCheckFunc {
return func(s *terraform.State) error {
val, ok := frule.Labels[key]
Expand All @@ -267,7 +270,9 @@ func testAccCheckComputeBetaGlobalForwardingRuleHasLabel(frule *computeBeta.Forw
return nil
}
}
<% end -%>

<% unless version.nil? || version == 'ga' -%>
func testAccCheckComputeBetaGlobalForwardingRuleHasCorrectLabelFingerprint(
frule *computeBeta.ForwardingRule, resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand All @@ -281,6 +286,7 @@ func testAccCheckComputeBetaGlobalForwardingRuleHasCorrectLabelFingerprint(
return nil
}
}
<% end -%>

func testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap string) string {
return fmt.Sprintf(`
Expand Down Expand Up @@ -339,6 +345,7 @@ func testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc,
}`, fr, proxy1, proxy2, backend, hc, urlmap)
}

<% unless version.nil? || version == 'ga' -%>
func testAccComputeGlobalForwardingRule_labels(fr, proxy1, proxy2, backend, hc, urlmap string) string {
return fmt.Sprintf(`
resource "google_compute_global_forwarding_rule" "foobar" {
Expand Down Expand Up @@ -400,7 +407,9 @@ func testAccComputeGlobalForwardingRule_labels(fr, proxy1, proxy2, backend, hc,
}
}`, fr, proxy1, proxy2, backend, hc, urlmap)
}
<% end -%>

<% unless version.nil? || version == 'ga' -%>
func testAccComputeGlobalForwardingRule_labelsUpdated(fr, proxy1, proxy2, backend, hc, urlmap string) string {
return fmt.Sprintf(`
resource "google_compute_global_forwarding_rule" "foobar" {
Expand Down Expand Up @@ -462,6 +471,7 @@ func testAccComputeGlobalForwardingRule_labelsUpdated(fr, proxy1, proxy2, backen
}
}`, fr, proxy1, proxy2, backend, hc, urlmap)
}
<% end -%>

func testAccComputeGlobalForwardingRule_basic2(fr, proxy1, proxy2, backend, hc, urlmap string) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit bcf56e8

Please sign in to comment.