konveyor / move2kube-api

HTTP REST API for move2kube
https://move2kube.konveyor.io/
Apache License 2.0
6 stars 18 forks source link

fix: bug where the sourceDir field in the m2k.plan file contains long relative paths when running locally on MacOS #109

Closed HarikrishnanBalagopal closed 2 years ago

HarikrishnanBalagopal commented 2 years ago

feat: copy over the m2k graph file into the output zip file

Bug

Overview

$ echo "$TMPDIR"
/var/folders/dt/y3srs7vs6pz9bqwrbjwt38pc0000gp/T/
$ readlink -f "$TMPDIR"
/private/var/folders/dt/y3srs7vs6pz9bqwrbjwt38pc0000gp/T

This is the cause of the bug. The reason we have long weird relative paths in the m2k.plan file when using the UI is because MacOS creates a symbolic link from /var to the /private/var directory.

$ ls -la /
...
lrwxr-xr-x  1 root wheel   11 Feb  7 02:52 var -> private/var
...

Steps to reproduce

  1. Do yarn run start in move2kube-ui on MacOS to start Move2Kube UI.
  2. Upload language-platforms.zip and start planning in the UI.
  3. The displayed plan file will contain a weird long relative path (example: ../../../../var/folders/......)

Proposed fix

https://pkg.go.dev/path/filepath#EvalSymlinks Use EvalSymlinks to resolve the symbolic link before using it and giving it to functions like filepath.Rel, etc.

github-actions[bot] commented 2 years ago

Thanks for making a pull request! 😃 One of the maintainers will review and advise on the next steps.