Skip to content

Commit

Permalink
chore: fixed the ID to fetch only the mysql/postgres server
Browse files Browse the repository at this point in the history
  • Loading branch information
ricleal-fugue committed Jan 13, 2023
1 parent 4776294 commit 62ed320
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/services/mysql/mysql_configuration_set_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package mysql
import (
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
Expand Down Expand Up @@ -67,13 +68,15 @@ func resourceMySQLConfigurationSetRead(d *pluginsdk.ResourceData, meta interface
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := parse.ConfigurationID(d.Id())
// id, err := parse.ConfigurationID(serverID)
serverID := strings.TrimSuffix(d.Id(), "/configurationSet/set")
id, err := parse.ServerID(serverID)
if err != nil {
return err
}

resourceGroup := id.ResourceGroup
serverName := id.ServerName
serverName := id.Name
resp, err := client.ListByServer(ctx, resourceGroup, serverName)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
Expand All @@ -92,7 +95,7 @@ func resourceMySQLConfigurationSetRead(d *pluginsdk.ResourceData, meta interface
configMap[*key] = *value
}

d.Set("server_name", id.ServerName)
d.Set("server_name", id.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("config_map", configMap)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
Expand Down Expand Up @@ -71,7 +72,8 @@ func resourcePostgreSQLConfigurationSetRead(d *pluginsdk.ResourceData, meta inte

defer cancel()

id, err := configurations.ParseServerID(d.Id())
serverID := strings.TrimSuffix(d.Id(), "/configurationSet/set")
id, err := configurations.ParseServerID(serverID)
if err != nil {
return err
}
Expand Down

0 comments on commit 62ed320

Please sign in to comment.