Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-14922: Allow 'patch' in custom manifest file name #2252

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libs/ui-lib/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,9 @@ export const getMaxFileSizeMessage = `File size is too big. The file size must b
)}.`;

export const validateFileName = (fileName: string) => {
return new RegExp(FILENAME_REGEX).test(fileName || '');
return (
new RegExp(FILENAME_REGEX).test(fileName || '') ||
fileName.indexOf('.yaml.patch') > -1 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct, because FILENAME_REGEX is ensuring that the fileName does not contain a slash. If one of the ORs becomes true, it could be for a fileName containing a slash.

I think we should use a second regular expression that contains the same part about the slash, and additionally it validates the yaml.patch or yml.patch part.

Also, note that FILENAME_REGEX is already a regular expression, so doing new RegExp(regexp) is unnecessary and less eficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've marked as draft this PR because BE is not allowing us to put .yaml.patch or .yml.patch in the name. I'm waiting for BE response to see how we can align the regexp.

fileName.indexOf('.yml.patch') > -1
);
};