diff --git a/physical/azure/azure.go b/physical/azure/azure.go index 122c40b9b3..c0b67e9a38 100644 --- a/physical/azure/azure.go +++ b/physical/azure/azure.go @@ -32,6 +32,9 @@ type AzureBackend struct { permitPool *physical.PermitPool } +// Verify AzureBackend satisfies the correct interfaces +var _ physical.Backend = (*AzureBackend)(nil) + // NewAzureBackend constructs an Azure backend using a pre-existing // bucket. Credentials can be provided to the backend, sourced // from the environment, AWS credential files or by IAM role. diff --git a/physical/cache.go b/physical/cache.go index bca6290361..ad3fb11a88 100644 --- a/physical/cache.go +++ b/physical/cache.go @@ -33,7 +33,11 @@ type TransactionalCache struct { Transactional } -var _ Purgable = &Cache{} +// Verify Cache satisfies the correct interfaces +var _ Purgable = (*Cache)(nil) +var _ Backend = (*Cache)(nil) +var _ Transactional = (*TransactionalCache)(nil) +var _ Purgable = (*TransactionalCache)(nil) // NewCache returns a physical cache of the given size. // If no size is provided, the default size is used. diff --git a/physical/cassandra/cassandra.go b/physical/cassandra/cassandra.go index be19e86f67..2a8f87e06f 100644 --- a/physical/cassandra/cassandra.go +++ b/physical/cassandra/cassandra.go @@ -26,6 +26,9 @@ type CassandraBackend struct { logger log.Logger } +// Verify CassandraBackend satisfies the correct interfaces +var _ physical.Backend = (*CassandraBackend)(nil) + // NewCassandraBackend constructs a Cassandra backend using a pre-existing // keyspace and table. func NewCassandraBackend(conf map[string]string, logger log.Logger) (physical.Backend, error) { diff --git a/physical/cockroachdb/cockroachdb.go b/physical/cockroachdb/cockroachdb.go index c63efa3dfd..d99589d158 100644 --- a/physical/cockroachdb/cockroachdb.go +++ b/physical/cockroachdb/cockroachdb.go @@ -20,7 +20,9 @@ import ( _ "github.com/lib/pq" ) -var _ physical.Transactional = &CockroachDBBackend{} +// Verify CockroachDBBackend satisfies the correct interfaces +var _ physical.Backend = (*CockroachDBBackend)(nil) +var _ physical.Transactional = (*CockroachDBBackend)(nil) // CockroachDBBackend Backend is a physical backend that stores data // within a CockroachDB database. diff --git a/physical/consul/consul.go b/physical/consul/consul.go index 9e5a355b12..3286209c74 100644 --- a/physical/consul/consul.go +++ b/physical/consul/consul.go @@ -67,11 +67,11 @@ const ( type notifyEvent struct{} -// Verify interfaces are satisfied -var _ physical.Backend = &ConsulBackend{} -var _ physical.HABackend = &ConsulBackend{} -var _ physical.Lock = &ConsulLock{} -var _ physical.Transactional = &ConsulBackend{} +// Verify ConsulBackend satisfies the correct interfaces +var _ physical.Backend = (*ConsulBackend)(nil) +var _ physical.HABackend = (*ConsulBackend)(nil) +var _ physical.Lock = (*ConsulLock)(nil) +var _ physical.Transactional = (*ConsulBackend)(nil) // ConsulBackend is a physical backend that stores data at specific // prefix within Consul. It is used for most production situations as diff --git a/physical/couchdb/couchdb.go b/physical/couchdb/couchdb.go index af66d18af1..76fb3679e0 100644 --- a/physical/couchdb/couchdb.go +++ b/physical/couchdb/couchdb.go @@ -27,6 +27,11 @@ type CouchDBBackend struct { permitPool *physical.PermitPool } +// Verify CouchDBBackend satisfies the correct interfaces +var _ physical.Backend = (*CouchDBBackend)(nil) +var _ physical.PseudoTransactional = (*CouchDBBackend)(nil) +var _ physical.PseudoTransactional = (*TransactionalCouchDBBackend)(nil) + type couchDBClient struct { endpoint string username string @@ -254,8 +259,6 @@ func (m *CouchDBBackend) List(ctx context.Context, prefix string) ([]string, err return out, nil } -var _ physical.PseudoTransactional = &TransactionalCouchDBBackend{} - // TransactionalCouchDBBackend creates a couchdb backend that forces all operations to happen // in serial type TransactionalCouchDBBackend struct { diff --git a/physical/dynamodb/dynamodb.go b/physical/dynamodb/dynamodb.go index 41ab0e6f44..bd12c47d45 100644 --- a/physical/dynamodb/dynamodb.go +++ b/physical/dynamodb/dynamodb.go @@ -69,6 +69,11 @@ const ( DynamoDBWatchRetryInterval = 5 * time.Second ) +// Verify DynamoDBBackend satisfies the correct interfaces +var _ physical.Backend = (*DynamoDBBackend)(nil) +var _ physical.HABackend = (*DynamoDBBackend)(nil) +var _ physical.Lock = (*DynamoDBLock)(nil) + // DynamoDBBackend is a physical backend that stores data in // a DynamoDB table. It can be run in high-availability mode // as DynamoDB has locking capabilities. diff --git a/physical/etcd/etcd2.go b/physical/etcd/etcd2.go index 1a996ef637..893f8de667 100644 --- a/physical/etcd/etcd2.go +++ b/physical/etcd/etcd2.go @@ -55,10 +55,10 @@ type Etcd2Backend struct { haEnabled bool } -// Verify interfaces are satisfied -var _ physical.Backend = &Etcd2Backend{} -var _ physical.HABackend = &Etcd2Backend{} -var _ physical.Lock = &Etcd2Lock{} +// Verify Etcd2Backend satisfies the correct interfaces +var _ physical.Backend = (*Etcd2Backend)(nil) +var _ physical.HABackend = (*Etcd2Backend)(nil) +var _ physical.Lock = (*Etcd2Lock)(nil) func newEtcd2Backend(conf map[string]string, logger log.Logger) (physical.Backend, error) { // Get the etcd path form the configuration. diff --git a/physical/etcd/etcd3.go b/physical/etcd/etcd3.go index 8420e41e5b..2495e6f5fe 100644 --- a/physical/etcd/etcd3.go +++ b/physical/etcd/etcd3.go @@ -41,10 +41,10 @@ const ( etcd3RequestTimeout = 5 * time.Second ) -// Verify interfaces are satisfied -var _ physical.Backend = &EtcdBackend{} -var _ physical.HABackend = &EtcdBackend{} -var _ physical.Lock = &EtcdLock{} +// Verify EtcdBackend satisfies the correct interfaces +var _ physical.Backend = (*EtcdBackend)(nil) +var _ physical.HABackend = (*EtcdBackend)(nil) +var _ physical.Lock = (*EtcdLock)(nil) // newEtcd3Backend constructs a etcd3 backend. func newEtcd3Backend(conf map[string]string, logger log.Logger) (physical.Backend, error) { diff --git a/physical/file/file.go b/physical/file/file.go index 280b3eecb3..b739913cf0 100644 --- a/physical/file/file.go +++ b/physical/file/file.go @@ -17,9 +17,10 @@ import ( "github.com/hashicorp/vault/physical" ) -// Verify interfaces are satisfied -var _ physical.Backend = &FileBackend{} -var _ physical.Transactional = &TransactionalFileBackend{} +// Verify FileBackend satisfies the correct interfaces +var _ physical.Backend = (*FileBackend)(nil) +var _ physical.Transactional = (*TransactionalFileBackend)(nil) +var _ physical.PseudoTransactional = (*FileBackend)(nil) // FileBackend is a physical backend that stores data on disk // at a given file path. It can be used for durable single server diff --git a/physical/gcs/gcs.go b/physical/gcs/gcs.go index 3ee1a6663a..e9748a5209 100644 --- a/physical/gcs/gcs.go +++ b/physical/gcs/gcs.go @@ -20,8 +20,8 @@ import ( "google.golang.org/api/option" ) -// Verify interfaces are satisfied -var _ physical.Backend = &GCSBackend{} +// Verify GCSBackend satisfies the correct interfaces +var _ physical.Backend = (*GCSBackend)(nil) // GCSBackend is a physical backend that stores data // within an Google Cloud Storage bucket. diff --git a/physical/inmem/inmem.go b/physical/inmem/inmem.go index d20a4e29e1..4501bab32d 100644 --- a/physical/inmem/inmem.go +++ b/physical/inmem/inmem.go @@ -12,11 +12,12 @@ import ( ) // Verify interfaces are satisfied -var _ physical.Backend = &InmemBackend{} -var _ physical.HABackend = &InmemHABackend{} -var _ physical.Lock = &InmemLock{} -var _ physical.Transactional = &TransactionalInmemBackend{} -var _ physical.Transactional = &TransactionalInmemHABackend{} +var _ physical.Backend = (*InmemBackend)(nil) +var _ physical.HABackend = (*InmemHABackend)(nil) +var _ physical.HABackend = (*TransactionalInmemHABackend)(nil) +var _ physical.Lock = (*InmemLock)(nil) +var _ physical.Transactional = (*TransactionalInmemBackend)(nil) +var _ physical.Transactional = (*TransactionalInmemHABackend)(nil) // InmemBackend is an in-memory only physical backend. It is useful // for testing and development situations where the data is not diff --git a/physical/latency.go b/physical/latency.go index e7ee5342b2..61f9729520 100644 --- a/physical/latency.go +++ b/physical/latency.go @@ -28,6 +28,10 @@ type TransactionalLatencyInjector struct { Transactional } +// Verify LatencyInjector satisfies the correct interfaces +var _ Backend = (*LatencyInjector)(nil) +var _ Transactional = (*TransactionalLatencyInjector)(nil) + // NewLatencyInjector returns a wrapped physical backend to simulate latency func NewLatencyInjector(b Backend, latency time.Duration, jitter int, logger log.Logger) *LatencyInjector { if jitter < 0 || jitter > 100 { diff --git a/physical/mssql/mssql.go b/physical/mssql/mssql.go index f9ebd95971..a9af982456 100644 --- a/physical/mssql/mssql.go +++ b/physical/mssql/mssql.go @@ -17,6 +17,9 @@ import ( log "github.com/mgutz/logxi/v1" ) +// Verify MSSQLBackend satisfies the correct interfaces +var _ physical.Backend = (*MSSQLBackend)(nil) + type MSSQLBackend struct { dbTable string client *sql.DB diff --git a/physical/mysql/mysql.go b/physical/mysql/mysql.go index 9b9e6eee67..818303042a 100644 --- a/physical/mysql/mysql.go +++ b/physical/mysql/mysql.go @@ -22,6 +22,9 @@ import ( "github.com/hashicorp/vault/physical" ) +// Verify MySQLBackend satisfies the correct interfaces +var _ physical.Backend = (*MySQLBackend)(nil) + // Unreserved tls key // Reserved values are "true", "false", "skip-verify" const mysqlTLSKey = "default" diff --git a/physical/physical_view.go b/physical/physical_view.go index d19d7d935d..da505a4f1f 100644 --- a/physical/physical_view.go +++ b/physical/physical_view.go @@ -16,6 +16,9 @@ type View struct { prefix string } +// Verify View satisfies the correct interfaces +var _ Backend = (*View)(nil) + // NewView takes an underlying physical backend and returns // a view of it that can only operate with the given prefix. func NewView(backend Backend, prefix string) *View { diff --git a/physical/postgresql/postgresql.go b/physical/postgresql/postgresql.go index ca6accf7b7..d54598f346 100644 --- a/physical/postgresql/postgresql.go +++ b/physical/postgresql/postgresql.go @@ -16,6 +16,9 @@ import ( "github.com/lib/pq" ) +// Verify PostgreSQLBackend satisfies the correct interfaces +var _ physical.Backend = (*PostgreSQLBackend)(nil) + // PostgreSQL Backend is a physical backend that stores data // within a PostgreSQL database. type PostgreSQLBackend struct { diff --git a/physical/s3/s3.go b/physical/s3/s3.go index 2eb473d70a..9f8084ac65 100644 --- a/physical/s3/s3.go +++ b/physical/s3/s3.go @@ -27,6 +27,9 @@ import ( "github.com/hashicorp/vault/physical" ) +// Verify S3Backend satisfies the correct interfaces +var _ physical.Backend = (*S3Backend)(nil) + // S3Backend is a physical backend that stores data // within an S3 bucket. type S3Backend struct { diff --git a/physical/swift/swift.go b/physical/swift/swift.go index 0f611b0171..91d6f1263a 100644 --- a/physical/swift/swift.go +++ b/physical/swift/swift.go @@ -19,6 +19,9 @@ import ( "github.com/ncw/swift" ) +// Verify SwiftBackend satisfies the correct interfaces +var _ physical.Backend = (*SwiftBackend)(nil) + // SwiftBackend is a physical backend that stores data // within an OpenStack Swift container. type SwiftBackend struct { diff --git a/physical/zookeeper/zookeeper.go b/physical/zookeeper/zookeeper.go index 7257683bfe..aa5de944bd 100644 --- a/physical/zookeeper/zookeeper.go +++ b/physical/zookeeper/zookeeper.go @@ -24,6 +24,11 @@ const ( ZKNodeFilePrefix = "_" ) +// Verify ZooKeeperBackend satisfies the correct interfaces +var _ physical.Backend = (*ZooKeeperBackend)(nil) +var _ physical.HABackend = (*ZooKeeperBackend)(nil) +var _ physical.Lock = (*ZooKeeperHALock)(nil) + // ZooKeeperBackend is a physical backend that stores data at specific // prefix within ZooKeeper. It is used in production situations as // it allows Vault to run on multiple machines in a highly-available manner.