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

Add docker content models. #260

Merged
merged 1 commit into from
Sep 17, 2018
Merged

Add docker content models. #260

merged 1 commit into from
Sep 17, 2018

Conversation

jortel
Copy link
Contributor

@jortel jortel commented Sep 10, 2018

https://pulp.plan.io/issues/3401

I'm not convinced we want to use choice= for media_type fields but did at the direction of the story.

@jortel jortel added the 3.0 label Sep 10, 2018
@pep8speaks
Copy link

pep8speaks commented Sep 10, 2018

Hello @jortel! Thanks for updating the PR.

Comment last updated on September 10, 2018 at 20:38 Hours UTC

Copy link
Contributor

@asmacdo asmacdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes and questions. Happy to rereview tomorrow.

This content has no artifacts.

Fields:
digest (models.CharField): The manifest digest.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more helpful: The SHA256 (is that what this is?) if the manifest file

Copy link
Member

@ipanova ipanova Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of now the sha256 is used, i would like to leave this opened in case some other algorithms will come in place later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, how about "The digest of the manifest file."

"""
A blob defined within a manifest.

This content has no artifacts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ManifestList actually does have a file on disk. I think maybe this docbloc is an accidental copy/paste?

media_type = models.CharField(
max_length=60,
choices=(
(MEDIA_TYPE.MANIFEST_LIST, MEDIA_TYPE.MANIFEST_LIST),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 choices are the same. I think there is only one choice, maybe this one doesn't need to be a choice field.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true that there is just 1 choice - for now ( you never know what will come next)

  • the value of this field will be validated at the db level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that this is (visible choice, internal choice), so this is just 1 choice. It seems reasonable to expect docker to add more choices in the future so this is fine.

manifest_list = models.ForeignKey(
ManifestList, null=True, related_name='tags', on_delete=models.CASCADE)

class Meta:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonblocking question: Is there a way to enforce that a specific tag cannot reference both a manifest and a manifest list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkliban, do you know of a way that is compatible with bulk_create()?

(MEDIA_TYPE.CONFIG_BLOB, MEDIA_TYPE.CONFIG_BLOB),
(MEDIA_TYPE.REGULAR_BLOB, MEDIA_TYPE.REGULAR_BLOB),
(MEDIA_TYPE.FOREIGN_BLOB, MEDIA_TYPE.FOREIGN_BLOB),
))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also reference an artifact? If so, it seems reasonable to leave out for now and add when there are actual units with artifacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The artifact relationship is already supported generically by ContentArtifact.


class ManifestList(Content):
"""
A blob defined within a manifest.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely copy/paste

TYPE = 'manifest-blob'

digest = models.CharField(max_length=255)
media_type = models.CharField(
Copy link
Member

@ipanova ipanova Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmacdo when you will be implementing sync, at the parsing of the manifest.json: if the information for the mediatype of the blob will be available, then use that info, otherwise set the value to MEDIA_TYPE.REGULAR_BLOB
** for the background, in schema1 there is no information available for blobs, just its digest. But also schema 1 can cope only with application/vnd.docker.image.rootfs.diff.tar.gzip mediatype

"""
A docker manifest.

This content has no artifacts.
Copy link
Member

@ipanova ipanova Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This content should have artifact --> manifest.json
manifest.json is the file we fetch and parse, and based on what we parsed we put this info onto the model and save, including the json file.

Same for ManifestList.

Copy link
Contributor

@asmacdo asmacdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, thanks @jortel!

@asmacdo
Copy link
Contributor

asmacdo commented Sep 14, 2018

@jortel, before you merge, the CI failure looks important:
"pulp_docker.ManifestBlob.manifest: (models.E006) The field 'manifest' clashes with the field 'manifest' from model 'pulp_app.content'."

Think we ought to have all of the plugins namespace their tables?

@jortel
Copy link
Contributor Author

jortel commented Sep 14, 2018

@asmacdo, The tables are already namespaced by django. The docker plugin tables are namespaced under the 'app' name. For example: the Manifest model results in table named: pulp_docker_manifest. The model class are naturally namespaced by python packages. This error (as reported) makes no sense to me but I'll dig into it before merging.

@jortel jortel merged commit d4e57d1 into pulp:master Sep 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants