Change ttl types to TypeDurationSecond
This commit is contained in:
parent
e3e5f12f9e
commit
892812d67d
|
@ -1,7 +1,6 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
||||||
|
@ -65,12 +64,12 @@ func pathRoles(b *databaseBackend) *framework.Path {
|
||||||
},
|
},
|
||||||
|
|
||||||
"default_ttl": {
|
"default_ttl": {
|
||||||
Type: framework.TypeString,
|
Type: framework.TypeDurationSecond,
|
||||||
Description: "Default ttl for role.",
|
Description: "Default ttl for role.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"max_ttl": {
|
"max_ttl": {
|
||||||
Type: framework.TypeString,
|
Type: framework.TypeDurationSecond,
|
||||||
Description: "Maximum time a credential is valid for",
|
Description: "Maximum time a credential is valid for",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -114,8 +113,8 @@ func (b *databaseBackend) pathRoleRead() framework.OperationFunc {
|
||||||
"revocation_statements": role.Statements.RevocationStatements,
|
"revocation_statements": role.Statements.RevocationStatements,
|
||||||
"rollback_statements": role.Statements.RollbackStatements,
|
"rollback_statements": role.Statements.RollbackStatements,
|
||||||
"renew_statements": role.Statements.RenewStatements,
|
"renew_statements": role.Statements.RenewStatements,
|
||||||
"default_ttl": role.DefaultTTL.String(),
|
"default_ttl": role.DefaultTTL.Seconds(),
|
||||||
"max_ttl": role.MaxTTL.String(),
|
"max_ttl": role.MaxTTL.Seconds(),
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -151,19 +150,10 @@ func (b *databaseBackend) pathRoleCreate() framework.OperationFunc {
|
||||||
renewStmts := data.Get("renew_statements").(string)
|
renewStmts := data.Get("renew_statements").(string)
|
||||||
|
|
||||||
// Get TTLs
|
// Get TTLs
|
||||||
defaultTTLRaw := data.Get("default_ttl").(string)
|
defaultTTLRaw := data.Get("default_ttl").(int)
|
||||||
maxTTLRaw := data.Get("max_ttl").(string)
|
maxTTLRaw := data.Get("max_ttl").(int)
|
||||||
|
defaultTTL := time.Duration(defaultTTLRaw) * time.Second
|
||||||
defaultTTL, err := time.ParseDuration(defaultTTLRaw)
|
maxTTL := time.Duration(maxTTLRaw) * time.Second
|
||||||
if err != nil {
|
|
||||||
return logical.ErrorResponse(fmt.Sprintf(
|
|
||||||
"invalid default_ttl: %s", err)), nil
|
|
||||||
}
|
|
||||||
maxTTL, err := time.ParseDuration(maxTTLRaw)
|
|
||||||
if err != nil {
|
|
||||||
return logical.ErrorResponse(fmt.Sprintf(
|
|
||||||
"invalid max_ttl: %s", err)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
statements := dbplugin.Statements{
|
statements := dbplugin.Statements{
|
||||||
CreationStatements: creationStmts,
|
CreationStatements: creationStmts,
|
||||||
|
|
Loading…
Reference in New Issue