From 305ccd54f7f8d92ac3c53f6bd91cfc4578288063 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Tue, 4 Apr 2017 11:33:58 -0700 Subject: [PATCH] Don't return strings, always structs --- builtin/logical/database/dbs/plugin.go | 44 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/builtin/logical/database/dbs/plugin.go b/builtin/logical/database/dbs/plugin.go index 791f3b465..441f97ca0 100644 --- a/builtin/logical/database/dbs/plugin.go +++ b/builtin/logical/database/dbs/plugin.go @@ -169,24 +169,24 @@ func (dr *databasePluginRPCClient) Close() error { } func (dr *databasePluginRPCClient) GenerateUsername(displayName string) (string, error) { - var username string - err := dr.client.Call("Plugin.GenerateUsername", displayName, &username) + resp := &GenerateUsernameResponse{} + err := dr.client.Call("Plugin.GenerateUsername", displayName, resp) - return username, err + return resp.Username, err } func (dr *databasePluginRPCClient) GeneratePassword() (string, error) { - var password string - err := dr.client.Call("Plugin.GeneratePassword", struct{}{}, &password) + resp := &GeneratePasswordResponse{} + err := dr.client.Call("Plugin.GeneratePassword", struct{}{}, resp) - return password, err + return resp.Password, err } func (dr *databasePluginRPCClient) GenerateExpiration(duration time.Duration) (string, error) { - var expiration string - err := dr.client.Call("Plugin.GenerateExpiration", duration, &expiration) + resp := &GenerateExpirationResponse{} + err := dr.client.Call("Plugin.GenerateExpiration", duration, resp) - return expiration, err + return resp.Expiration, err } // ---- RPC server domain ---- @@ -230,28 +230,28 @@ func (ds *databasePluginRPCServer) Close(_ struct{}, _ *struct{}) error { return nil } -func (ds *databasePluginRPCServer) GenerateUsername(args string, resp *string) error { +func (ds *databasePluginRPCServer) GenerateUsername(args string, resp *GenerateUsernameResponse) error { var err error - *resp, err = ds.impl.GenerateUsername(args) + resp.Username, err = ds.impl.GenerateUsername(args) return err } -func (ds *databasePluginRPCServer) GeneratePassword(_ struct{}, resp *string) error { +func (ds *databasePluginRPCServer) GeneratePassword(_ struct{}, resp *GeneratePasswordResponse) error { var err error - *resp, err = ds.impl.GeneratePassword() + resp.Password, err = ds.impl.GeneratePassword() return err } -func (ds *databasePluginRPCServer) GenerateExpiration(args time.Duration, resp *string) error { +func (ds *databasePluginRPCServer) GenerateExpiration(args time.Duration, resp *GenerateExpirationResponse) error { var err error - *resp, err = ds.impl.GenerateExpiration(args) + resp.Expiration, err = ds.impl.GenerateExpiration(args) return err } -// ---- Request Args domain ---- +// ---- Request Args Domain ---- type CreateUserRequest struct { Statements Statements @@ -270,3 +270,15 @@ type RevokeUserRequest struct { Statements Statements Username string } + +// ---- Response Args Domain ---- + +type GenerateUsernameResponse struct { + Username string +} +type GenerateExpirationResponse struct { + Expiration string +} +type GeneratePasswordResponse struct { + Password string +}