Skip to content

Commit 8101bc2

Browse files
support for backend's Dockerfile path
1 parent be28ec3 commit 8101bc2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

frontend/packages/dev-console/src/components/import/devfile/devfileHooks.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { useTranslation } from 'react-i18next';
44
import { parseDevfile } from '@console/internal/module/k8s';
55
import { DevfileSuggestedResources } from '../import-types';
66

7+
const suffixSlash = (val: string) => (val.endsWith('/') ? val : `${val}/`);
8+
const prefixDotSlash = (val) => (val.startsWith('/') ? val : `.${val}`);
9+
710
export const useDefileServer = (
811
values: FormikValues,
912
setFieldValue: (name: string, value: any) => any,
@@ -26,7 +29,7 @@ export const useDefileServer = (
2629

2730
return {
2831
name,
29-
git: { URL: url, ref, dir },
32+
git: { URL: url, ref, dir: prefixDotSlash(dir) },
3033
devfile: { devfileContent, devfilePath },
3134
};
3235
}, [name, url, ref, dir, devfileContent, devfilePath]);
@@ -86,8 +89,7 @@ export const useDevfileDirectoryWatcher = (
8689
git: { dir },
8790
} = values;
8891
React.useEffect(() => {
89-
let smartSlashDir = dir.endsWith('/') ? dir : `${dir}/`;
90-
smartSlashDir = smartSlashDir.startsWith('.') ? smartSlashDir : `.${smartSlashDir}`;
92+
const smartSlashDir = prefixDotSlash(suffixSlash(dir));
9193

9294
setFieldValue('devfile.devfilePath', `${smartSlashDir}devfile.yaml`);
9395
setFieldValue('docker.dockerfilePath', `${smartSlashDir}Dockerfile`);

0 commit comments

Comments
 (0)