sonata-nfv / tng-sdk-project

The 5GTANGO SDK tool to manage network service projects.
http://www.5gtango.eu
Apache License 2.0
5 stars 4 forks source link

BUG: Paths in project.yml should be relative to project folder root #15

Closed mpeuster closed 6 years ago

mpeuster commented 6 years ago

Now we have:

descriptor_extension: yml
files:
- path: test_project1/sources/vnfd/vnfd-sample.yml
  tags:
  - eu.5gtango
  type: application/vnd.5gtango.vnfd
- path: test_project1/sources/nsd/nsd-sample.yml
  tags:
  - eu.5gtango
  type: application/vnd.5gtango.nsd
package:
  description: Some description about this sample
  maintainer: Name, Company, Contact
  name: 5gtango-project-sample
  vendor: eu.5gtango
  version: '0.1'
version: '0.5'

but test_project1 should not be part of the paths to the files. The paths need to be relative to the project.yml itself, not to the PWD in which tng-project was called.

Should be:

descriptor_extension: yml
files:
- path: sources/vnfd/vnfd-sample.yml
  tags:
  - eu.5gtango
  type: application/vnd.5gtango.vnfd
- path: sources/nsd/nsd-sample.yml
  tags:
  - eu.5gtango
  type: application/vnd.5gtango.nsd
package:
  description: Some description about this sample
  maintainer: Name, Company, Contact
  name: 5gtango-project-sample
  vendor: eu.5gtango
  version: '0.1'
version: '0.5'
stefanbschneider commented 6 years ago

I thought this could easily be fixed by adding

# change into project root directory (for correct relative paths)
os.chdir(self._prj_root)

inside _create_dirs() and avoid using _prj_root for constructing paths from then on. It works fine when creating projects but breaks when adding new files. I'll have to look into it again on Firday.

stefanbschneider commented 6 years ago

TODO: Properly deal with relative paths, given that we don't know, in which directory tng-project is executed.

When adding/removing a file with tng-project -p <prj-path> --add file <file-path>:

Does that make sense?

mpeuster commented 6 years ago

You know the absolute path of project.yml, say /x/y/z/project.yml then get the basepath of it (folder w/o file name): /x/y/z/ ... then the relative path to the project root is the absolute path of the added file minus /x/y/z. This would not require any change dir operations or so.