mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-05 22:27:03 +02:00
* adding clause for external plugin to tooltip * fixing mouseover event * fix check * pulling object out of list * fix used parameter * adding comments * fix * fixing tests * adding 1 more test * update tooltip func, remove excess params, update tests
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { ALL_ENGINES } from 'vault/utils/all-engines-metadata';
|
|
|
|
/**
|
|
* Helper function to retrieve engine metadata for a given `methodType`.
|
|
* It searches the `ALL_ENGINES` array for an engine with a matching type and returns its metadata object.
|
|
* The `ALL_ENGINES` array includes secret and auth engines, including those supported only in enterprise.
|
|
* These details (such as mount type and enterprise licensing) are included in the returned engine object.
|
|
*
|
|
* Example usage:
|
|
* const engineMetadata = engineDisplayData('kmip');
|
|
* if (engineMetadata?.requiresEnterprise) {
|
|
* console.log(`This mount: ${engineMetadata.engineType} requires an enterprise license`);
|
|
* }
|
|
*
|
|
* @param {string} methodType - The engine type (sometimes called backend) to look up (e.g., "aws", "azure").
|
|
* @returns {Object|undefined} - The engine metadata, which includes information about its mount type (e.g., secret or auth)
|
|
* and whether it requires an enterprise license. Returns undefined if no match is found.
|
|
*/
|
|
export default function engineDisplayData(methodType: string) {
|
|
const engine = ALL_ENGINES?.find((t) => t.type === methodType);
|
|
if (!engine && methodType) {
|
|
// Fallback to a generic engine if no match found but type is provided
|
|
return {
|
|
displayName: 'Generic plugin',
|
|
type: 'generic',
|
|
glyph: 'lock',
|
|
mountCategory: ['secret', 'auth'],
|
|
};
|
|
}
|
|
|
|
return engine;
|
|
}
|