Set namespace on vault client if VAULT_NAMESPACE env is set (#6867)
parent
b65cf281fd
commit
45bb11e020
@ -0,0 +1,14 @@ |
||||
package consts |
||||
|
||||
const ( |
||||
// ExpirationRestoreWorkerCount specifies the number of workers to use while
|
||||
// restoring leases into the expiration manager
|
||||
ExpirationRestoreWorkerCount = 64 |
||||
|
||||
// NamespaceHeaderName is the header set to specify which namespace the
|
||||
// request is indented for.
|
||||
NamespaceHeaderName = "X-Vault-Namespace" |
||||
|
||||
// AuthHeaderName is the name of the header containing the token.
|
||||
AuthHeaderName = "X-Vault-Token" |
||||
) |
@ -0,0 +1,16 @@ |
||||
package consts |
||||
|
||||
import "errors" |
||||
|
||||
var ( |
||||
// ErrSealed is returned if an operation is performed on a sealed barrier.
|
||||
// No operation is expected to succeed before unsealing
|
||||
ErrSealed = errors.New("Vault is sealed") |
||||
|
||||
// ErrStandby is returned if an operation is performed on a standby Vault.
|
||||
// No operation is expected to succeed until active.
|
||||
ErrStandby = errors.New("Vault is in standby mode") |
||||
|
||||
// Used when .. is used in a path
|
||||
ErrPathContainsParentReferences = errors.New("path cannot contain parent references") |
||||
) |
@ -0,0 +1,59 @@ |
||||
package consts |
||||
|
||||
import "fmt" |
||||
|
||||
var PluginTypes = []PluginType{ |
||||
PluginTypeUnknown, |
||||
PluginTypeCredential, |
||||
PluginTypeDatabase, |
||||
PluginTypeSecrets, |
||||
} |
||||
|
||||
type PluginType uint32 |
||||
|
||||
// This is a list of PluginTypes used by Vault.
|
||||
// If we need to add any in the future, it would
|
||||
// be best to add them to the _end_ of the list below
|
||||
// because they resolve to incrementing numbers,
|
||||
// which may be saved in state somewhere. Thus if
|
||||
// the name for one of those numbers changed because
|
||||
// a value were added to the middle, that could cause
|
||||
// the wrong plugin types to be read from storage
|
||||
// for a given underlying number. Example of the problem
|
||||
// here: https://play.golang.org/p/YAaPw5ww3er
|
||||
const ( |
||||
PluginTypeUnknown PluginType = iota |
||||
PluginTypeCredential |
||||
PluginTypeDatabase |
||||
PluginTypeSecrets |
||||
) |
||||
|
||||
func (p PluginType) String() string { |
||||
switch p { |
||||
case PluginTypeUnknown: |
||||
return "unknown" |
||||
case PluginTypeCredential: |
||||
return "auth" |
||||
case PluginTypeDatabase: |
||||
return "database" |
||||
case PluginTypeSecrets: |
||||
return "secret" |
||||
default: |
||||
return "unsupported" |
||||
} |
||||
} |
||||
|
||||
func ParsePluginType(pluginType string) (PluginType, error) { |
||||
switch pluginType { |
||||
case "unknown": |
||||
return PluginTypeUnknown, nil |
||||
case "auth": |
||||
return PluginTypeCredential, nil |
||||
case "database": |
||||
return PluginTypeDatabase, nil |
||||
case "secret": |
||||
return PluginTypeSecrets, nil |
||||
default: |
||||
return PluginTypeUnknown, fmt.Errorf("%q is not a supported plugin type", pluginType) |
||||
} |
||||
} |
@ -0,0 +1,87 @@ |
||||
package consts |
||||
|
||||
import "time" |
||||
|
||||
type ReplicationState uint32 |
||||
|
||||
var ReplicationStaleReadTimeout = 2 * time.Second |
||||
|
||||
const ( |
||||
_ ReplicationState = iota |
||||
OldReplicationPrimary |
||||
OldReplicationSecondary |
||||
OldReplicationBootstrapping |
||||
// Don't add anything here. Adding anything to this Old block would cause
|
||||
// the rest of the values to change below. This was done originally to
|
||||
// ensure no overlap between old and new values.
|
||||
|
||||
ReplicationUnknown ReplicationState = 0 |
||||
ReplicationPerformancePrimary ReplicationState = 1 << iota |
||||
ReplicationPerformanceSecondary |
||||
OldSplitReplicationBootstrapping |
||||
ReplicationDRPrimary |
||||
ReplicationDRSecondary |
||||
ReplicationPerformanceBootstrapping |
||||
ReplicationDRBootstrapping |
||||
ReplicationPerformanceDisabled |
||||
ReplicationDRDisabled |
||||
ReplicationPerformanceStandby |
||||
) |
||||
|
||||
func (r ReplicationState) string() string { |
||||
switch r { |
||||
case ReplicationPerformanceSecondary: |
||||
return "secondary" |
||||
case ReplicationPerformancePrimary: |
||||
return "primary" |
||||
case ReplicationPerformanceBootstrapping: |
||||
return "bootstrapping" |
||||
case ReplicationPerformanceDisabled: |
||||
return "disabled" |
||||
case ReplicationDRPrimary: |
||||
return "primary" |
||||
case ReplicationDRSecondary: |
||||
return "secondary" |
||||
case ReplicationDRBootstrapping: |
||||
return "bootstrapping" |
||||
case ReplicationDRDisabled: |
||||
return "disabled" |
||||
} |
||||
|
||||
return "unknown" |
||||
} |
||||
|
||||
func (r ReplicationState) GetDRString() string { |
||||
switch { |
||||
case r.HasState(ReplicationDRBootstrapping): |
||||
return ReplicationDRBootstrapping.string() |
||||
case r.HasState(ReplicationDRPrimary): |
||||
return ReplicationDRPrimary.string() |
||||
case r.HasState(ReplicationDRSecondary): |
||||
return ReplicationDRSecondary.string() |
||||
case r.HasState(ReplicationDRDisabled): |
||||
return ReplicationDRDisabled.string() |
||||
default: |
||||
return "unknown" |
||||
} |
||||
} |
||||
|
||||
func (r ReplicationState) GetPerformanceString() string { |
||||
switch { |
||||
case r.HasState(ReplicationPerformanceBootstrapping): |
||||
return ReplicationPerformanceBootstrapping.string() |
||||
case r.HasState(ReplicationPerformancePrimary): |
||||
return ReplicationPerformancePrimary.string() |
||||
case r.HasState(ReplicationPerformanceSecondary): |
||||
return ReplicationPerformanceSecondary.string() |
||||
case r.HasState(ReplicationPerformanceDisabled): |
||||
return ReplicationPerformanceDisabled.string() |
||||
default: |
||||
return "unknown" |
||||
} |
||||
} |
||||
|
||||
func (r ReplicationState) HasState(flag ReplicationState) bool { return r&flag != 0 } |
||||
func (r *ReplicationState) AddState(flag ReplicationState) { *r |= flag } |
||||
func (r *ReplicationState) ClearState(flag ReplicationState) { *r &= ^flag } |
||||
func (r *ReplicationState) ToggleState(flag ReplicationState) { *r ^= flag } |
Loading…
Reference in new issue