Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Renaming base fields #424

Merged
merged 4 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/5454.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change `_type` to `pulp_type`
1 change: 1 addition & 0 deletions CHANGES/5457.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change `_id`, `_created`, `_last_updated`, `_href` to `pulp_id`, `pulp_created`, `pulp_last_updated`, `pulp_href`
1 change: 1 addition & 0 deletions CHANGES/5550.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removing base field: `_type` .
2 changes: 1 addition & 1 deletion docs/_scripts/destination_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export DEST_REPO_NAME=$(head /dev/urandom | tr -dc a-z | head -c5)

echo "Create a second repository so we can add content to it."
export DEST_REPO_HREF=$(http POST $BASE_ADDR/pulp/api/v3/repositories/ name=$DEST_REPO_NAME \
| jq -r '._href')
| jq -r '.pulp_href')

echo "Inspect repository."
http $BASE_ADDR$DEST_REPO_HREF
2 changes: 1 addition & 1 deletion docs/_scripts/download_after_sync.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

DOCKER_TAG='latest'
DOCKER_TAG='manifest_a'

echo "Setting REGISTRY_PATH, which can be used directly with the Docker Client."
export REGISTRY_PATH=$(http $BASE_ADDR$DISTRIBUTION_HREF | jq -r '.registry_path')
Expand Down
2 changes: 1 addition & 1 deletion docs/_scripts/image_tagging.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

export TAG_NAME='custom_tag'
export MANIFEST_DIGEST='sha256:b8ba256769a0ac28dd126d584e0a2011cd2877f3f76e093a7ae560f2a5301c00'
export MANIFEST_DIGEST='sha256:21e3caae28758329318c8a868a80daa37ad8851705155fc28767852c73d36af5'

echo "Tagging the manifest."
export TASK_URL=$(http POST $BASE_ADDR'/pulp/api/v3/docker/tag/' \
Expand Down
4 changes: 2 additions & 2 deletions docs/_scripts/recursive_add_tag.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

echo "Retrieve the href of Tag latest in the synced repository."
export TAG_HREF=$(http $BASE_ADDR'/pulp/api/v3/content/docker/tags/?repository_version='$REPOVERSION_HREF'&name=latest' \
| jq -r '.results | first | ._href')
export TAG_HREF=$(http $BASE_ADDR'/pulp/api/v3/content/docker/tags/?repository_version='$REPOVERSION_HREF'&name=manifest_a' \
| jq -r '.results | first | .pulp_href')

echo "Create a task to recursively add a tag to the repo."
export TASK_HREF=$(http POST $BASE_ADDR'/pulp/api/v3/docker/recursive-add/' \
Expand Down
4 changes: 2 additions & 2 deletions docs/_scripts/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ echo "Creating a remote that points to an external source of container images."
http POST $BASE_ADDR/pulp/api/v3/remotes/docker/docker/ \
name='my-hello-repo' \
url='https://registry-1.docker.io' \
upstream_name='library/hello-world'
upstream_name='pulp/test-fixture-1'

echo "Export an environment variable for the new remote URI."
export REMOTE_HREF=$(http $BASE_ADDR/pulp/api/v3/remotes/docker/docker/ \
| jq -r '.results[] | select(.name == "my-hello-repo") | ._href')
| jq -r '.results[] | select(.name == "my-hello-repo") | .pulp_href')

echo "Inspecting new Remote."
http $BASE_ADDR$REMOTE_HREF
2 changes: 1 addition & 1 deletion docs/_scripts/repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export REPO_NAME=$(head /dev/urandom | tr -dc a-z | head -c5)

echo "Creating a new repository named $REPO_NAME."
export REPO_HREF=$(http POST $BASE_ADDR/pulp/api/v3/repositories/ name=$REPO_NAME \
| jq -r '._href')
| jq -r '.pulp_href')

echo "Inspecting repository."
http $BASE_ADDR$REPO_HREF
2 changes: 1 addition & 1 deletion docs/_scripts/tag_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Create a task to copy a tag to the repo."
export TASK_HREF=$(http POST $BASE_ADDR'/pulp/api/v3/docker/tags/copy/' \
source_repository=$REPO_HREF \
destination_repository=$DEST_REPO_HREF \
names:="[\"latest\"]" \
names:="[\"manifest_a\"]" \
| jq -r '.task')

# Poll the task (here we use a function defined in docs/_scripts/base.sh)
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/api.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/workflows/host.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _host:

Host and Consume a Docker Repository
Host and Consume a Docker Repository
====================================

This section assumes that you have a repository with content in it. To do this, see the
Expand All @@ -11,7 +11,7 @@ Create a Docker Distribution to serve your Repository Version

Docker Distributions can be used to serve the Docker registry API
containing the content in a repository's latest version or a specified
repository version.
repository version.

.. literalinclude:: ../_scripts/distribution.sh
:language: bash
Expand All @@ -21,8 +21,8 @@ Response:
.. code::

{
"_created": "2019-09-05T14:29:51.742086Z",
"_href": "/pulp/api/v3/distributions/docker/docker/1b461dac-0839-4049-aa8f-92f8e8f7f034/",
"pulp_created": "2019-09-05T14:29:51.742086Z",
"pulp_href": "/pulp/api/v3/distributions/docker/docker/1b461dac-0839-4049-aa8f-92f8e8f7f034/",
"base_path": "test",
"content_guard": null,
"name": "testing-hello",
Expand Down Expand Up @@ -73,7 +73,7 @@ https://docs.docker.com/registry/insecure/#deploy-a-plain-http-registry

.. literalinclude:: ../_scripts/download_after_sync.sh
:language: bash

Docker Output::

Unable to find image 'localhost:24816/test:latest' locally
Expand All @@ -82,10 +82,10 @@ Docker Output::
1b930d010525: Pull complete
Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd
Status: Downloaded newer image for localhost:24816/test:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
Expand All @@ -94,13 +94,13 @@ Docker Output::
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

Expand Down
18 changes: 9 additions & 9 deletions docs/workflows/manage-content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Relations:
(non-recursively).

Begin by following the :ref:`Synchronize <sync-workflow>` workflow to
start with a repository that has some content in it.
start with a repository that has some content in it.

Next create a new repository that we can add content to.

Expand All @@ -114,8 +114,8 @@ tag to function correctly when pulled by a client.
New Repository Version::

{
"_created": "2019-09-05T19:04:06.152589Z",
"_href": "/pulp/api/v3/repositories/ce642635-dd9b-423f-82c4-86a150b9f5fe/versions/10/",
"pulp_created": "2019-09-05T19:04:06.152589Z",
"pulp_href": "/pulp/api/v3/repositories/ce642635-dd9b-423f-82c4-86a150b9f5fe/versions/10/",
"base_version": null,
"content_summary": {
"added": {
Expand Down Expand Up @@ -192,8 +192,8 @@ been removed, resulting in an empty repository.
New Repository Version::

{
"_created": "2019-09-10T13:25:44.078017Z",
"_href": "/pulp/api/v3/repositories/c2f67416-7200-4dcc-9868-f320431aae20/versions/2/",
"pulp_created": "2019-09-10T13:25:44.078017Z",
"pulp_href": "/pulp/api/v3/repositories/c2f67416-7200-4dcc-9868-f320431aae20/versions/2/",
"base_version": null,
"content_summary": {
"added": {},
Expand Down Expand Up @@ -249,8 +249,8 @@ name.
New Repository Version::

{
"_created": "2019-09-10T13:42:12.572859Z",
"_href": "/pulp/api/v3/repositories/2b1c6d76-c369-4f31-8eb8-9d5d92bb2346/versions/1/",
"pulp_created": "2019-09-10T13:42:12.572859Z",
"pulp_href": "/pulp/api/v3/repositories/2b1c6d76-c369-4f31-8eb8-9d5d92bb2346/versions/1/",
"base_version": null,
"content_summary": {
"added": {
Expand Down Expand Up @@ -309,8 +309,8 @@ to copy only manifest lists, for example.
New Repository Version::

{
"_created": "2019-09-20T13:53:04.907351Z",
"_href": "/pulp/api/v3/repositories/70450dfb-ae46-4061-84e3-97eb71cf9414/versions/2/",
"pulp_created": "2019-09-20T13:53:04.907351Z",
"pulp_href": "/pulp/api/v3/repositories/70450dfb-ae46-4061-84e3-97eb71cf9414/versions/2/",
"base_version": null,
"content_summary": {
"added": {
Expand Down
15 changes: 7 additions & 8 deletions docs/workflows/sync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Create a Repository
Repository GET Response::

{
"_created": "2019-09-05T14:29:43.424822Z",
"_href": "/pulp/api/v3/repositories/fcf03266-f0e4-4497-8434-0fe9d94c8053/",
"pulp_created": "2019-09-05T14:29:43.424822Z",
"pulp_href": "/pulp/api/v3/repositories/fcf03266-f0e4-4497-8434-0fe9d94c8053/",
"_latest_version_href": null,
"_versions_href": "/pulp/api/v3/repositories/fcf03266-f0e4-4497-8434-0fe9d94c8053/versions/",
"description": null,
Expand All @@ -41,10 +41,9 @@ including `quay`, `google container registry`, or even another instance of Pulp.
Remote GET Response::

{
"_created": "2019-09-05T14:29:44.267406Z",
"_href": "/pulp/api/v3/remotes/docker/docker/1cc699b7-24fd-4944-bde7-86aed8ac12fa/",
"_last_updated": "2019-09-05T14:29:44.267428Z",
"_type": "docker.docker",
"pulp_created": "2019-09-05T14:29:44.267406Z",
"pulp_href": "/pulp/api/v3/remotes/docker/docker/1cc699b7-24fd-4944-bde7-86aed8ac12fa/",
"pulp_last_updated": "2019-09-05T14:29:44.267428Z",
"download_concurrency": 20,
"name": "my-hello-repo",
"policy": "immediate",
Expand Down Expand Up @@ -80,8 +79,8 @@ Repository Version GET Response (when complete):
.. code:: json

{
"_created": "2019-09-05T14:29:45.563089Z",
"_href": "/pulp/api/v3/repositories/fcf03266-f0e4-4497-8434-0fe9d94c8053/versions/1/",
"pulp_created": "2019-09-05T14:29:45.563089Z",
"pulp_href": "/pulp/api/v3/repositories/fcf03266-f0e4-4497-8434-0fe9d94c8053/versions/1/",
"base_version": null,
"content_summary": {
"added": {
Expand Down
2 changes: 1 addition & 1 deletion pulp_docker/app/tasks/recursive_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def recursive_add_content(repository_pk, content_units):
latest_version = RepositoryVersion.latest(repository)
if latest_version:
tags_in_repo = latest_version.content.filter(
_type="docker.tag"
pulp_type="docker.tag"
)
tags_to_replace = Tag.objects.filter(
pk__in=tags_in_repo,
Expand Down
6 changes: 3 additions & 3 deletions pulp_docker/app/tasks/recursive_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def recursive_remove_content(repository_pk, content_units):
latest_version = RepositoryVersion.latest(repository)
latest_content = latest_version.content.all() if latest_version else Content.objects.none()

tags_in_repo = Q(pk__in=latest_content.filter(_type='docker.tag'))
manifests_in_repo = Q(pk__in=latest_content.filter(_type='docker.manifest'))
tags_in_repo = Q(pk__in=latest_content.filter(pulp_type='docker.tag'))
manifests_in_repo = Q(pk__in=latest_content.filter(pulp_type='docker.manifest'))
user_provided_content = Q(pk__in=content_units)
type_manifest_list = Q(media_type=MEDIA_TYPE.MANIFEST_LIST)
type_manifest = Q(media_type__in=[MEDIA_TYPE.MANIFEST_V1, MEDIA_TYPE.MANIFEST_V2])
blobs_in_repo = Q(pk__in=latest_content.filter(_type='docker.blob'))
blobs_in_repo = Q(pk__in=latest_content.filter(pulp_type='docker.blob'))

# Tags do not have must_remain because they are the highest level content.
tags_to_remove = Tag.objects.filter(user_provided_content & tags_in_repo)
Expand Down
2 changes: 1 addition & 1 deletion pulp_docker/app/tasks/untag.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def untag_image(tag, repository_pk):
latest_version = RepositoryVersion.latest(repository)

tags_in_latest_repository = latest_version.content.filter(
_type="docker.tag"
pulp_type="docker.tag"
)

tags_to_remove = Tag.objects.filter(
Expand Down
4 changes: 2 additions & 2 deletions pulp_docker/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def create(self, request):
source_latest = serializer.validated_data['source_repository_version']
destination = serializer.validated_data['destination_repository']
content_tags_in_repo = source_latest.content.filter(
_type="docker.tag"
pulp_type="docker.tag"
)
tags_in_repo = models.Tag.objects.filter(
pk__in=content_tags_in_repo,
Expand Down Expand Up @@ -335,7 +335,7 @@ def create(self, request):
source_latest = serializer.validated_data['source_repository_version']
destination = serializer.validated_data['destination_repository']
content_manifests_in_repo = source_latest.content.filter(
_type="docker.manifest"
pulp_type="docker.manifest"
)
manifests_in_repo = models.Manifest.objects.filter(
pk__in=content_manifests_in_repo,
Expand Down
8 changes: 4 additions & 4 deletions pulp_docker/tests/functional/api/test_crud_content_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_01_create_content_unit(self):
@skip_if(bool, 'content_unit', False)
def test_02_read_content_unit(self):
"""Read a content unit by its href."""
content_unit = self.client.get(self.content_unit['_href'])
content_unit = self.client.get(self.content_unit['pulp_href'])
for key, val in self.content_unit.items():
with self.subTest(key=key):
self.assertEqual(content_unit[key], val)
Expand All @@ -80,7 +80,7 @@ def test_03_partially_update(self):
"""
attrs = gen_docker_image_attrs(self.artifact)
with self.assertRaises(HTTPError) as exc:
self.client.patch(self.content_unit['_href'], attrs)
self.client.patch(self.content_unit['pulp_href'], attrs)
self.assertEqual(exc.exception.response.status_code, 405)

@skip_if(bool, 'content_unit', False)
Expand All @@ -91,7 +91,7 @@ def test_03_fully_update(self):
"""
attrs = gen_docker_image_attrs(self.artifact)
with self.assertRaises(HTTPError) as exc:
self.client.put(self.content_unit['_href'], attrs)
self.client.put(self.content_unit['pulp_href'], attrs)
self.assertEqual(exc.exception.response.status_code, 405)

@skip_if(bool, 'content_unit', False)
Expand All @@ -101,5 +101,5 @@ def test_04_delete(self):
This HTTP method is not supported and a HTTP exception is expected.
"""
with self.assertRaises(HTTPError) as exc:
self.client.delete(self.content_unit['_href'])
self.client.delete(self.content_unit['pulp_href'])
self.assertEqual(exc.exception.response.status_code, 405)
26 changes: 13 additions & 13 deletions pulp_docker/tests/functional/api/test_crud_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_02_create_same_name(self):

@skip_if(bool, 'distribution', False)
def test_02_read_distribution(self):
"""Read a distribution by its _href."""
distribution = self.client.get(self.distribution['_href'])
"""Read a distribution by its pulp_href."""
distribution = self.client.get(self.distribution['pulp_href'])
for key, val in self.distribution.items():
with self.subTest(key=key):
self.assertEqual(distribution[key], val)
Expand All @@ -65,10 +65,10 @@ def test_02_read_distribution_with_specific_fields(self):
raise unittest.SkipTest('Issue 4599 is not resolved')
fields = ('base_path', 'name')
for field_pair in permutations(fields, 2):
# ex: field_pair = ('_href', 'base_url)
# ex: field_pair = ('pulp_href', 'base_url)
with self.subTest(field_pair=field_pair):
distribution = self.client.get(
self.distribution['_href'],
self.distribution['pulp_href'],
params={'fields': ','.join(field_pair)}
)
self.assertEqual(
Expand All @@ -82,7 +82,7 @@ def test_02_read_distribution_without_specific_fields(self):
raise unittest.SkipTest('Issue 4599 is not resolved')
# requests doesn't allow the use of != in parameters.
url = '{}?exclude_fields=base_path,name'.format(
self.distribution['_href']
self.distribution['pulp_href']
)
distribution = self.client.get(url)
response_fields = distribution.keys()
Expand Down Expand Up @@ -111,8 +111,8 @@ def test_02_read_distributions(self):
def test_03_partially_update(self):
"""Update a distribution using HTTP PATCH."""
body = gen_distribution()
self.client.patch(self.distribution['_href'], body)
type(self).distribution = self.client.get(self.distribution['_href'])
self.client.patch(self.distribution['pulp_href'], body)
type(self).distribution = self.client.get(self.distribution['pulp_href'])
for key, val in body.items():
with self.subTest(key=key):
self.assertEqual(self.distribution[key], val)
Expand All @@ -121,18 +121,18 @@ def test_03_partially_update(self):
def test_04_fully_update(self):
"""Update a distribution using HTTP PUT."""
body = gen_distribution()
self.client.put(self.distribution['_href'], body)
type(self).distribution = self.client.get(self.distribution['_href'])
self.client.put(self.distribution['pulp_href'], body)
type(self).distribution = self.client.get(self.distribution['pulp_href'])
for key, val in body.items():
with self.subTest(key=key):
self.assertEqual(self.distribution[key], val)

@skip_if(bool, 'distribution', False)
def test_05_delete(self):
"""Delete a distribution."""
self.client.delete(self.distribution['_href'])
self.client.delete(self.distribution['pulp_href'])
with self.assertRaises(HTTPError):
self.client.get(self.distribution['_href'])
self.client.get(self.distribution['pulp_href'])

def test_negative_create_distribution_with_invalid_parameter(self):
"""Attempt to create distribution passing invalid parameter.
Expand Down Expand Up @@ -172,7 +172,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
"""Clean up resources."""
cls.client.delete(cls.distribution['_href'])
cls.client.delete(cls.distribution['pulp_href'])

def test_spaces(self):
"""Test that spaces can not be part of ``base_path``."""
Expand Down Expand Up @@ -209,4 +209,4 @@ def try_update_distribution(self, **kwargs):
Use the given kwargs as the body of the request.
"""
with self.assertRaises(HTTPError):
self.client.patch(self.distribution['_href'], kwargs)
self.client.patch(self.distribution['pulp_href'], kwargs)
Loading