Project

Profile

Help

Story #3935

Updated by bmbouter over 5 years ago

h2. Problem Statement 

 If a plugin needs to inject a custom stage, e.g. RPMs RelatedErrataModelSaver, it must carry lots of code that is already contained in DeclarativeVersion. This is doubly unfortunate because as DeclarativeVersion gets more feature over time, these other forked pipelines have to continue to duplicate those changes also. 

 h2. Solution 

 Create a method in DeclarativeVersion call pipeline_stages that provides Allow the artifact and content portions plugin writer to use DeclarativeVersion, but to also inject one or more stages into different parts of the pipeline (leaving out pipeline. Do this using a tuple like: 

 <pre> 
 ( 
     ContentUnitSaver,    # this is an actual instance of the associate/unassociate stages). model object pulpcore.plugin.stages.ContentUnitSaver 
     RelatedErrataModelSaver    # this is the stage I want DeclarativeVersion to inject. 
 ) 
 </pre> 

 Quoting from "@gmbnomis' comment":https://github.com/pulp/pulp/pull/3605#issuecomment-421075869 To specify this, the plugin writers have lots of options then: writer will use two new kwargs present on DeclarativeVersion's <code>__init__</code>: 

 * Scrap <code>inject_after</code> - Add a custom stage to the whole thing if it does not fit pipeline after the last instance of a stage type. 
 * Overwrite pipeline_stages() <code>inject_before</code> - Add a custom stage to instantiate stock or customized stages in any order 
 * Do "surgery" on the stages list by calling super().pipeline_stages() and modifying pipeline before the result (the idea first instance of this PR). a stage type. 

 Each will take a single tuple or an iterable of tuples, e.g. a list of tuples. 

 h3. Example 

 <pre> 
 * Use it as is DeclarativeVersion(inject_before=(ContentUnitSaver, RelatedErrataModelSaver)) 

 OR 

 DeclarativeVersion(inject_before=[(ContentUnitSaver, RelatedErrataModelSaver), (ArtifactDownloader, AnotherCustomStage)]) 
 </pre>

Back