Skip to content

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::PipelineContext is 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_context object.

    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:

  1. A Plugin PipelineExecutionPolicy is registered in Ci::CreatePipelineService.
  2. The plugin component defines callback methods based on a supported list of callbacks.
  3. The logic in Ci::CreatePipelineService fires callbacks to registered plugins, passing data to each callback.
  4. 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:

  • PipelineExecutionPolicy plugin using PipelineExecutionPolicies::PipelineContext
  • ScanExecutionPolicy plugin using ScanExecutionPolicies::PipelineContext, using a "skip hook"

See also #514933 (closed).

Edited by 🤖 GitLab Bot 🤖