Commit c1b8f3a2 authored by Matija Čupić's avatar Matija Čupić

Pass class as parameter to Simplifiable

parent ec3b5087
......@@ -9,7 +9,7 @@ module EE
extend ActiveSupport::Concern
prepended do
strategy :Bridge, if: -> (config) { config.is_a?(Hash) }
strategy :Bridge, class: EE::Gitlab::Ci::Config::Entry::Need::Bridge, if: -> (config) { config.is_a?(Hash) }
end
class Bridge < ::Gitlab::Config::Entry::Node
......
......@@ -4,7 +4,7 @@ module Gitlab
module Config
module Entry
class Simplifiable < SimpleDelegator
EntryStrategy = Struct.new(:name, :condition)
EntryStrategy = Struct.new(:name, :klass, :condition)
attr_reader :subject
......@@ -25,7 +25,7 @@ module Gitlab
end
def self.strategy(name, **opts)
EntryStrategy.new(name, opts.fetch(:if)).tap do |strategy|
EntryStrategy.new(name, opts.dig(:class), opts.fetch(:if)).tap do |strategy|
strategies.append(strategy)
end
end
......@@ -36,7 +36,7 @@ module Gitlab
def self.entry_class(strategy)
if strategy.present?
self.const_get(strategy.name, false)
strategy.klass || self.const_get(strategy.name, false)
else
self::UnknownStrategy
end
......
......@@ -1342,7 +1342,7 @@ module Gitlab
expect(subject.builds.size).to eq(2)
expect(subject.builds[0]).to eq(
stage: "build",
stage_idx: 0,
stage_idx: 1,
name: "build",
options: {
script: ["test"]
......@@ -1353,7 +1353,7 @@ module Gitlab
)
expect(subject.builds[1]).to eq(
stage: "test",
stage_idx: 1,
stage_idx: 2,
name: "bridge",
options: {
bridge_needs: { pipeline: 'some/project' }
......@@ -1372,7 +1372,7 @@ module Gitlab
expect(subject.builds.size).to eq(2)
expect(subject.builds[0]).to eq(
stage: "build",
stage_idx: 0,
stage_idx: 1,
name: "build",
options: {
script: ["test"]
......@@ -1383,7 +1383,7 @@ module Gitlab
)
expect(subject.builds[1]).to eq(
stage: "test",
stage_idx: 1,
stage_idx: 2,
name: "bridge",
options: {
bridge_needs: { pipeline: 'some/project' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment