Remove delegations from ExecutionPolicies::PipelineContext
The following discussion from !178199 (merged) should be addressed:
-
@fabiopitino started a discussion: (+2 comments) All these delegations make it seem we can actually merge this class with
Gitlab::Ci::Pipeline::PipelineExecutionPolicies::PipelineContext. It's very hard to distinguish nowadays the 2 classes and responsibilities. The class::Gitlab::Ci::Pipeline::PipelineExecutionPolicies::PipelineContextis only used inside this class, and could make most of the methods in the latter class private.I think one of the class existed before we started to move most of the logic into
pipeline_execution_contextobject.Can we address this tech debt in a follow-up MR?
We call the generic ExecutionPolicies::PipelineContext from the Skip chain. Either PEP or SEP can prevent the pipeline from being skipped here.
The delegations were introduced as a middle step, but the overall idea was to call pipeline_policy_context.pipeline_execution_context whenever we interact with pipeline execution policies and remove the delegations.
Additional context
We should aim towards a plugin architecture in the Ci::CreatePipelineService described here:
- A Plugin
PipelineExecutionPolicyis registered inCi::CreatePipelineService. - The plugin component defines callback methods based on a supported list of callbacks.
- The logic in
Ci::CreatePipelineServicefires callbacks to registered plugins, passing data to each callback. - The plugin can modify the pipeline data structure along the way.
If we have that in place, we could eventually remove this "glue-context" ExecutionPolicies::PipelineContext and register two plugins:
-
PipelineExecutionPolicyplugin usingPipelineExecutionPolicies::PipelineContext -
ScanExecutionPolicyplugin usingScanExecutionPolicies::PipelineContext, using a "skip hook"
See also #514933 (closed).