From 80f53ae35de8a12615ac60c2eb45a04cc4ecc2d9 Mon Sep 17 00:00:00 2001 From: Ina Panova Date: Mon, 9 May 2016 14:56:08 +0200 Subject: [PATCH 1/1] Name of the puppet module should be in format 'name-author'. Name of puppet module should correspond to the name specified in metadata.json --- docs/tech-reference/plugin_report.rst | 6 +++--- docs/tech-reference/type.rst | 4 ++-- docs/user-guide/quick-start.rst | 12 ++++++------ docs/user-guide/release-notes/2.8.x.rst | 14 ++++++++++++++ .../extensions/admin/consumer/content.py | 2 +- .../test/unit/test_consumer_content.py | 6 +++--- .../pulp_puppet/handlers/puppet.py | 4 ++-- .../test/unit/test_module_handler.py | 14 +++++++------- .../pulp_puppet/plugins/db/models.py | 22 ---------------------- .../pulp_puppet/plugins/importers/forge.py | 3 --- .../pulp_puppet/plugins/importers/upload.py | 3 --- 11 files changed, 38 insertions(+), 52 deletions(-) diff --git a/docs/tech-reference/plugin_report.rst b/docs/tech-reference/plugin_report.rst index db40944..ba84f47 100644 --- a/docs/tech-reference/plugin_report.rst +++ b/docs/tech-reference/plugin_report.rst @@ -14,7 +14,7 @@ The publish report's ``details`` value has the following format:: [ { "version": "3.2.0", - "name": "stdlib", + "name": "puppetlabs/stdlib", "author": "puppetlabs" }, "failed to download: not found" @@ -23,7 +23,7 @@ The publish report's ``details`` value has the following format:: "success_unit_keys": [ { "version": "4.1.0", - "name": "stdlib", + "name": "puppetlabs/stdlib", "author": "puppetlabs" } ] @@ -39,4 +39,4 @@ The ``details`` report object has two keys: ``success_unit_keys`` An array containing objects representing unit keys of modules that were - successfully published. \ No newline at end of file + successfully published. diff --git a/docs/tech-reference/type.rst b/docs/tech-reference/type.rst index 8bf9b35..2062911 100644 --- a/docs/tech-reference/type.rst +++ b/docs/tech-reference/type.rst @@ -15,8 +15,8 @@ Unit Key contributor "Puppet Labs" has the username "puppetlabs". ``name`` - Module's name only, not including the author section. For the module - identified as "puppetlabs/stdlib", this field would be "stdlib". + Module's name. For the module identified as "puppetlabs/stdlib", this field would be + "puppetlabs/stdlib" and it should correspond to name mentioned in the module's metadata. ``version`` Module's version, which according to Puppet Labs' documentation, should follow diff --git a/docs/user-guide/quick-start.rst b/docs/user-guide/quick-start.rst index 738e74d..fb96cc2 100644 --- a/docs/user-guide/quick-start.rst +++ b/docs/user-guide/quick-start.rst @@ -168,7 +168,7 @@ List Modules in a Repository :: $ pulp-admin puppet repo modules --repo-id=repo1 - Name: libvirt + Name: thias-libvirt Version: 0.0.1 Author: thias Dependencies: @@ -180,7 +180,7 @@ List Modules in a Repository Tag List: rhel, libvirt, kvm, CentOS Types: - Name: virt + Name: carlasouza-virt Version: 1.0.0 Author: carlasouza Dependencies: @@ -196,8 +196,8 @@ To be more specific, we can search by name. :: - $ pulp-admin puppet repo modules --repo-id=repo1 --str-eq='name=libvirt' - Name: libvirt + $ pulp-admin puppet repo modules --repo-id=repo1 --str-eq='name=thias-libvirt' + Name: thias-libvirt Version: 0.0.1 Author: thias Dependencies: @@ -214,7 +214,7 @@ Or by license, and for fun let's use a regex. :: $ pulp-admin puppet repo modules --repo-id=repo1 --match='license=^GPL.*' - Name: virt + Name: carlasouza-virt Version: 1.0.0 Author: carlasouza Dependencies: @@ -237,7 +237,7 @@ a result of the above sync. $ pulp-admin puppet repo create --repo-id=repo2 Successfully created repository [repo2] - $ pulp-admin puppet repo copy --from-repo-id=repo1 --to-repo-id=repo2 --str-eq='name=libvirt' + $ pulp-admin puppet repo copy --from-repo-id=repo1 --to-repo-id=repo2 --str-eq='name=thias-libvirt' Progress on this task can be viewed using the commands under "repo tasks". $ pulp-admin repo tasks list --repo-id=repo1 diff --git a/docs/user-guide/release-notes/2.8.x.rst b/docs/user-guide/release-notes/2.8.x.rst index ac57a54..63f99a9 100644 --- a/docs/user-guide/release-notes/2.8.x.rst +++ b/docs/user-guide/release-notes/2.8.x.rst @@ -2,6 +2,20 @@ Pulp Puppet 2.8 Release Notes ============================= +Pulp Puppet 2.8.4 +================= + +New Behaviours +-------------- + +From now on the name of the puppet module will correspond to the name specified in its metadata. + +Pulp Puppet 2.8.3 +================= + +Due to a Pulp platform release, this plugin's version has been incremented. +There are no changes from the previous release. + Pulp Puppet 2.8.2 ================= diff --git a/pulp_puppet_extensions_admin/pulp_puppet/extensions/admin/consumer/content.py b/pulp_puppet_extensions_admin/pulp_puppet/extensions/admin/consumer/content.py index 4e18053..3255314 100644 --- a/pulp_puppet_extensions_admin/pulp_puppet/extensions/admin/consumer/content.py +++ b/pulp_puppet_extensions_admin/pulp_puppet/extensions/admin/consumer/content.py @@ -33,7 +33,7 @@ def parse_units(units): parts = unit.split('/', 2) if len(parts) < 2: raise ValueError - unit_key = {'author': parts[0], 'name': parts[1]} + unit_key = {'name': "/".join((parts[0], parts[1])), 'author': parts[0]} if len(parts) == 3: unit_key['version'] = parts[2] ret.append({'type_id': constants.TYPE_PUPPET_MODULE, 'unit_key': unit_key}) diff --git a/pulp_puppet_extensions_admin/test/unit/test_consumer_content.py b/pulp_puppet_extensions_admin/test/unit/test_consumer_content.py index 7162ccc..8b060d6 100644 --- a/pulp_puppet_extensions_admin/test/unit/test_consumer_content.py +++ b/pulp_puppet_extensions_admin/test/unit/test_consumer_content.py @@ -33,7 +33,7 @@ class TestParseUnits(unittest.TestCase): self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE) unit_key = unit.get('unit_key', {}) self.assertEqual(unit_key.get('author'), 'foo') - self.assertEqual(unit_key.get('name'), 'bar') + self.assertEqual(unit_key.get('name'), 'foo/bar') self.assertTrue('version' not in unit_key) def test_single_unit_with_version(self): @@ -44,7 +44,7 @@ class TestParseUnits(unittest.TestCase): self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE) unit_key = unit.get('unit_key', {}) self.assertEqual(unit_key.get('author'), 'foo') - self.assertEqual(unit_key.get('name'), 'bar') + self.assertEqual(unit_key.get('name'), 'foo/bar') self.assertEqual(unit_key.get('version'), '1.2.3') def test_units(self): @@ -55,7 +55,7 @@ class TestParseUnits(unittest.TestCase): self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE) unit_key = unit.get('unit_key', {}) self.assertTrue(unit_key.get('author') in ['foo', 'abc']) - self.assertTrue(unit_key.get('name') in ['bar', 'xyz']) + self.assertTrue(unit_key.get('name') in ['foo/bar', 'abc/xyz']) self.assertTrue('version' not in unit_key) diff --git a/pulp_puppet_handlers/pulp_puppet/handlers/puppet.py b/pulp_puppet_handlers/pulp_puppet/handlers/puppet.py index 0acf27c..009ccf2 100644 --- a/pulp_puppet_handlers/pulp_puppet/handlers/puppet.py +++ b/pulp_puppet_handlers/pulp_puppet/handlers/puppet.py @@ -156,7 +156,7 @@ class ModuleHandler(handler.ContentHandler): # need this so we can easily access original unit objects when constructing # new requests below - units_by_full_name = dict(('%s/%s'% (u['author'], u['name']), u) for u in units) + units_by_full_name = dict(('%s'% (u['name']), u) for u in units) # loop over the results, and keep trying to uninstall failed attempts as # a dumb but effective way of dealing with dependency-related failures. @@ -235,7 +235,7 @@ class ModuleHandler(handler.ContentHandler): for unit in units: # prepare the command - full_name = '%s/%s' % (unit['author'], unit['name']) + full_name = unit['name'] args = ['puppet', 'module', operation, '--render-as', 'json'] if forge_url: args.extend(['--module_repository', forge_url]) diff --git a/pulp_puppet_handlers/test/unit/test_module_handler.py b/pulp_puppet_handlers/test/unit/test_module_handler.py index 122cf9e..48086b8 100644 --- a/pulp_puppet_handlers/test/unit/test_module_handler.py +++ b/pulp_puppet_handlers/test/unit/test_module_handler.py @@ -80,8 +80,8 @@ class TestGenerateForgeURL(ModuleHandlerTest): class TestInstall(ModuleHandlerTest): UNITS = [ - {'author': 'puppetlabs', 'name': 'stdlib', 'version': '3.1.1'}, - {'author': 'puppetlabs', 'name': 'java'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/stdlib', 'version': '3.1.1'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/java'}, ] POPEN_OUTPUT = [( @@ -189,7 +189,7 @@ notice: Installing -- do not interrupt ... class TestUpdate(ModuleHandlerTest): UNITS = [ - {'author': 'puppetlabs', 'name': 'stdlib'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/stdlib'}, ] POPEN_STDOUT = """notice: Preparing to upgrade 'puppetlabs-stdlib' ... @@ -287,8 +287,8 @@ notice: Upgrading -- do not interrupt ... class TestUninstall(ModuleHandlerTest): UNITS = [ - {'author': 'puppetlabs', 'name': 'stdlib'}, - {'author': 'puppetlabs', 'name': 'java'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/stdlib'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/java'}, ] # one failed attempt, then two successful attempts @@ -401,8 +401,8 @@ class TestUninstall(ModuleHandlerTest): class TestPerformOperation(ModuleHandlerTest): UNITS = [ - {'author': 'puppetlabs', 'name': 'stdlib', 'version': '3.1.1'}, - {'author': 'puppetlabs', 'name': 'java'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/stdlib', 'version': '3.1.1'}, + {'author': 'puppetlabs', 'name': 'puppetlabs/java'}, ] POPEN_OUTPUT = [( """notice: Preparing to install into /etc/puppet/modules ... diff --git a/pulp_puppet_plugins/pulp_puppet/plugins/db/models.py b/pulp_puppet_plugins/pulp_puppet/plugins/db/models.py index 674bcdc..df3de97 100644 --- a/pulp_puppet_plugins/pulp_puppet/plugins/db/models.py +++ b/pulp_puppet_plugins/pulp_puppet/plugins/db/models.py @@ -144,28 +144,6 @@ class Module(FileContentUnit): """ Backwards compatible with __repr__ from pulp.plugins.model.AssociatedUnit """ return str(self) - @staticmethod - def split_filename(filename): - """ - Splits a module's filename into two parts 'author' and 'name' and returns them as a dict. - - Split the filename of a module into into two parts and return it as a dict with the keys - 'author' and 'name'. The module filenamename is expected to be in the format 'author-name' - or 'author/name'. - - :param filename: The module's filename to be split into author and name. - :type filename: basestring - - :return: A dictionary with 'author' and 'name' containing the author and name respectively. - :rtype: A dict of strings. - """ - try: - author, name = filename.split("-", 1) - except ValueError: - # This is the forge format, but Puppet still allows it - author, name = filename.split("/", 1) - return {'author': author, 'name': name} - @classmethod def from_metadata(cls, metadata): """ diff --git a/pulp_puppet_plugins/pulp_puppet/plugins/importers/forge.py b/pulp_puppet_plugins/pulp_puppet/plugins/importers/forge.py index 6525c5a..963bfe7 100644 --- a/pulp_puppet_plugins/pulp_puppet/plugins/importers/forge.py +++ b/pulp_puppet_plugins/pulp_puppet/plugins/importers/forge.py @@ -294,9 +294,6 @@ class SynchronizeWithPuppetForge(object): metadata = metadata_module.extract_metadata(downloaded_filename, self.repo.working_dir) - # Overwrite the author and name - metadata.update(Module.split_filename(metadata['name'])) - # Create and save the Module module = Module.from_metadata(metadata) module.set_storage_path(os.path.basename(downloaded_filename)) diff --git a/pulp_puppet_plugins/pulp_puppet/plugins/importers/upload.py b/pulp_puppet_plugins/pulp_puppet/plugins/importers/upload.py index 04939db..3e63078 100644 --- a/pulp_puppet_plugins/pulp_puppet/plugins/importers/upload.py +++ b/pulp_puppet_plugins/pulp_puppet/plugins/importers/upload.py @@ -42,9 +42,6 @@ def handle_uploaded_unit(repo, type_id, unit_key, metadata, file_path, conduit): new_file_path = os.path.join(os.path.dirname(file_path), original_filename) shutil.move(file_path, new_file_path) - # Overwrite the author and name - extracted_data.update(Module.split_filename(extracted_data['name'])) - uploaded_module = Module.from_metadata(extracted_data) uploaded_module.set_storage_path(os.path.basename(new_file_path)) try: -- 2.1.0