Fixes for golint
This commit is contained in:
parent
b5377616e8
commit
e389f98ba2
|
|
@ -14,12 +14,16 @@ import (
|
|||
blog "github.com/letsencrypt/boulder/log"
|
||||
)
|
||||
|
||||
// CertificateAuthorityDatabaseImpl represents a database used by the CA; it
|
||||
// enforces transaction semantics, and is effectively single-threaded.
|
||||
type CertificateAuthorityDatabaseImpl struct {
|
||||
log *blog.AuditLogger
|
||||
db *sql.DB
|
||||
activeTx *sql.Tx
|
||||
}
|
||||
|
||||
// NewCertificateAuthorityDatabaseImpl constructs a Database for the
|
||||
// Certificate Authority.
|
||||
func NewCertificateAuthorityDatabaseImpl(logger *blog.AuditLogger, driver string, name string) (cadb core.CertificateAuthorityDatabase, err error) {
|
||||
if logger == nil {
|
||||
err = errors.New("Nil logger not permitted")
|
||||
|
|
@ -43,6 +47,9 @@ func NewCertificateAuthorityDatabaseImpl(logger *blog.AuditLogger, driver string
|
|||
return
|
||||
}
|
||||
|
||||
// createTablesIfNotExist builds the database tables and inserts the initial
|
||||
// state, if the tables do not already exist. It is not an error for the tables
|
||||
// to already exist.
|
||||
func createTablesIfNotExist(db *sql.DB) (err error) {
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
|
|
@ -68,6 +75,8 @@ func createTablesIfNotExist(db *sql.DB) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Begin starts a Database transaction. There can only be one in this object
|
||||
// at a time.
|
||||
func (cadb *CertificateAuthorityDatabaseImpl) Begin() (err error) {
|
||||
if cadb.activeTx != nil {
|
||||
err = errors.New("Transaction already open")
|
||||
|
|
@ -77,6 +86,8 @@ func (cadb *CertificateAuthorityDatabaseImpl) Begin() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Commit makes permanent a database transaction; there must be an active
|
||||
// transaction when called.
|
||||
func (cadb *CertificateAuthorityDatabaseImpl) Commit() (err error) {
|
||||
if cadb.activeTx == nil {
|
||||
err = errors.New("Transaction already closed")
|
||||
|
|
@ -87,6 +98,8 @@ func (cadb *CertificateAuthorityDatabaseImpl) Commit() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Rollback cancels the ongoing database transaction; there must be an active
|
||||
// transaction when called.
|
||||
func (cadb *CertificateAuthorityDatabaseImpl) Rollback() (err error) {
|
||||
if cadb.activeTx == nil {
|
||||
err = errors.New("Transaction already closed")
|
||||
|
|
@ -97,6 +110,10 @@ func (cadb *CertificateAuthorityDatabaseImpl) Rollback() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// IncrementAndGetSerial returns the next-available serial number, incrementing
|
||||
// it in the database before returning. There must be an active transaction to
|
||||
// call this method. Callers should Begin the transaction, call this method,
|
||||
// perform any other work, and Commit at the end once the certificate is issued.
|
||||
func (cadb *CertificateAuthorityDatabaseImpl) IncrementAndGetSerial() (val int, err error) {
|
||||
if cadb.activeTx == nil {
|
||||
err = errors.New("No transaction open")
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import (
|
|||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/signer/remote"
|
||||
)
|
||||
|
||||
// CertificateAuthorityImpl represents a CA that signs certificates, CRLs, and
|
||||
// OCSP responses.
|
||||
type CertificateAuthorityImpl struct {
|
||||
profile string
|
||||
Signer signer.Signer
|
||||
|
|
@ -73,6 +75,8 @@ func NewCertificateAuthorityImpl(logger *blog.AuditLogger, hostport string, auth
|
|||
return
|
||||
}
|
||||
|
||||
// IssueCertificate attempts to convert a CSR into a signed Certificate, while
|
||||
// enforcing all policies.
|
||||
func (ca *CertificateAuthorityImpl) IssueCertificate(csr x509.CertificateRequest) (cert core.Certificate, err error) {
|
||||
// XXX Take in authorizations and verify that union covers CSR?
|
||||
// Pull hostnames from CSR
|
||||
|
|
|
|||
13
cmd/shell.go
13
cmd/shell.go
|
|
@ -79,16 +79,19 @@ type Config struct {
|
|||
}
|
||||
}
|
||||
|
||||
// QueuePair describes a client-server pair of queue names
|
||||
type QueuePair struct {
|
||||
Client string
|
||||
Server string
|
||||
}
|
||||
|
||||
// AppShell contains CLI Metadata
|
||||
type AppShell struct {
|
||||
Action func(Config)
|
||||
app *cli.App
|
||||
}
|
||||
|
||||
// NewAppShell creates a basic AppShell object containing CLI metadata
|
||||
func NewAppShell(name string) (shell *AppShell) {
|
||||
app := cli.NewApp()
|
||||
|
||||
|
|
@ -106,6 +109,8 @@ func NewAppShell(name string) (shell *AppShell) {
|
|||
return &AppShell{app: app}
|
||||
}
|
||||
|
||||
// Run begins the application context, reading config and passing
|
||||
// control to the default commandline action.
|
||||
func (as *AppShell) Run() {
|
||||
as.app.Action = func(c *cli.Context) {
|
||||
configFileName := c.GlobalString("config")
|
||||
|
|
@ -123,7 +128,7 @@ func (as *AppShell) Run() {
|
|||
FailOnError(err, "Failed to run application")
|
||||
}
|
||||
|
||||
// Exit and print error message if we encountered a problem
|
||||
// FailOnError exits and prints an error message if we encountered a problem
|
||||
func FailOnError(err error, msg string) {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %s\n", msg, err)
|
||||
|
|
@ -131,7 +136,7 @@ func FailOnError(err error, msg string) {
|
|||
}
|
||||
}
|
||||
|
||||
// This is the same as amqpConnect in boulder, but with even
|
||||
// AmqpChannel is the same as amqpConnect in boulder, but with even
|
||||
// more aggressive error dropping
|
||||
func AmqpChannel(url string) (ch *amqp.Channel) {
|
||||
conn, err := amqp.Dial(url)
|
||||
|
|
@ -142,7 +147,7 @@ func AmqpChannel(url string) (ch *amqp.Channel) {
|
|||
return
|
||||
}
|
||||
|
||||
// Start the server and wait around
|
||||
// RunForever starts the server and wait around
|
||||
func RunForever(server *rpc.AmqpRPCServer) {
|
||||
forever := make(chan bool)
|
||||
server.Start()
|
||||
|
|
@ -150,7 +155,7 @@ func RunForever(server *rpc.AmqpRPCServer) {
|
|||
<-forever
|
||||
}
|
||||
|
||||
// Start the server and run until we get something on closeChan
|
||||
// RunUntilSignaled starts the server and run until we get something on closeChan
|
||||
func RunUntilSignaled(logger *blog.AuditLogger, server *rpc.AmqpRPCServer, closeChan chan *amqp.Error) {
|
||||
server.Start()
|
||||
fmt.Fprintf(os.Stderr, "Server running...\n")
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ type StorageAdder interface {
|
|||
AddCertificate([]byte) (string, error)
|
||||
}
|
||||
|
||||
// The StorageAuthority interface represnts a simple key/value
|
||||
// StorageAuthority interface represents a simple key/value
|
||||
// store. It is divided into StorageGetter and StorageUpdater
|
||||
// interfaces for privilege separation.
|
||||
type StorageAuthority interface {
|
||||
|
|
@ -111,7 +111,7 @@ type StorageAuthority interface {
|
|||
StorageAdder
|
||||
}
|
||||
|
||||
// The CA Database represents an atomic sequence source
|
||||
// CertificateAuthorityDatabase represents an atomic sequence source
|
||||
type CertificateAuthorityDatabase interface {
|
||||
Begin() error
|
||||
Commit() error
|
||||
|
|
|
|||
Loading…
Reference in New Issue