Small refactor of mount entry manipulation (#16024)

This commit is contained in:
Violet Hynes 2022-06-17 08:52:43 -04:00 committed by GitHub
parent 37edd59828
commit 96371ed0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -193,15 +193,9 @@ func (b *SystemBackend) handleRateLimitQuotasUpdate() framework.OperationFunc {
return logical.ErrorResponse("invalid mount path %q", mountPath), nil
}
var newMountPath string
if me.Table == mountTableType {
newMountPath = me.Path
} else {
newMountPath = me.Table + "/" + me.Path
}
pathSuffix = strings.TrimSuffix(strings.TrimPrefix(mountPath, newMountPath), "/")
mountPath = newMountPath
mountAPIPath := me.APIPathNoNamespace()
pathSuffix = strings.TrimSuffix(strings.TrimPrefix(mountPath, mountAPIPath), "/")
mountPath = mountAPIPath
}
// Disallow creation of new quota that has properties similar to an
// existing quota.

View File

@ -391,6 +391,15 @@ func (e *MountEntry) APIPath() string {
return e.namespace.Path + path
}
// APIPathNoNamespace returns the API Path without the namespace for the given mount entry
func (e *MountEntry) APIPathNoNamespace() string {
path := e.Path
if e.Table == credentialTableType {
path = credentialRoutePrefix + path
}
return path
}
// SyncCache syncs tunable configuration values to the cache. In the case of
// cached values, they should be retrieved via synthesizedConfigCache.Load()
// instead of accessing them directly through MountConfig.