validate plugin and module ids
Signed-off-by: Juan Pablo Garcia Ripa <sarabadu@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CONFIG_KEY_PART_PATTERN } from '@backstage/config';
|
||||
import { BackendFeature } from '../types';
|
||||
import {
|
||||
BackendModuleRegistrationPoints,
|
||||
@@ -55,6 +56,12 @@ export function createBackendModule(
|
||||
options: CreateBackendModuleOptions,
|
||||
): BackendFeature {
|
||||
function getRegistrations() {
|
||||
if (!CONFIG_KEY_PART_PATTERN.test(options.moduleId)) {
|
||||
throw new Error(
|
||||
`Invalid moduleId '${options.moduleId}' for plugin '${options.pluginId}', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`,
|
||||
);
|
||||
}
|
||||
|
||||
const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =
|
||||
[];
|
||||
let init: InternalBackendModuleRegistration['init'] | undefined = undefined;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CONFIG_KEY_PART_PATTERN } from '@backstage/config';
|
||||
import { BackendFeature } from '../types';
|
||||
import {
|
||||
BackendPluginRegistrationPoints,
|
||||
@@ -49,6 +50,12 @@ export function createBackendPlugin(
|
||||
options: CreateBackendPluginOptions,
|
||||
): BackendFeature {
|
||||
function getRegistrations() {
|
||||
if (!CONFIG_KEY_PART_PATTERN.test(options.pluginId)) {
|
||||
throw new Error(
|
||||
`Invalid pluginId '${options.pluginId}', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`,
|
||||
);
|
||||
}
|
||||
|
||||
const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =
|
||||
[];
|
||||
let init: InternalBackendPluginRegistration['init'] | undefined = undefined;
|
||||
|
||||
Reference in New Issue
Block a user