sonata-nfv / tng-sdk-validation

The 5GTANGO SDK validation repository
Apache License 2.0
2 stars 6 forks source link

Pass a custom workspace to tng-project #90

Closed stefanbschneider closed 5 years ago

stefanbschneider commented 5 years ago

When using a custom workspace, eg, created with tng-wks -w kubernetes, it can be specified in the validator using the --workspace flag. But this specified workspace is not passed to tng-project when loading a project for validation: https://github.com/sonata-nfv/tng-sdk-validation/blob/master/src/tngsdk/validation/validator.py#L300

Rather than using workspace=None in load_project, workspace should the the path to the custom workspace (if one is specified with --workspace).

Issue discovered by @felipevicens

mpeuster commented 5 years ago

This patch introduced a bug that stops also the packager from working (since packager now always calls the validator):

tng-validate --project misc/5gtango_ns_project_example1

gives:

18-12-10 15:42:02 [INFO] [tngsdk.project.project] Loading project 'misc/5gtango_ns_project_example1/project.yml'
2018-12-10 15:42:02 [WARNING] [tngsdk.project.project] Project version 0.5 is outdated. To translate to new 5GTANGO project version use --translate
2018-12-10 15:42:02 [WARNING] [tngsdk.project.project] Couldn't retrieve the projects UUID.
Traceback (most recent call last):
  File "/Users/manuel/tango/venv_tango_sdk/bin/tng-validate", line 11, in <module>
    load_entry_point('tngsdk.validate', 'console_scripts', 'tng-validate')()
  File "/Users/manuel/tango/tng-sdk-validation/src/tngsdk/validation/__init__.py", line 71, in main
    result_validator = cli.dispatch(args, validator)
  File "/Users/manuel/tango/tng-sdk-validation/src/tngsdk/validation/cli.py", line 118, in dispatch
    if not validator.validate_project(args.project_path):
  File "/Users/manuel/tango/tng-sdk-validation/src/tngsdk/validation/validator.py", line 300, in validate_project
    project = Project.load_project(project, workspace=self._workspace_path, translate=False)
  File "/Users/manuel/tango/tng-sdk-project/src/tngsdk/project/project.py", line 380, in load_project
    return Project(workspace, prj_root, config=prj_config)
  File "/Users/manuel/tango/tng-sdk-project/src/tngsdk/project/project.py", line 73, in __init__
    with open(workspace.config["projects_config"], 'r') as config_file:
AttributeError: 'str' object has no attribute 'config'
mpeuster commented 5 years ago

Ok, we can close this issue :-)