Skip to content

Commit

Permalink
minor simplifications on variable assignments and for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun committed Oct 24, 2024
1 parent a427e1e commit a314bd6
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (r PostgresqlFlexibleServerVirtualEndpointResource) Read() sdk.ResourceFunc
}

// Model.Properties.Members is a tuple => [source_server_id, replication_server_name]
sourceServerName := (*resp.Model.Properties.Members)[0]
replicaServerName := (*resp.Model.Properties.Members)[1]
sourceServerName := (*props.Members)[0]
replicaServerName := (*props.Members)[1]

sourceServerId := servers.NewFlexibleServerID(id.SubscriptionId, id.ResourceGroupName, sourceServerName).ID()

Expand All @@ -173,12 +173,14 @@ func (r PostgresqlFlexibleServerVirtualEndpointResource) Read() sdk.ResourceFunc

state.SourceServerId = sourceServerId

replicaId, err := servers.ParseFlexibleServerID(*replicaServer.Id)
if err != nil {
return err
}
if replicaServer != nil {
replicaId, err := servers.ParseFlexibleServerID(*replicaServer.Id)
if err != nil {
return err
}

state.ReplicaServerId = replicaId.ID()
state.ReplicaServerId = replicaId.ID()
}
}
}

Expand Down Expand Up @@ -259,10 +261,9 @@ func lookupFlexibleServerByName(ctx context.Context, flexibleServerClient *serve
}

// loop to find the replica server associated with this flexible endpoint
for i := 0; i < len(postgresServers.Items); i++ {
postgresServer := postgresServers.Items[i]
if postgresServer.Properties.SourceServerResourceId != nil && *postgresServer.Properties.SourceServerResourceId == sourceServerId {
return &postgresServer, nil
for _, server := range postgresServers.Items {
if server.Properties != nil && pointer.From(server.Properties.SourceServerResourceId) == sourceServerId {
return &server, nil
}
}

Expand Down

0 comments on commit a314bd6

Please sign in to comment.