Skip to content

Commit

Permalink
devtestlabs: Upgrade API to 2018-09-15 and... (#13074)
Browse files Browse the repository at this point in the history
Fixes #7221
  • Loading branch information
favoretti committed Aug 25, 2021
1 parent d683b13 commit 9543263
Show file tree
Hide file tree
Showing 45 changed files with 8,320 additions and 4,902 deletions.
2 changes: 1 addition & 1 deletion internal/services/devtestlabs/client/client.go
@@ -1,7 +1,7 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -88,6 +88,10 @@ func resourceDevTestGlobalVMShutdownSchedule() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Optional: true,
},
"email": {
Type: pluginsdk.TypeString,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -257,18 +261,20 @@ func expandDevTestGlobalVMShutdownScheduleNotificationSettings(d *pluginsdk.Reso
notificationSettingsConfig := notificationSettingsConfigs[0].(map[string]interface{})
webhookUrl := notificationSettingsConfig["webhook_url"].(string)
timeInMinutes := int32(notificationSettingsConfig["time_in_minutes"].(int))
email := notificationSettingsConfig["email"].(string)

var notificationStatus dtl.NotificationStatus
var notificationStatus dtl.EnableStatus
if notificationSettingsConfig["enabled"].(bool) {
notificationStatus = dtl.NotificationStatusEnabled
notificationStatus = dtl.EnableStatusEnabled
} else {
notificationStatus = dtl.NotificationStatusDisabled
notificationStatus = dtl.EnableStatusDisabled
}

return &dtl.NotificationSettings{
WebhookURL: &webhookUrl,
TimeInMinutes: &timeInMinutes,
Status: notificationStatus,
WebhookURL: &webhookUrl,
TimeInMinutes: &timeInMinutes,
Status: notificationStatus,
EmailRecipient: &email,
}
}

Expand All @@ -287,7 +293,8 @@ func flattenDevTestGlobalVMShutdownScheduleNotificationSettings(notificationSett
result["time_in_minutes"] = *notificationSettings.TimeInMinutes
}

result["enabled"] = notificationSettings.Status == dtl.NotificationStatusEnabled
result["enabled"] = notificationSettings.Status == dtl.EnableStatusEnabled
result["email"] = notificationSettings.EmailRecipient

return []interface{}{result}
}
Expand Up @@ -55,6 +55,7 @@ func TestAccDevTestGlobalVMShutdownSchedule_autoShutdownComplete(t *testing.T) {
check.That(data.ResourceName).Key("notification_settings.0.enabled").HasValue("true"),
check.That(data.ResourceName).Key("notification_settings.0.time_in_minutes").HasValue("15"),
check.That(data.ResourceName).Key("notification_settings.0.webhook_url").HasValue("https://www.bing.com/2/4"),
check.That(data.ResourceName).Key("notification_settings.0.email").HasValue("alerts@devtest.com"),
check.That(data.ResourceName).Key("daily_recurrence_time").HasValue("1100"),
check.That(data.ResourceName).Key("tags.%").HasValue("1"),
check.That(data.ResourceName).Key("tags.Environment").HasValue("Production"),
Expand Down Expand Up @@ -217,6 +218,7 @@ resource "azurerm_dev_test_global_vm_shutdown_schedule" "test" {
notification_settings {
time_in_minutes = 15
webhook_url = "https://www.bing.com/2/4"
email = "alerts@devtest.com"
enabled = true
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/devtestlabs/dev_test_lab_resource.go
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
10 changes: 5 additions & 5 deletions internal/services/devtestlabs/dev_test_lab_schedule_resource.go
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -153,10 +153,10 @@ func resourceDevTestLabSchedules() *pluginsdk.Resource {
"status": {
Type: pluginsdk.TypeString,
Optional: true,
Default: dtl.NotificationStatusDisabled,
Default: dtl.EnableStatusDisabled,
ValidateFunc: validation.StringInSlice([]string{
string(dtl.NotificationStatusEnabled),
string(dtl.NotificationStatusDisabled),
string(dtl.EnableStatusEnabled),
string(dtl.EnableStatusDisabled),
}, false),
},
"time_in_minutes": {
Expand Down Expand Up @@ -430,7 +430,7 @@ func expandDevTestScheduleNotificationSettings(d *pluginsdk.ResourceData) *dtl.N
webhookUrl := notificationSettingsConfig["webhook_url"].(string)
timeInMinutes := int32(notificationSettingsConfig["time_in_minutes"].(int))

notificationStatus := dtl.NotificationStatus(notificationSettingsConfig["status"].(string))
notificationStatus := dtl.EnableStatus(notificationSettingsConfig["status"].(string))

return &dtl.NotificationSettings{
WebhookURL: &webhookUrl,
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/devtestlabs/dev_test_policy_resource.go
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/devtestlabs/validate"
Expand Down
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/devtestlabs/helpers.go
@@ -1,7 +1,7 @@
package devtestlabs

import (
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/devtestlabs/validate/devtest.go
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"regexp"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9543263

Please sign in to comment.