Story #4366
closedAs a plugin writer, I have special purpose Content Serializers for content types that have 0, 1, or many artifacts per content
0%
Description
The "_artifacts" field is rather difficult to use from a user perspective, and is also over-generalized. Nearly all currently existing Pulp 3 plugins have a single have a single artifact per content unit, and carry around boilerplate code to replace the "_artifacts" (plural) serializer field with a singular version, in order to avoid the usability issues that comes with it.
This boilerplate is not ideal, and errors found in it (such as [0] )must be made against many, many plugins.
There are also additional common invariants, such as Content without any Artifacts, which should be handled in a more explicit way without any plugin writer boilerplate.
To fix this, we propose the following changes to the plugin API:
- The current "ContentSerializer" will be renamed to MultiArtifactContentSerializer
- A new "SingleArtifactContentSerializer" will be defined, which has an "_artifact" field, which lists a single artifact
- A new "NoArtifactContentSerializer" will be defined, which lacks any field related to Artifacts
Plugin writers will inherit their own content serializers from the one most closely matching their needs.
The one used in plugin_template by default will be the SingleArtifactContentSerializer, with a FIXME instruction added.
This should also be documented in the plugin writer docs.
Related issues
Add custom serializers for "_artifact" vs "_artifacts"
Remove boilerplate from the plugins by defining new, more specialized serializers for the single-artifact-per-content case, the multiple-artifacts-per-content case, and the no-artifacts-per-content case.
Required PR: https://github.com/pulp/pulp_file/pull/159 Required PR: https://github.com/PulpQE/pulp-smash/pull/1164 Required PR: https://github.com/pulp/pulpcore-plugin/pull/38
re: #4366 https://pulp.plan.io/issues/4366