You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/05/08 18:18:52 UTC

incubator-ariatosca git commit: ARIA-210 Handle relative paths in CLI service-templates

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-210-handle-relative-paths-in-cli-service-templates [created] 0a3ea7991


ARIA-210 Handle relative paths in CLI service-templates

This was a rather simple change, mainly involving adding absolute path
references.

The problems were only in `service-templates store` and in
`service-templates create-archive`.
`service-templates validate` was not affected.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/0a3ea799
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/0a3ea799
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/0a3ea799

Branch: refs/heads/ARIA-210-handle-relative-paths-in-cli-service-templates
Commit: 0a3ea7991d6218438318d93232f82e7d7d42d4ae
Parents: 0ec2370
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Mon May 8 17:45:23 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Mon May 8 17:45:23 2017 +0300

----------------------------------------------------------------------
 aria/cli/commands/service_templates.py |  4 +++-
 aria/cli/csar.py                       | 14 ++++++++------
 aria/cli/service_template_utils.py     |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py
index 2537012..460d6cb 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -195,7 +195,9 @@ def create_archive(service_template_path, destination, logger):
     `destination` is the path of the output CSAR archive file
     """
     logger.info('Creating a CSAR archive')
-    csar.write(os.path.dirname(service_template_path), service_template_path, destination, logger)
+    if not destination.endswith('.csar'):
+        destination += '.csar'
+    csar.write(service_template_path, destination, logger)
     logger.info('CSAR archive created at {0}'.format(destination))
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/csar.py
----------------------------------------------------------------------
diff --git a/aria/cli/csar.py b/aria/cli/csar.py
index 5bc35ac..f1608cd 100644
--- a/aria/cli/csar.py
+++ b/aria/cli/csar.py
@@ -38,17 +38,19 @@ BASE_METADATA = {
 }
 
 
-def write(source, entry, destination, logger):
-    source = os.path.expanduser(source)
-    destination = os.path.expanduser(destination)
-    entry_definitions = os.path.join(source, entry)
+def write(service_template_path, destination, logger):
+
+    service_template_path = os.path.abspath(os.path.expanduser(service_template_path))
+    source = os.path.dirname(service_template_path)
+    entry = os.path.basename(service_template_path)
+
     meta_file = os.path.join(source, META_FILE)
     if not os.path.isdir(source):
         raise ValueError('{0} is not a directory. Please specify the service template '
                          'directory.'.format(source))
-    if not os.path.isfile(entry_definitions):
+    if not os.path.isfile(service_template_path):
         raise ValueError('{0} does not exists. Please specify a valid entry point.'
-                         .format(entry_definitions))
+                         .format(service_template_path))
     if os.path.exists(destination):
         raise ValueError('{0} already exists. Please provide a path to where the CSAR should be '
                          'created.'.format(destination))

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a3ea799/aria/cli/service_template_utils.py
----------------------------------------------------------------------
diff --git a/aria/cli/service_template_utils.py b/aria/cli/service_template_utils.py
index 382cce1..c953c02 100644
--- a/aria/cli/service_template_utils.py
+++ b/aria/cli/service_template_utils.py
@@ -53,7 +53,7 @@ def get(source, service_template_filename):
             return _get_service_template_file_from_archive(source, service_template_filename)
         else:
             # Maybe check if yaml.
-            return source
+            return os.path.abspath(source)
     elif len(source.split('/')) == 2:
         url = _map_to_github_url(source)
         downloaded_file = utils.download_file(url)