From 357ecb4dfee0e4c4af12befce3ac44738892fd6a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 19 Aug 2016 16:48:32 -0400 Subject: [PATCH] gofmt --- builtin/credential/cert/path_crls.go | 2 +- builtin/logical/aws/path_config_lease.go | 2 +- builtin/logical/mongodb/path_config_connection.go | 4 ++-- builtin/logical/mysql/path_config_lease.go | 2 +- builtin/logical/pki/path_config_crl.go | 2 +- builtin/logical/postgresql/path_config_lease.go | 2 +- builtin/logical/postgresql/secret_creds.go | 1 - builtin/logical/ssh/path_config_zeroaddress.go | 2 +- builtin/logical/ssh/path_keys.go | 2 +- helper/mfa/duo/duo.go | 10 +++++----- helper/mfa/duo/path_duo_access.go | 2 +- helper/mfa/duo/path_duo_config.go | 6 +++--- helper/mfa/mfa.go | 8 ++++---- helper/mfa/path_mfa_config.go | 4 ++-- logical/error.go | 15 +++++++-------- physical/postgresql.go | 8 ++++---- 16 files changed, 35 insertions(+), 37 deletions(-) diff --git a/builtin/credential/cert/path_crls.go b/builtin/credential/cert/path_crls.go index d0e1f0ea2a..f45effbdd4 100644 --- a/builtin/credential/cert/path_crls.go +++ b/builtin/credential/cert/path_crls.go @@ -33,7 +33,7 @@ using the same name as specified here.`, Callbacks: map[logical.Operation]framework.OperationFunc{ logical.DeleteOperation: b.pathCRLDelete, logical.ReadOperation: b.pathCRLRead, - logical.UpdateOperation: b.pathCRLWrite, + logical.UpdateOperation: b.pathCRLWrite, }, HelpSynopsis: pathCRLsHelpSyn, diff --git a/builtin/logical/aws/path_config_lease.go b/builtin/logical/aws/path_config_lease.go index 87b02f7a23..3decbfb5c7 100644 --- a/builtin/logical/aws/path_config_lease.go +++ b/builtin/logical/aws/path_config_lease.go @@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path { }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ReadOperation: b.pathLeaseRead, + logical.ReadOperation: b.pathLeaseRead, logical.UpdateOperation: b.pathLeaseWrite, }, diff --git a/builtin/logical/mongodb/path_config_connection.go b/builtin/logical/mongodb/path_config_connection.go index b191598f6a..9f615f9491 100644 --- a/builtin/logical/mongodb/path_config_connection.go +++ b/builtin/logical/mongodb/path_config_connection.go @@ -80,7 +80,7 @@ func (b *backend) pathConnectionWrite(req *logical.Request, data *framework.Fiel // Store it entry, err := logical.StorageEntryJSON("config/connection", connectionConfig{ - URI: uri, + URI: uri, }) if err != nil { return nil, err @@ -99,7 +99,7 @@ func (b *backend) pathConnectionWrite(req *logical.Request, data *framework.Fiel } type connectionConfig struct { - URI string `json:"uri" structs:"uri" mapstructure:"uri"` + URI string `json:"uri" structs:"uri" mapstructure:"uri"` } const pathConfigConnectionHelpSyn = ` diff --git a/builtin/logical/mysql/path_config_lease.go b/builtin/logical/mysql/path_config_lease.go index 3f2fee97a1..f386b609e0 100644 --- a/builtin/logical/mysql/path_config_lease.go +++ b/builtin/logical/mysql/path_config_lease.go @@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path { }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ReadOperation: b.pathLeaseRead, + logical.ReadOperation: b.pathLeaseRead, logical.UpdateOperation: b.pathLeaseWrite, }, diff --git a/builtin/logical/pki/path_config_crl.go b/builtin/logical/pki/path_config_crl.go index aadc8cc5eb..36db15db3e 100644 --- a/builtin/logical/pki/path_config_crl.go +++ b/builtin/logical/pki/path_config_crl.go @@ -26,7 +26,7 @@ valid; defaults to 72 hours`, }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ReadOperation: b.pathCRLRead, + logical.ReadOperation: b.pathCRLRead, logical.UpdateOperation: b.pathCRLWrite, }, diff --git a/builtin/logical/postgresql/path_config_lease.go b/builtin/logical/postgresql/path_config_lease.go index b8798bdf7b..4bc55c8617 100644 --- a/builtin/logical/postgresql/path_config_lease.go +++ b/builtin/logical/postgresql/path_config_lease.go @@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path { }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.ReadOperation: b.pathLeaseRead, + logical.ReadOperation: b.pathLeaseRead, logical.UpdateOperation: b.pathLeaseWrite, }, diff --git a/builtin/logical/postgresql/secret_creds.go b/builtin/logical/postgresql/secret_creds.go index 4e001d2d44..3c771457cb 100644 --- a/builtin/logical/postgresql/secret_creds.go +++ b/builtin/logical/postgresql/secret_creds.go @@ -91,7 +91,6 @@ func (b *backend) secretCredsRevoke( } username, ok := usernameRaw.(string) - // Get our connection db, err := b.DB(req.Storage) if err != nil { diff --git a/builtin/logical/ssh/path_config_zeroaddress.go b/builtin/logical/ssh/path_config_zeroaddress.go index 392ebcbd43..43b41db714 100644 --- a/builtin/logical/ssh/path_config_zeroaddress.go +++ b/builtin/logical/ssh/path_config_zeroaddress.go @@ -25,7 +25,7 @@ func pathConfigZeroAddress(b *backend) *framework.Path { }, }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: b.pathConfigZeroAddressWrite, + logical.UpdateOperation: b.pathConfigZeroAddressWrite, logical.ReadOperation: b.pathConfigZeroAddressRead, logical.DeleteOperation: b.pathConfigZeroAddressDelete, }, diff --git a/builtin/logical/ssh/path_keys.go b/builtin/logical/ssh/path_keys.go index 7d0b9b8b6b..aa0f444762 100644 --- a/builtin/logical/ssh/path_keys.go +++ b/builtin/logical/ssh/path_keys.go @@ -27,7 +27,7 @@ func pathKeys(b *backend) *framework.Path { }, }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: b.pathKeysWrite, + logical.UpdateOperation: b.pathKeysWrite, logical.DeleteOperation: b.pathKeysDelete, }, HelpSynopsis: pathKeysSyn, diff --git a/helper/mfa/duo/duo.go b/helper/mfa/duo/duo.go index df25316cbf..7d724993a7 100644 --- a/helper/mfa/duo/duo.go +++ b/helper/mfa/duo/duo.go @@ -22,7 +22,7 @@ func DuoPaths() []*framework.Path { // DuoRootPaths returns the paths that are used to configure Duo. func DuoRootPaths() []string { - return []string { + return []string{ "duo/access", "duo/config", } @@ -60,10 +60,10 @@ func DuoHandler(req *logical.Request, d *framework.FieldData, resp *logical.Resp type duoAuthRequest struct { successResp *logical.Response - username string - method string - passcode string - ipAddr string + username string + method string + passcode string + ipAddr string } func duoHandler(duoConfig *DuoConfig, duoAuthClient AuthClient, request *duoAuthRequest) ( diff --git a/helper/mfa/duo/path_duo_access.go b/helper/mfa/duo/path_duo_access.go index 7537fd6b0d..d087b0fb46 100644 --- a/helper/mfa/duo/path_duo_access.go +++ b/helper/mfa/duo/path_duo_access.go @@ -34,7 +34,7 @@ func pathDuoAccess() *framework.Path { }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: pathDuoAccessWrite, + logical.UpdateOperation: pathDuoAccessWrite, }, HelpSynopsis: pathDuoAccessHelpSyn, diff --git a/helper/mfa/duo/path_duo_config.go b/helper/mfa/duo/path_duo_config.go index 381ca471c6..7c8a56b3ed 100644 --- a/helper/mfa/duo/path_duo_config.go +++ b/helper/mfa/duo/path_duo_config.go @@ -13,7 +13,7 @@ func pathDuoConfig() *framework.Path { Pattern: `duo/config`, Fields: map[string]*framework.FieldSchema{ "user_agent": &framework.FieldSchema{ - Type: framework.TypeString, + Type: framework.TypeString, Description: "User agent to connect to Duo (default \"\")", }, "username_format": &framework.FieldSchema{ @@ -24,7 +24,7 @@ func pathDuoConfig() *framework.Path { Callbacks: map[logical.Operation]framework.OperationFunc{ logical.UpdateOperation: pathDuoConfigWrite, - logical.ReadOperation: pathDuoConfigRead, + logical.ReadOperation: pathDuoConfigRead, }, HelpSynopsis: pathDuoConfigHelpSyn, @@ -87,7 +87,7 @@ func pathDuoConfigRead( type DuoConfig struct { UsernameFormat string `json:"username_format"` - UserAgent string `json:"user_agent"` + UserAgent string `json:"user_agent"` } const pathDuoConfigHelpSyn = ` diff --git a/helper/mfa/mfa.go b/helper/mfa/mfa.go index 5813906033..9939a5f8ef 100644 --- a/helper/mfa/mfa.go +++ b/helper/mfa/mfa.go @@ -35,7 +35,7 @@ func MFARootPaths() []string { } // HandlerFunc is the callback called to handle MFA for a login request. -type HandlerFunc func (*logical.Request, *framework.FieldData, *logical.Response) (*logical.Response, error) +type HandlerFunc func(*logical.Request, *framework.FieldData, *logical.Response) (*logical.Response, error) // handlers maps each supported MFA type to its handler. var handlers = map[string]HandlerFunc{ @@ -52,7 +52,7 @@ func wrapLoginPath(b *backend, loginPath *framework.Path) *framework.Path { Description: "One time passcode (optional)", } loginPath.Fields["method"] = &framework.FieldSchema{ - Type: framework.TypeString, + Type: framework.TypeString, Description: "Multi-factor auth method to use (optional)", } // wrap write callback to do MFA after auth @@ -62,9 +62,9 @@ func wrapLoginPath(b *backend, loginPath *framework.Path) *framework.Path { } func (b *backend) wrapLoginHandler(loginHandler framework.OperationFunc) framework.OperationFunc { - return func (req *logical.Request, d *framework.FieldData) (*logical.Response, error) { + return func(req *logical.Request, d *framework.FieldData) (*logical.Response, error) { // login with original login function first - resp, err := loginHandler(req, d); + resp, err := loginHandler(req, d) if err != nil || resp.Auth == nil { return resp, err } diff --git a/helper/mfa/path_mfa_config.go b/helper/mfa/path_mfa_config.go index 46be15cdfd..8f96e25064 100644 --- a/helper/mfa/path_mfa_config.go +++ b/helper/mfa/path_mfa_config.go @@ -16,8 +16,8 @@ func pathMFAConfig(b *backend) *framework.Path { }, Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: b.pathMFAConfigWrite, - logical.ReadOperation: b.pathMFAConfigRead, + logical.UpdateOperation: b.pathMFAConfigWrite, + logical.ReadOperation: b.pathMFAConfigRead, }, HelpSynopsis: pathMFAConfigHelpSyn, diff --git a/logical/error.go b/logical/error.go index e32ef007be..9d082013f6 100644 --- a/logical/error.go +++ b/logical/error.go @@ -1,24 +1,23 @@ package logical type HTTPCodedError interface { - Error() string - Code() int + Error() string + Code() int } func CodedError(c int, s string) HTTPCodedError { - return &codedError{s,c} + return &codedError{s, c} } type codedError struct { - s string - code int + s string + code int } func (e *codedError) Error() string { - return e.s + return e.s } func (e *codedError) Code() int { - return e.code + return e.code } - diff --git a/physical/postgresql.go b/physical/postgresql.go index 2fe2b4fafe..91d656ecd2 100644 --- a/physical/postgresql.go +++ b/physical/postgresql.go @@ -20,7 +20,7 @@ type PostgreSQLBackend struct { get_query string delete_query string list_query string - logger *log.Logger + logger *log.Logger } // newPostgreSQLBackend constructs a PostgreSQL backend using the given @@ -69,9 +69,9 @@ func newPostgreSQLBackend(conf map[string]string, logger *log.Logger) (Backend, put_query: put_query, get_query: "SELECT value FROM " + quoted_table + " WHERE path = $1 AND key = $2", delete_query: "DELETE FROM " + quoted_table + " WHERE path = $1 AND key = $2", - list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" + + list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" + "UNION SELECT substr(path, length($1)+1) FROM " + quoted_table + "WHERE parent_path = $1", - logger: logger, + logger: logger, } return m, nil @@ -154,7 +154,7 @@ func (m *PostgreSQLBackend) Delete(fullPath string) error { func (m *PostgreSQLBackend) List(prefix string) ([]string, error) { defer metrics.MeasureSince([]string{"postgres", "list"}, time.Now()) - rows, err := m.client.Query(m.list_query, "/" + prefix) + rows, err := m.client.Query(m.list_query, "/"+prefix) if err != nil { return nil, err }