Skip to content

Commit b8bc157

Browse files
chrisstmodular-magician
authored andcommitted
Allow duration to be updatable and force new
1 parent b4a0e96 commit b8bc157

3 files changed

+62
-7
lines changed

google/resource_appengine_firewall_rule_generated_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package google
1616

1717
import (
1818
"fmt"
19+
"strings"
1920
"testing"
2021

2122
"github.com/hashicorp/terraform/helper/acctest"
@@ -71,10 +72,13 @@ resource "google_appengine_firewall_rule" "rule" {
7172
}
7273

7374
func testAccCheckAppengineFirewallRuleDestroy(s *terraform.State) error {
74-
for _, rs := range s.RootModule().Resources {
75+
for name, rs := range s.RootModule().Resources {
7576
if rs.Type != "google_appengine_firewall_rule" {
7677
continue
7778
}
79+
if strings.HasPrefix(name, "data.") {
80+
continue
81+
}
7882

7983
config := testAccProvider.Meta().(*Config)
8084

google/resource_compute_image_generated_test.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ import (
2727
func TestAccComputeImage_imageBasicExample(t *testing.T) {
2828
t.Parallel()
2929

30+
context := map[string]interface{}{
31+
"random_suffix": acctest.RandString(10),
32+
}
33+
3034
resource.Test(t, resource.TestCase{
3135
PreCheck: func() { testAccPreCheck(t) },
3236
Providers: testAccProviders,
3337
CheckDestroy: testAccCheckComputeImageDestroy,
3438
Steps: []resource.TestStep{
3539
{
36-
Config: testAccComputeImage_imageBasicExample(acctest.RandString(10)),
40+
Config: testAccComputeImage_imageBasicExample(context),
3741
},
3842
{
3943
ResourceName: "google_compute_image.example",
@@ -45,17 +49,16 @@ func TestAccComputeImage_imageBasicExample(t *testing.T) {
4549
})
4650
}
4751

48-
func testAccComputeImage_imageBasicExample(val string) string {
49-
return fmt.Sprintf(`
52+
func testAccComputeImage_imageBasicExample(context map[string]interface{}) string {
53+
return Nprintf(`
5054
resource "google_compute_image" "example" {
51-
name = "example-image-%s"
55+
name = "example-image-%{random_suffix}"
5256
5357
raw_disk {
5458
source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"
5559
}
5660
}
57-
`, val,
58-
)
61+
`, context)
5962
}
6063

6164
func testAccCheckComputeImageDestroy(s *terraform.State) error {

google/resource_monitoring_uptime_check_config.go

+48
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"log"
2020
"reflect"
2121
"strconv"
22+
"strings"
2223
"time"
2324

2425
"github.com/hashicorp/terraform/helper/schema"
@@ -461,6 +462,53 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
461462
}
462463

463464
log.Printf("[DEBUG] Updating UptimeCheckConfig %q: %#v", d.Id(), obj)
465+
updateMask := []string{}
466+
467+
if d.HasChange("display_name") {
468+
updateMask = append(updateMask, "displayName")
469+
}
470+
471+
if d.HasChange("timeout") {
472+
updateMask = append(updateMask, "timeout")
473+
}
474+
475+
if d.HasChange("content_matchers") {
476+
updateMask = append(updateMask, "contentMatchers")
477+
}
478+
479+
if d.HasChange("selected_regions") {
480+
updateMask = append(updateMask, "selectedRegions")
481+
}
482+
483+
if d.HasChange("is_internal") {
484+
updateMask = append(updateMask, "isInternal")
485+
}
486+
487+
if d.HasChange("internal_checkers") {
488+
updateMask = append(updateMask, "internalCheckers")
489+
}
490+
491+
if d.HasChange("http_check") {
492+
updateMask = append(updateMask, "httpCheck")
493+
}
494+
495+
if d.HasChange("tcp_check") {
496+
updateMask = append(updateMask, "tcpCheck")
497+
}
498+
499+
if d.HasChange("resource_group") {
500+
updateMask = append(updateMask, "resourceGroup")
501+
}
502+
503+
if d.HasChange("monitored_resource") {
504+
updateMask = append(updateMask, "monitoredResource")
505+
}
506+
// updateMask is a URL parameter but not present in the schema, so replaceVars
507+
// won't set it
508+
url, err = addQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
509+
if err != nil {
510+
return err
511+
}
464512
_, err = sendRequestWithTimeout(config, "PATCH", url, obj, d.Timeout(schema.TimeoutUpdate))
465513

466514
if err != nil {

0 commit comments

Comments
 (0)