Skip to content

Commit

Permalink
Fix upgrade acc test
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaweitao001 committed Sep 11, 2024
1 parent 4dd14f3 commit c05d200
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ func (r AppServiceConnectorResource) Update() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 30 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.ServiceConnector.LinksClient
id, err := links.ParseScopedLinkerID(metadata.ResourceData.Id())
client := metadata.Client.ServiceConnector.ServiceLinkerClient

id, err := servicelinker.ParseScopedLinkerID(metadata.ResourceData.Id())
if err != nil {
return err
}
Expand All @@ -345,24 +346,26 @@ func (r AppServiceConnectorResource) Update() sdk.ResourceFunc {
return fmt.Errorf("decoding %+v", err)
}

linkerProps := links.LinkerProperties{}
existing, err := client.LinkerGet(ctx, *id)
if err != nil {
return fmt.Errorf("checking for presence of existing %s: %+v", *id, err)
}
linkerProps := existing.Model.Properties
d := metadata.ResourceData

if d.HasChange("client_type") {
clientType := links.ClientType(state.ClientType)
linkerProps.ClientType = &clientType
linkerProps.ClientType = pointer.To(servicelinker.ClientType(state.ClientType))
}

if d.HasChange("vnet_solution") {
vnetSolutionType := links.VNetSolutionType(state.VnetSolution)
vnetSolution := links.VNetSolution{
Type: &vnetSolutionType,
vnetSolution := servicelinker.VNetSolution{
Type: pointer.To(servicelinker.VNetSolutionType(state.VnetSolution)),
}
linkerProps.VNetSolution = &vnetSolution
linkerProps.VNetSolution = pointer.To(vnetSolution)
}

if d.HasChange("secret_store") {
linkerProps.SecretStore = pointer.To(links.SecretStore{KeyVaultId: expandSecretStore(state.SecretStore).KeyVaultId})
linkerProps.SecretStore = pointer.To(servicelinker.SecretStore{KeyVaultId: expandSecretStore(state.SecretStore).KeyVaultId})
}

if d.HasChange("authentication") {
Expand All @@ -373,11 +376,19 @@ func (r AppServiceConnectorResource) Update() sdk.ResourceFunc {
linkerProps.Scope = pointer.To(state.Scope)
}

props := links.LinkerPatch{
Properties: &linkerProps,
if d.HasChange("configuration") {
linkerProps.ConfigurationInfo = expandConfigurationInfo(state.ConfigurationInfo)
}

if d.HasChange("public_network_solution") {
linkerProps.PublicNetworkSolution = expandPublicNetworkSolution(state.PublicNetworkSolution)
}

props := servicelinker.LinkerResource{
Properties: linkerProps,
}

if err := client.LinkerUpdateThenPoll(ctx, *id, props); err != nil {
if err := client.LinkerCreateOrUpdateThenPoll(ctx, *id, props); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ resource "azurerm_linux_web_app" "test" {
app_settings["AZURE_STORAGEBLOB_RESOURCEENDPOINT"],
identity,
sticky_settings,
ftp_publish_basic_authentication_enabled,
webdeploy_publish_basic_authentication_enabled,
]
}
}
Expand Down Expand Up @@ -306,36 +308,30 @@ func (r ServiceConnectorAppServiceResource) cosmosdbUpdate(data acceptance.TestD
return fmt.Sprintf(`
%[1]s
resource "azurerm_cosmosdb_sql_database" "update" {
name = "cosmos-sql-db-update"
resource_group_name = azurerm_cosmosdb_account.test.resource_group_name
account_name = azurerm_cosmosdb_account.test.name
throughput = 400
}
resource "azurerm_cosmosdb_sql_container" "update" {
name = "test-containerupdate%[2]s"
resource_group_name = azurerm_cosmosdb_account.test.resource_group_name
account_name = azurerm_cosmosdb_account.test.name
database_name = azurerm_cosmosdb_sql_database.update.name
partition_key_paths = ["/definitionupdate"]
}
resource "azurerm_service_plan" "update" {
location = azurerm_resource_group.test.location
name = "testserviceplanupdate%[2]s"
resource "azurerm_app_configuration" "test" {
name = "testacc-appconf%[3]d"
resource_group_name = azurerm_resource_group.test.name
sku_name = "P1v2"
os_type = "Linux"
location = azurerm_resource_group.test.location
sku = "free"
}
resource "azurerm_app_service_connection" "test" {
name = "acctestserviceconnector%[3]d"
app_service_id = azurerm_linux_web_app.test.id
target_resource_id = azurerm_cosmosdb_sql_database.update.id
target_resource_id = azurerm_cosmosdb_sql_database.test.id
authentication {
type = "systemAssignedIdentity"
}
scope = "default"
configuration {
action = "enable"
configuration_store {
app_configuration_id = azurerm_app_configuration.test.id
}
}
public_network_solution {
action = "enable"
}
}
`, template, data.RandomString, data.RandomInteger)
}
Expand Down Expand Up @@ -413,6 +409,8 @@ resource "azurerm_linux_web_app" "test" {
app_settings["AZURE_STORAGEBLOB_RESOURCEENDPOINT"],
identity,
sticky_settings,
ftp_publish_basic_authentication_enabled,
webdeploy_publish_basic_authentication_enabled,
]
}
}
Expand Down Expand Up @@ -640,6 +638,8 @@ resource "azurerm_linux_web_app" "test" {
app_settings,
identity,
sticky_settings,
ftp_publish_basic_authentication_enabled,
webdeploy_publish_basic_authentication_enabled,
]
}
}
Expand Down

0 comments on commit c05d200

Please sign in to comment.