From 50729a4528a055013e344d286ce5f738fcef066f Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Tue, 28 Mar 2017 13:08:11 -0700 Subject: [PATCH] Add comments to connection and credential producers --- builtin/logical/database/dbs/connectionproducer.go | 7 ++++++- builtin/logical/database/dbs/credentialsproducer.go | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/builtin/logical/database/dbs/connectionproducer.go b/builtin/logical/database/dbs/connectionproducer.go index dae8d9400..ca9e7250e 100644 --- a/builtin/logical/database/dbs/connectionproducer.go +++ b/builtin/logical/database/dbs/connectionproducer.go @@ -23,6 +23,9 @@ var ( errNotInitalized = errors.New("connection has not been initalized") ) +// ConnectionProducer can be used as an embeded interface in the DatabaseType +// definition. It implements the methods dealing with individual database +// connections and is used in all the builtin database types. type ConnectionProducer interface { Close() error Initialize(map[string]interface{}) error @@ -31,7 +34,7 @@ type ConnectionProducer interface { connection() (interface{}, error) } -// sqlConnectionProducer impliments ConnectionProducer and provides a generic producer for most sql databases +// sqlConnectionProducer implements ConnectionProducer and provides a generic producer for most sql databases type sqlConnectionProducer struct { ConnectionURL string `json:"connection_url" structs:"connection_url" mapstructure:"connection_url"` @@ -111,6 +114,8 @@ func (c *sqlConnectionProducer) Close() error { return nil } +// cassandraConnectionProducer implements ConnectionProducer and provides an +// interface for cassandra databases to make connections. type cassandraConnectionProducer struct { Hosts string `json:"hosts" structs:"hosts" mapstructure:"hosts"` Username string `json:"username" structs:"username" mapstructure:"username"` diff --git a/builtin/logical/database/dbs/credentialsproducer.go b/builtin/logical/database/dbs/credentialsproducer.go index 5ae3b128e..6bd543f4e 100644 --- a/builtin/logical/database/dbs/credentialsproducer.go +++ b/builtin/logical/database/dbs/credentialsproducer.go @@ -8,20 +8,22 @@ import ( uuid "github.com/hashicorp/go-uuid" ) +// CredentialsProducer can be used as an embeded interface in the DatabaseType +// definition. It implements the methods for generating user information for a +// particular database type and is used in all the builtin database types. type CredentialsProducer interface { GenerateUsername(displayName string) (string, error) GeneratePassword() (string, error) GenerateExpiration(ttl time.Duration) (string, error) } -// sqlCredentialsProducer impliments CredentialsProducer and provides a generic credentials producer for most sql database types. +// sqlCredentialsProducer implements CredentialsProducer and provides a generic credentials producer for most sql database types. type sqlCredentialsProducer struct { displayNameLen int usernameLen int } func (scp *sqlCredentialsProducer) GenerateUsername(displayName string) (string, error) { - // Generate the username, password and expiration. PG limits user to 63 characters if scp.displayNameLen > 0 && len(displayName) > scp.displayNameLen { displayName = displayName[:scp.displayNameLen] } @@ -52,6 +54,8 @@ func (scp *sqlCredentialsProducer) GenerateExpiration(ttl time.Duration) (string Format("2006-01-02 15:04:05-0700"), nil } +// cassandraCredentialsProducer implements CredentialsProducer and provides an +// interface for cassandra databases to generate user information. type cassandraCredentialsProducer struct{} func (ccp *cassandraCredentialsProducer) GenerateUsername(displayName string) (string, error) {