Skip to content

Commit

Permalink
Remove manifest field from remotes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed May 14, 2019
1 parent 7572418 commit 8ab1815
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Create a repository ``foo``
Create a new remote ``bar``
---------------------------

``$ http POST http://localhost:8000/pulp/api/v3/remotes/file/ name='bar' url='https://repos.fedorapeople.org/pulp/pulp/demo_repos/test_file_repo/' manifest=PULP_MANIFEST``
``$ http POST http://localhost:8000/pulp/api/v3/remotes/file/ name='bar' url='https://repos.fedorapeople.org/pulp/pulp/demo_repos/test_file_repo/PULP_MANIFEST'``

.. code:: json
Expand Down Expand Up @@ -171,7 +171,7 @@ Add content to repository ``foo``
Create a ``file`` Publisher
---------------------------

``$ http POST http://localhost:8000/pulp/api/v3/publishers/file/ name=bar manifest=my_manifest.csv``
``$ http POST http://localhost:8000/pulp/api/v3/publishers/file/ name=bar``

.. code:: json
Expand Down
1 change: 0 additions & 1 deletion pulp_file/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class FileRemote(Remote):
"""

TYPE = 'file'
manifest = models.TextField(blank=True, null=True)


class FilePublisher(Publisher):
Expand Down
10 changes: 2 additions & 8 deletions pulp_file/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ class FileRemoteSerializer(RemoteSerializer):
Serializer for File Remotes.
"""

manifest = serializers.CharField(
help_text='Name of the file manifest, the full path will be url/manifest',
required=False,
default='manifest.csv'
)

class Meta:
fields = RemoteSerializer.Meta.fields + ('manifest',)
fields = RemoteSerializer.Meta.fields
model = FileRemote


Expand All @@ -55,7 +49,7 @@ class FilePublisherSerializer(PublisherSerializer):
manifest = serializers.CharField(
help_text='Name of the file manifest, the full path will be url/manifest',
required=False,
default='manifest.csv'
default='PULP_MANIFEST'
)

class Meta:
Expand Down
8 changes: 3 additions & 5 deletions pulp_file/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

from gettext import gettext as _
from urllib.parse import urlparse, urlunparse, urljoin
from urllib.parse import urlparse, urlunparse

from pulpcore.plugin.models import Artifact, ProgressBar, Repository
from pulpcore.plugin.stages import (
Expand Down Expand Up @@ -66,11 +66,9 @@ async def __call__(self, in_q, out_q):
"""
with ProgressBar(message='Downloading Metadata') as pb:
if self.remote.url[-1] != '/':
self.remote.url += '/'
parsed_url = urlparse(self.remote.url)
root_dir = parsed_url.path
downloader = self.remote.get_downloader(urljoin(self.remote.url, self.remote.manifest))
root_dir = os.path.dirname(parsed_url.path)
downloader = self.remote.get_downloader(self.remote.url)
result = await downloader.run()
pb.increment()

Expand Down
6 changes: 3 additions & 3 deletions pulp_file/tests/functional/api/test_crud_remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from pulp_smash.pulp3.utils import gen_repo

from pulp_file.tests.functional.constants import (
FILE_FIXTURE_URL,
FILE2_FIXTURE_URL,
FILE_FIXTURE_MANIFEST_URL,
FILE2_FIXTURE_MANIFEST_URL,
FILE_REMOTE_PATH
)
from pulp_file.tests.functional.utils import gen_file_remote, skip_if
Expand Down Expand Up @@ -137,7 +137,7 @@ def _gen_verbose_remote():
Note that 'username' and 'password' are write-only attributes.
"""
attrs = gen_file_remote(url=choice((FILE_FIXTURE_URL, FILE2_FIXTURE_URL)))
attrs = gen_file_remote(url=choice((FILE_FIXTURE_MANIFEST_URL, FILE2_FIXTURE_MANIFEST_URL)))
attrs.update({
'password': utils.uuid4(),
'username': utils.uuid4(),
Expand Down
12 changes: 9 additions & 3 deletions pulp_file/tests/functional/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# coding=utf-8
"""Constants for Pulp file plugin tests."""
from urllib.parse import urljoin

from pulp_smash.constants import PULP_FIXTURES_BASE_URL
Expand All @@ -15,21 +14,28 @@

FILE_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'file/')

FILE_MANIFEST = 'PULP_MANIFEST'
"""Default name of a file manifest."""

FILE_FIXTURE_URL = urljoin(PULP_FIXTURES_BASE_URL, 'file/')
"""The URL to a file repository."""

FILE_FIXTURE_MANIFEST_URL = urljoin(FILE_FIXTURE_URL, 'PULP_MANIFEST')
"""The URL to a file repository manifest."""

FILE_FIXTURE_COUNT = 3
"""The number of packages available at :data:`FILE_FIXTURE_URL`."""

FILE2_FIXTURE_URL = urljoin(PULP_FIXTURES_BASE_URL, 'file2/')
"""The URL to a file repository."""

FILE2_FIXTURE_MANIFEST_URL = urljoin(FILE2_FIXTURE_URL, 'PULP_MANIFEST')
"""The URL to a file repository manifest"""

FILE_LARGE_FIXTURE_URL = urljoin(PULP_FIXTURES_BASE_URL, 'file-large/')
"""The URL to a file repository containing a large number of files."""

FILE_LARGE_FIXTURE_MANIFEST_URL = urljoin(FILE_LARGE_FIXTURE_URL, 'PULP_MANIFEST')
"""The URL to a file repository manifest."""

FILE_URL = urljoin(FILE_FIXTURE_URL, '1.iso')
"""The URL to an ISO file at :data:`FILE_FIXTURE_URL`."""

Expand Down
17 changes: 6 additions & 11 deletions pulp_file/tests/functional/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

from pulp_file.tests.functional.constants import (
FILE_CONTENT_PATH,
FILE_FIXTURE_URL,
FILE_MANIFEST,
FILE_REMOTE_PATH,
FILE_FIXTURE_MANIFEST_URL,
FILE_REMOTE_PATH
)


Expand All @@ -34,7 +33,7 @@ def populate_pulp(cfg, url=None):
Pulp.
"""
if url is None:
url = FILE_FIXTURE_URL
url = FILE_FIXTURE_MANIFEST_URL

client = api.Client(cfg, api.json_handler)
remote = {}
Expand All @@ -51,19 +50,15 @@ def populate_pulp(cfg, url=None):
return client.get(FILE_CONTENT_PATH)['results']


def gen_file_remote(url=None, manifest=None, **kwargs):
def gen_file_remote(url=None, **kwargs):
"""Return a semi-random dict for use in creating a file Remote.
:param url: The URL of an external content source.
:param manifest: The name of a file manifest.
"""
if url is None:
url = FILE_FIXTURE_URL
url = FILE_FIXTURE_MANIFEST_URL

if manifest is None:
manifest = FILE_MANIFEST

return gen_remote(url, manifest=manifest, **kwargs)
return gen_remote(url, **kwargs)


def gen_file_publisher(**kwargs):
Expand Down

0 comments on commit 8ab1815

Please sign in to comment.