Signed-off-by: npiyush97 <npiyush35@gmail.com>
This commit is contained in:
npiyush97
2024-02-12 20:44:58 +05:30
parent 863414127b
commit adc0414cf7
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-import': patch
---
fix related to component name not adhering to kubernetes validobjectname.
@@ -143,11 +143,25 @@ export const StepPrepareCreatePullRequest = (
.sort();
});
const isValidObjectName = (value: unknown): boolean => {
return (
typeof value === 'string' &&
value.length >= 1 &&
value.length <= 63 &&
/^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$/.test(value)
);
};
const handleResult = useCallback(
async (data: FormData) => {
setSubmitted(true);
try {
if (!isValidObjectName(data.componentName)) {
throw new Error(
'Component name: Must start and end with an alphanumeric character, and contain only alphanumeric characters, hyphens, underscores, and periods. Maximum length is 63 characters.',
);
}
const pr = await catalogImportApi.submitPullRequest({
repositoryUrl: analyzeResult.url,
title: data.title,