mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 10:12:35 +00:00
Add compile tests to verify physical stores satisfy the correct interfaces (#3820)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user