fix: improve mount path warning for PostgreSQL by handling multiple data mounts

This commit is contained in:
Mauricio Siu
2026-08-08 23:36:48 -06:00
parent 6a10923a50
commit c0694eb5b2
@@ -109,16 +109,21 @@ export const ShowCustomCommand = ({ id, type }: Props) => {
const mountPathWarning = (() => { const mountPathWarning = (() => {
if (type !== "postgres" || !dockerImage) return null; if (type !== "postgres" || !dockerImage) return null;
const mounts = (data as any)?.mounts ?? []; const mounts = data && "mounts" in data ? data.mounts : [];
const dataMount = mounts.find( const dataMounts = mounts.filter(
(mount: { type: string; mountPath: string }) => (mount) =>
mount.type === "volume" && mount.type === "volume" &&
POSTGRES_DATA_PATH_REGEX.test(mount.mountPath), POSTGRES_DATA_PATH_REGEX.test(mount.mountPath),
); );
if (!dataMount) return null; if (dataMounts.length === 0) return null;
const expectedPath = getPostgresMountPath(dockerImage); const expectedPath = getPostgresMountPath(dockerImage);
if (expectedPath === dataMount.mountPath) return null; if (dataMounts.some((mount) => mount.mountPath === expectedPath)) {
return { expectedPath, currentPath: dataMount.mountPath }; return null;
}
return {
expectedPath,
currentPath: dataMounts.map((mount) => mount.mountPath).join(", "),
};
})(); })();
const onSubmit = async (formData: AddDockerImage) => { const onSubmit = async (formData: AddDockerImage) => {