Skip to content

Commit

Permalink
change per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
buhongw7583c committed Apr 28, 2020
1 parent 03dd4fa commit 2605a45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion controllers/postgresql_combined_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestPSQLDatabaseController(t *testing.T) {

// Add any setup steps that needs to be executed before each test
rgName = tc.resourceGroupName
rgLocation = "eastus"
rgLocation = tc.resourceGroupLocation

postgreSQLServerName = GenerateTestResourceNameWithRandom("psql-srv", 10)
postgreSQLServerReplicaName := GenerateTestResourceNameWithRandom("psql-rep", 10)
Expand Down
15 changes: 5 additions & 10 deletions pkg/resourcemanager/psql/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
psql "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/pkg/helpers"
Expand Down Expand Up @@ -98,19 +97,19 @@ func (p *PSQLServerClient) CreateServerIfValid(ctx context.Context,
return "", psql.Server{}, err
}

var result postgresql.ServersCreateFuture
var result pqsl.ServersCreateFuture

if strings.EqualFold(createmode, string(postgresql.CreateModeReplica)) {
if strings.EqualFold(createmode, string(psql.CreateModeReplica)) {
result, err = client.Create(
ctx,
resourcegroup,
servername,
postgresql.ServerForCreate{
psql.ServerForCreate{
Location: &location,
Tags: tags,
Properties: &postgresql.ServerPropertiesForReplica{
Properties: &psql.ServerPropertiesForReplica{
SourceServerID: to.StringPtr(sourceserver),
CreateMode: postgresql.CreateModeReplica,
CreateMode: psql.CreateModeReplica,
},
},
)
Expand All @@ -136,13 +135,9 @@ func (p *PSQLServerClient) CreateServerIfValid(ctx context.Context,
}

if err != nil {
fmt.Println(err.Error())
return "", psql.Server{}, err
}
res, err := result.Result(client)
if err != nil {
fmt.Println(err.Error())
}
return result.PollingURL(), res, err
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/resourcemanager/psql/server/server_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/profiles/latest/postgresql/mgmt/postgresql"
psql "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
"github.com/Azure/azure-service-operator/api/v1alpha1"
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
Expand Down Expand Up @@ -37,13 +36,13 @@ func (p *PSQLServerClient) Ensure(ctx context.Context, obj runtime.Object, opts
return true, err
}

createmode := string(postgresql.CreateModeDefault)
createmode := string(psql.CreateModeDefault)
if len(instance.Spec.CreateMode) != 0 {
createmode = instance.Spec.CreateMode
}

// If a replica is requested, ensure that source server is specified
if strings.EqualFold(createmode, string(postgresql.CreateModeReplica)) {
if strings.EqualFold(createmode, string(psql.CreateModeReplica)) {
if len(instance.Spec.ReplicaProperties.SourceServerId) == 0 {
instance.Status.Message = "Replica requested but source server unspecified"
return true, nil
Expand Down

0 comments on commit 2605a45

Please sign in to comment.