mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 22:21:30 +01:00
Add defaults to the cassandra databse type
This commit is contained in:
parent
78fdc2ad24
commit
73200db1d9
@ -45,8 +45,17 @@ func (c *Cassandra) CreateUser(statements Statements, username, password, expira
|
||||
return err
|
||||
}
|
||||
|
||||
creationCQL := statements.CreationStatements
|
||||
if creationCQL == "" {
|
||||
creationCQL = defaultCreationCQL
|
||||
}
|
||||
rollbackCQL := statements.RollbackStatements
|
||||
if rollbackCQL == "" {
|
||||
rollbackCQL = defaultRollbackCQL
|
||||
}
|
||||
|
||||
// Execute each query
|
||||
for _, query := range strutil.ParseArbitraryStringSlice(statements.CreationStatements, ";") {
|
||||
for _, query := range strutil.ParseArbitraryStringSlice(creationCQL, ";") {
|
||||
query = strings.TrimSpace(query)
|
||||
if len(query) == 0 {
|
||||
continue
|
||||
@ -57,7 +66,7 @@ func (c *Cassandra) CreateUser(statements Statements, username, password, expira
|
||||
"password": password,
|
||||
})).Exec()
|
||||
if err != nil {
|
||||
for _, query := range strutil.ParseArbitraryStringSlice(statements.RollbackStatements, ";") {
|
||||
for _, query := range strutil.ParseArbitraryStringSlice(rollbackCQL, ";") {
|
||||
query = strings.TrimSpace(query)
|
||||
if len(query) == 0 {
|
||||
continue
|
||||
|
||||
@ -94,6 +94,8 @@ type DatabaseConfig struct {
|
||||
MaxConnectionLifetime time.Duration `json:"max_connection_lifetime" structs:"max_connection_lifetime" mapstructure:"max_connection_lifetime"`
|
||||
}
|
||||
|
||||
// Statments set in role creation and passed into the database type's functions.
|
||||
// TODO: Add a way of setting defaults here.
|
||||
type Statements struct {
|
||||
CreationStatements string `json:"creation_statments" mapstructure:"creation_statements" structs:"creation_statments"`
|
||||
RevocationStatements string `json:"revocation_statements" mapstructure:"revocation_statements" structs:"revocation_statements"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user