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

Allow setting notification channel enabled to false #3874

Merged
merged 1 commit into from
Jun 18, 2019
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
1 change: 1 addition & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Config struct {
AccessContextManagerBasePath string
CloudSchedulerBasePath string
FirestoreBasePath string
MonitoringBasePath string
RedisBasePath string
TpuBasePath string

Expand Down
3 changes: 3 additions & 0 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func Provider() terraform.ResourceProvider {
FilestoreCustomEndpointEntryKey: FilestoreCustomEndpointEntry,
FirestoreCustomEndpointEntryKey: FirestoreCustomEndpointEntry,
KmsCustomEndpointEntryKey: KmsCustomEndpointEntry,
MonitoringCustomEndpointEntryKey: MonitoringCustomEndpointEntry,
PubsubCustomEndpointEntryKey: PubsubCustomEndpointEntry,
RedisCustomEndpointEntryKey: RedisCustomEndpointEntry,
ResourceManagerCustomEndpointEntryKey: ResourceManagerCustomEndpointEntry,
Expand Down Expand Up @@ -357,6 +358,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.DnsBasePath = d.Get(DnsCustomEndpointEntryKey).(string)
config.FilestoreBasePath = d.Get(FilestoreCustomEndpointEntryKey).(string)
config.KmsBasePath = d.Get(KmsCustomEndpointEntryKey).(string)
config.MonitoringBasePath = d.Get(MonitoringCustomEndpointEntryKey).(string)
config.PubsubBasePath = d.Get(PubsubCustomEndpointEntryKey).(string)
config.RedisBasePath = d.Get(RedisCustomEndpointEntryKey).(string)
config.ResourceManagerBasePath = d.Get(ResourceManagerCustomEndpointEntryKey).(string)
Expand Down Expand Up @@ -409,6 +411,7 @@ func ConfigureBasePaths(c *Config) {
c.FilestoreBasePath = FilestoreDefaultBasePath
c.FirestoreBasePath = FirestoreDefaultBasePath
c.KmsBasePath = KmsDefaultBasePath
c.MonitoringBasePath = MonitoringDefaultBasePath
c.PubsubBasePath = PubsubDefaultBasePath
c.RedisBasePath = RedisDefaultBasePath
c.ResourceManagerBasePath = ResourceManagerDefaultBasePath
Expand Down
4 changes: 2 additions & 2 deletions google/resource_monitoring_notification_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func resourceMonitoringNotificationChannelCreate(d *schema.ResourceData, meta in
enabledProp, err := expandMonitoringNotificationChannelEnabled(d.Get("enabled"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enabled"); !isEmptyValue(reflect.ValueOf(enabledProp)) && (ok || !reflect.DeepEqual(v, enabledProp)) {
} else if v, ok := d.GetOkExists("enabled"); ok || !reflect.DeepEqual(v, enabledProp) {
obj["enabled"] = enabledProp
}

Expand Down Expand Up @@ -251,7 +251,7 @@ func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta in
enabledProp, err := expandMonitoringNotificationChannelEnabled(d.Get("enabled"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enabled"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enabledProp)) {
} else if v, ok := d.GetOkExists("enabled"); ok || !reflect.DeepEqual(v, enabledProp) {
obj["enabled"] = enabledProp
}

Expand Down
9 changes: 5 additions & 4 deletions google/resource_monitoring_notification_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ func TestAccMonitoringNotificationChannel_update(t *testing.T) {
CheckDestroy: testAccCheckMonitoringNotificationChannelDestroy,
Steps: []resource.TestStep{
{
Config: testAccMonitoringNotificationChannel_update("email", `email_address = "fake_email@blahblah.com"`),
Config: testAccMonitoringNotificationChannel_update("email", `email_address = "fake_email@blahblah.com"`, "true"),
},
{
ResourceName: "google_monitoring_notification_channel.update",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccMonitoringNotificationChannel_update("sms", `number = "+15555379009"`),
Config: testAccMonitoringNotificationChannel_update("sms", `number = "+15555379009"`, "false"),
},
{
ResourceName: "google_monitoring_notification_channel.update",
Expand All @@ -56,15 +56,16 @@ func TestAccMonitoringNotificationChannel_update(t *testing.T) {
})
}

func testAccMonitoringNotificationChannel_update(channel, labels string) string {
func testAccMonitoringNotificationChannel_update(channel, labels, enabled string) string {
return fmt.Sprintf(`
resource "google_monitoring_notification_channel" "update" {
display_name = "IntTest Notification Channel"
type = "%s"
labels = {
%s
}
enabled = "%s"
}
`, channel, labels,
`, channel, labels, enabled,
)
}