Skip to content

Commit

Permalink
Updating based on 121f9c84b (hashicorp#22536)
Browse files Browse the repository at this point in the history
Co-authored-by: hc-github-team-tf-azure <>
  • Loading branch information
hc-github-team-tf-azure authored Jul 17, 2023
1 parent 065c713 commit 0255c78
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (r KubernetesFleetManagerResource) Create() sdk.ResourceFunc {
}

subscriptionId := metadata.Client.Account.SubscriptionId

id := fleets.NewFleetID(subscriptionId, config.ResourceGroupName, config.Name)

existing, err := client.Get(ctx, id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ provider "azurerm" {
resource "azurerm_kubernetes_fleet_manager" "test" {
location = azurerm_resource_group.test.location
name = "acctestkfm-${var.random_integer}"
name = "acctestkfm-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
}
`, r.template(data))
Expand Down Expand Up @@ -142,7 +142,7 @@ provider "azurerm" {
resource "azurerm_kubernetes_fleet_manager" "test" {
location = azurerm_resource_group.test.location
name = "acctestkfm-${var.random_integer}"
name = "acctestkfm-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
tags = {
environment = "terraform-acctests"
Expand Down
27 changes: 1 addition & 26 deletions internal/services/loadtestservice/load_test_resource_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (r LoadTestResource) Create() sdk.ResourceFunc {
}

subscriptionId := metadata.Client.Account.SubscriptionId

id := loadtests.NewLoadTestID(subscriptionId, config.ResourceGroupName, config.Name)

existing, err := client.Get(ctx, id)
Expand Down Expand Up @@ -201,16 +202,6 @@ func (r LoadTestResource) mapLoadTestPropertiesToLoadTestResourceSchema(input lo
return nil
}

func (r LoadTestResource) mapLoadTestResourceSchemaToLoadTestResourcePatchRequestBodyProperties(input LoadTestResourceSchema, output *loadtests.LoadTestResourcePatchRequestBodyProperties) error {
output.Description = &input.Description
return nil
}

func (r LoadTestResource) mapLoadTestResourcePatchRequestBodyPropertiesToLoadTestResourceSchema(input loadtests.LoadTestResourcePatchRequestBodyProperties, output *LoadTestResourceSchema) error {
output.Description = pointer.From(input.Description)
return nil
}

func (r LoadTestResource) mapLoadTestResourceSchemaToLoadTestResource(input LoadTestResourceSchema, output *loadtests.LoadTestResource) error {

identity, err := identity.ExpandLegacySystemAndUserAssignedMapFromModel(input.Identity)
Expand Down Expand Up @@ -262,14 +253,6 @@ func (r LoadTestResource) mapLoadTestResourceSchemaToLoadTestResourcePatchReques
output.Identity = identity

output.Tags = tags.Expand(input.Tags)

if output.Properties == nil {
output.Properties = &loadtests.LoadTestResourcePatchRequestBodyProperties{}
}
if err := r.mapLoadTestResourceSchemaToLoadTestResourcePatchRequestBodyProperties(input, output.Properties); err != nil {
return fmt.Errorf("mapping Schema to SDK Field %q / Model %q: %+v", "LoadTestResourcePatchRequestBodyProperties", "Properties", err)
}

return nil
}

Expand All @@ -282,13 +265,5 @@ func (r LoadTestResource) mapLoadTestResourcePatchRequestBodyToLoadTestResourceS
output.Identity = identity

output.Tags = tags.Flatten(input.Tags)

if input.Properties == nil {
input.Properties = &loadtests.LoadTestResourcePatchRequestBodyProperties{}
}
if err := r.mapLoadTestResourcePatchRequestBodyPropertiesToLoadTestResourceSchema(*input.Properties, output); err != nil {
return fmt.Errorf("mapping SDK Field %q / Model %q to Schema: %+v", "LoadTestResourcePatchRequestBodyProperties", "Properties", err)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ provider "azurerm" {
resource "azurerm_load_test" "test" {
location = azurerm_resource_group.test.location
name = "acctestlt-${var.random_integer}"
name = "acctestlt-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
}
`, r.template(data))
Expand Down Expand Up @@ -142,7 +142,7 @@ provider "azurerm" {
resource "azurerm_load_test" "test" {
location = azurerm_resource_group.test.location
name = "acctestlt-${var.random_integer}"
name = "acctestlt-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
description = "Description for the Load Test"
tags = {
Expand All @@ -165,6 +165,9 @@ variable "primary_location" {
variable "random_integer" {
default = %d
}
variable "random_string" {
default = %q
}
resource "azurerm_resource_group" "test" {
name = "acctestrg-${var.random_integer}"
Expand All @@ -177,5 +180,5 @@ resource "azurerm_user_assigned_identity" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}
`, data.Locations.Primary, data.RandomInteger)
`, data.Locations.Primary, data.RandomInteger, data.RandomString)
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (r UserAssignedIdentityResource) Create() sdk.ResourceFunc {
}

subscriptionId := metadata.Client.Account.SubscriptionId

id := commonids.NewUserAssignedIdentityID(subscriptionId, config.ResourceGroupName, config.Name)

existing, err := client.UserAssignedIdentitiesGet(ctx, id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ provider "azurerm" {
resource "azurerm_user_assigned_identity" "test" {
location = azurerm_resource_group.test.location
name = "acctestuai-${var.random_integer}"
name = "acctestuai-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
}
`, r.template(data))
Expand Down Expand Up @@ -142,7 +142,7 @@ provider "azurerm" {
resource "azurerm_user_assigned_identity" "test" {
location = azurerm_resource_group.test.location
name = "acctestuai-${var.random_integer}"
name = "acctestuai-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
tags = {
environment = "terraform-acctests"
Expand All @@ -160,10 +160,13 @@ variable "primary_location" {
variable "random_integer" {
default = %d
}
variable "random_string" {
default = %q
}
resource "azurerm_resource_group" "test" {
name = "acctestrg-${var.random_integer}"
location = var.primary_location
}
`, data.Locations.Primary, data.RandomInteger)
`, data.Locations.Primary, data.RandomInteger, data.RandomString)
}

0 comments on commit 0255c78

Please sign in to comment.