Define a bunch of stubs that will replace existing init hooks. (#23557)

This commit is contained in:
Nick Cabatoff 2023-10-06 15:17:18 -04:00 committed by GitHub
parent 1e132479f0
commit 2b460a3a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 169 additions and 19 deletions

View File

@ -64,6 +64,7 @@ import (
// Thus, rather than creating multiple instances of it, we only need one.
var Registry = newRegistry()
// TODO remove once entAddExtPlugins is implemented in ENT
var addExternalPlugins = addExtPluginsImpl
// BuiltinFactory is the func signature that should be returned by

View File

@ -0,0 +1,8 @@
//go:build !enterprise
package builtinplugins
//go:generate go run github.com/hashicorp/vault/tools/stubmaker
func entAddExtPlugins(r *registry) {
}

View File

@ -21,16 +21,19 @@ import (
)
var (
// TODO remove once entWrapGenericHandler is implemented in ENT
genericWrapping = func(core *vault.Core, in http.Handler, props *vault.HandlerProperties) http.Handler {
// Wrap the help wrapped handler with another layer with a generic
// handler
return wrapGenericHandler(core, in, props)
}
// TODO remove once entAdditionalRoutes is implemented in ENT
additionalRoutes = func(mux *http.ServeMux, core *vault.Core) {}
nonVotersAllowed = false
// TODO remove once entAdjustResponse is implemented in ENT
adjustResponse = func(core *vault.Core, w http.ResponseWriter, req *logical.Request) {}
)

21
http/util_stubs_oss.go Normal file
View File

@ -0,0 +1,21 @@
//go:build !enterprise
package http
import (
"net/http"
"github.com/hashicorp/vault/vault"
)
//go:generate go run github.com/hashicorp/vault/tools/stubmaker
func entWrapGenericHandler(core *vault.Core, in http.Handler, props *vault.HandlerProperties) http.Handler {
// Wrap the help wrapped handler with another layer with a generic
// handler
return wrapGenericHandler(core, in, props)
}
func entAdditionalRoutes(mux *http.ServeMux, core *vault.Core) {}
func entAdjustResponse() {}

View File

@ -150,26 +150,46 @@ var (
manualStepDownSleepPeriod = 10 * time.Second
// Functions only in the Enterprise version
enterprisePostUnseal = enterprisePostUnsealImpl
enterprisePreSeal = enterprisePreSealImpl
// TODO remove once entPostUnseal is implemented in ENT
enterprisePostUnseal = enterprisePostUnsealImpl
// TODO remove once entPreSeal is implemented in ENT
enterprisePreSeal = enterprisePreSealImpl
// TODO remove once entSetupFilteredPaths is implemented in ENT
enterpriseSetupFilteredPaths = enterpriseSetupFilteredPathsImpl
enterpriseSetupQuotas = enterpriseSetupQuotasImpl
enterpriseSetupAPILock = setupAPILockImpl
startReplication = startReplicationImpl
stopReplication = stopReplicationImpl
LastWAL = lastWALImpl
LastPerformanceWAL = lastPerformanceWALImpl
LastDRWAL = lastDRWALImpl
PerformanceMerkleRoot = merkleRootImpl
DRMerkleRoot = merkleRootImpl
LastRemoteWAL = lastRemoteWALImpl
LastRemoteUpstreamWAL = lastRemoteUpstreamWALImpl
WaitUntilWALShipped = waitUntilWALShippedImpl
storedLicenseCheck = func(c *Core, conf *CoreConfig) error { return nil }
LicenseAutoloaded = func(*Core) bool { return false }
LicenseInitCheck = func(*Core) error { return nil }
LicenseSummary = func(*Core) (*LicenseState, error) { return nil, nil }
LicenseReload = func(*Core) error { return nil }
// TODO remove once entSetupQuotas is implemented in ENT
enterpriseSetupQuotas = enterpriseSetupQuotasImpl
// TODO remove once entSetupAPILock is implemented in ENT
enterpriseSetupAPILock = setupAPILockImpl
// TODO remove once entStartReplication is implemented in ENT
startReplication = startReplicationImpl
// TODO remove once entStopReplication is implemented in ENT
stopReplication = stopReplicationImpl
// TODO remove once EntLastWAL is implemented in ENT
LastWAL = lastWALImpl
// TODO remove once EntLastPerformanceWAL is implemented in ENT
LastPerformanceWAL = lastPerformanceWALImpl
// TODO remove once EntLastDRWAL is implemented in ENT
LastDRWAL = lastDRWALImpl
// TODO remove once EntPerformanceMerkleRoot is implemented in ENT
PerformanceMerkleRoot = merkleRootImpl
// TODO remove once EntDRMerkleRoot is implemented in ENT
DRMerkleRoot = merkleRootImpl
// TODO remove once EntLastRemoteWAL is implemented in ENT
LastRemoteWAL = lastRemoteWALImpl
// TODO remove once entLastRemoteUpstreamWAL is implemented in ENT
LastRemoteUpstreamWAL = lastRemoteUpstreamWALImpl
// TODO remove once EntWaitUntilWALShipped is implemented in ENT
WaitUntilWALShipped = waitUntilWALShippedImpl
// TODO remove once entCheckStoredLicense is implemented in ENT
storedLicenseCheck = func(c *Core, conf *CoreConfig) error { return nil }
// TODO remove once entIsLicenseAutoloaded is implemented in ENT
LicenseAutoloaded = func(*Core) bool { return false }
// TODO remove once entCheckLicenseInit is implemented in ENT
LicenseInitCheck = func(*Core) error { return nil }
// TODO remove once entGetLicenseState is implemented in ENT
LicenseSummary = func(*Core) (*LicenseState, error) { return nil, nil }
// TODO remove once entReloadLicense is implemented in ENT
LicenseReload = func(*Core) error { return nil }
)
// NonFatalError is an error that can be returned during NewCore that should be

95
vault/core_stubs_oss.go Normal file
View File

@ -0,0 +1,95 @@
//go:build !enterprise
package vault
import "context"
//go:generate go run github.com/hashicorp/vault/tools/stubmaker
func (c *Core) entInitWALPassThrough() func() {
return nil
}
func (c *Core) entCheckStoredLicense(conf *CoreConfig) error {
return nil
}
func (c *Core) entIsLicenseAutoloaded() bool {
return false
}
func (c *Core) entCheckLicenseInit() error {
return nil
}
func (c *Core) entGetLicenseState() (*LicenseState, error) {
return nil, nil
}
func (c *Core) entReloadLicense() error {
return nil
}
func (c *Core) entPostUnseal(isStandby bool) error {
return nil
}
func (c *Core) entPreSeal() error {
return nil
}
func (c *Core) entSetupFilteredPaths() error {
return nil
}
func (c *Core) entSetupQuotas(ctx context.Context) error {
return nil
}
func (c *Core) entSetupAPILock(ctx context.Context) error {
return nil
}
func (c *Core) entBlockRequestIfError(nsPath, requestPath string) error {
return nil
}
func (c *Core) entStartReplication() error {
return nil
}
func (c *Core) entStopReplication() error {
return nil
}
func (c *Core) EntLastWAL() uint64 {
return 0
}
func (c *Core) EntLastPerformanceWAL() uint64 {
return 0
}
func (c *Core) EntLastDRWAL() uint64 {
return 0
}
func (c *Core) EntDRMerkleRoot() string {
return ""
}
func (c *Core) EntPerformanceMerkleRoot() string {
return ""
}
func (c *Core) EntLastRemoteWAL() uint64 {
return 0
}
func (c *Core) entLastRemoteUpstreamWAL() uint64 {
return 0
}
func (c *Core) EntWaitUntilWALShipped(ctx context.Context, index uint64) bool {
return true
}

View File

@ -40,6 +40,7 @@ type InitResult struct {
}
var (
// TODO remove once entInitWALPassThrough is implemented in ENT
initPTFunc = func(c *Core) func() { return nil }
initInProgress uint32
ErrInitWithoutAutoloading = errors.New("cannot initialize storage without an autoloaded license")

View File

@ -58,6 +58,7 @@ var (
// if this returns an error, the request should be blocked and the error
// should be returned to the client
// TODO remove once entBlockRequestIfError is implemented in ENT
enterpriseBlockRequestIfError = blockRequestIfErrorImpl
)