Class: Gitlab::Ci::Config::EdgeStagesInjector

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/config/edge_stages_injector.rb

Constant Summary collapse

PRE_PIPELINE =
'.pre'
POST_PIPELINE =
'.post'
EDGES =
[PRE_PIPELINE, POST_PIPELINE].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ EdgeStagesInjector

Returns a new instance of EdgeStagesInjector.



19
20
21
# File 'lib/gitlab/ci/config/edge_stages_injector.rb', line 19

def initialize(config)
  @config = config.to_h.deep_dup
end

Class Method Details

.wrap_stages(stages) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/gitlab/ci/config/edge_stages_injector.rb', line 11

def self.wrap_stages(stages)
  stages = stages.to_a - EDGES
  stages.unshift PRE_PIPELINE
  stages.push POST_PIPELINE

  stages
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/ci/config/edge_stages_injector.rb', line 23

def to_hash
  if config.key?(:stages)
    process(:stages)
  elsif config.key?(:types)
    process(:types)
  else
    config
  end
end