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
Updated by bmbouter almost 6 years ago
+1 this looks like exactly what we talked about. Thanks so much for writing this up.
Updated by dalley almost 6 years ago
Pulpcore: https://github.com/pulp/pulp/pull/3846
Pulp file: https://github.com/pulp/pulp_file/pull/159
Updated by dalley almost 6 years ago
- Is duplicate of Task #4282: Rename 'artifact' to '_artifact' added
Updated by dalley almost 6 years ago
Pulp Smash PR https://github.com/PulpQE/pulp-smash/pull/1164 (by Pavel)
Pulpcore plugin PR https://github.com/pulp/pulpcore-plugin/pull/38
Added by dalley almost 6 years ago
Added by dalley almost 6 years ago
Revision 8c793f8a | View on GitHub
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
Added by dalley almost 6 years ago
Revision c9d4c734 | View on GitHub
Remove _artifact vs. _artifacts boilerplate
Required PR: https://github.com/pulp/pulp/pull/3846 Required PR: https://github.com/PulpQE/pulp-smash/pull/1164 Required PR: https://github.com/pulp/pulpcore-plugin/pull/38
closes: #4340 https://pulp.plan.io/issues/4340 re: #4366 https://pulp.plan.io/issues/4366
Updated by dalley almost 6 years ago
Updated by dalley almost 6 years ago
Added by dalley almost 6 years ago
Revision d503518d | View on GitHub
Use new specialized serializers
Added by dalley almost 6 years ago
Revision 4376e5c8 | View on GitHub
Update to use specialized serializers
Updated by dalley almost 6 years ago
- Status changed from POST to MODIFIED
Added by dalley almost 6 years ago
Revision 3b05da47 | View on GitHub
Use new specialized serializers
Updated by bmbouter about 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
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