Skip to content

Commit

Permalink
add extra logs
Browse files Browse the repository at this point in the history
  • Loading branch information
test committed Oct 20, 2022
1 parent 98d7d52 commit dae3cb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ func run(ctx context.Context, args []string) error {
Host: dbHost,
Port: dbPort,
}
klog.Info("\nuser:", dbUser, "\nhost:", dbHost, "\nport:", dbPort, "\n")
identityServer, databaseProvisioner := driver.NewDriver(provisionerName, postgresDB)
server, err := provisioner.NewDefaultProvisionerServer(driverAddress,
identityServer,
databaseProvisioner)
if err != nil {
klog.Errorf("Failed to create provisioner server %v", err)
return err
}
klog.Info("Starting Postgres provisioner")
return server.Run(ctx)
}
8 changes: 7 additions & 1 deletion pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ type ProvisionerServer struct {

func (ps *ProvisionerServer) DriverCreateDatabase(_ context.Context, req *databasespec.DriverCreateDatabaseRequest) (*databasespec.DriverCreateDatabaseResponse, error) {
if ps.postgresDB == nil {
klog.Errorf("Database not initialized")
return &databasespec.DriverCreateDatabaseResponse{}, status.Error(codes.Internal, "Database not initialized")
}
databaseName := req.GetName()
klog.V(3).Info("Create Database", "name", databaseName)
klog.Info("Create Database", "name", databaseName)
if err := ps.postgresDB.CreateDatabase(databaseName); err != nil {
klog.Errorf("Failed to create database %v", err)
return &databasespec.DriverCreateDatabaseResponse{}, err
}

Expand All @@ -43,9 +45,12 @@ func (ps *ProvisionerServer) DriverCreateDatabase(_ context.Context, req *databa

func (ps *ProvisionerServer) DriverDeleteDatabase(_ context.Context, req *databasespec.DriverDeleteDatabaseRequest) (*databasespec.DriverDeleteDatabaseResponse, error) {
if ps.postgresDB == nil {
klog.Errorf("Database not initialized")
return &databasespec.DriverDeleteDatabaseResponse{}, status.Error(codes.Internal, "Database not initialized")
}
klog.Info("Delete Database", "name", req.DatabaseId)
if err := ps.postgresDB.DeleteDatabase(req.DatabaseId); err != nil {
klog.Errorf("Failed to delete database %v", err)
return &databasespec.DriverDeleteDatabaseResponse{}, err
}

Expand All @@ -55,6 +60,7 @@ func (ps *ProvisionerServer) DriverDeleteDatabase(_ context.Context, req *databa
// This call grants access to an account. The account_name in the request shall be used as a unique identifier to create credentials.
// The account_id returned in the response will be used as the unique identifier for deleting this access when calling DriverRevokeDatabaseAccess.
func (ps *ProvisionerServer) DriverGrantDatabaseAccess(_ context.Context, req *databasespec.DriverGrantDatabaseAccessRequest) (*databasespec.DriverGrantDatabaseAccessResponse, error) {
klog.Info("Grant access", "name", req.DatabaseId)
resp := &databasespec.DriverGrantDatabaseAccessResponse{
AccountId: req.DatabaseId,
Credentials: map[string]*databasespec.CredentialDetails{},
Expand Down

0 comments on commit dae3cb7

Please sign in to comment.