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

Pass class as parameter to Simplifiable

parent ec3b5087
...@@ -9,7 +9,7 @@ module EE ...@@ -9,7 +9,7 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do 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 end
class Bridge < ::Gitlab::Config::Entry::Node class Bridge < ::Gitlab::Config::Entry::Node
......
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module Config module Config
module Entry module Entry
class Simplifiable < SimpleDelegator class Simplifiable < SimpleDelegator
EntryStrategy = Struct.new(:name, :condition) EntryStrategy = Struct.new(:name, :klass, :condition)
attr_reader :subject attr_reader :subject
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
end end
def self.strategy(name, **opts) 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) strategies.append(strategy)
end end
end end
...@@ -36,7 +36,7 @@ module Gitlab ...@@ -36,7 +36,7 @@ module Gitlab
def self.entry_class(strategy) def self.entry_class(strategy)
if strategy.present? if strategy.present?
self.const_get(strategy.name, false) strategy.klass || self.const_get(strategy.name, false)
else else
self::UnknownStrategy self::UnknownStrategy
end end
......
...@@ -1342,7 +1342,7 @@ module Gitlab ...@@ -1342,7 +1342,7 @@ module Gitlab
expect(subject.builds.size).to eq(2) expect(subject.builds.size).to eq(2)
expect(subject.builds[0]).to eq( expect(subject.builds[0]).to eq(
stage: "build", stage: "build",
stage_idx: 0, stage_idx: 1,
name: "build", name: "build",
options: { options: {
script: ["test"] script: ["test"]
...@@ -1353,7 +1353,7 @@ module Gitlab ...@@ -1353,7 +1353,7 @@ module Gitlab
) )
expect(subject.builds[1]).to eq( expect(subject.builds[1]).to eq(
stage: "test", stage: "test",
stage_idx: 1, stage_idx: 2,
name: "bridge", name: "bridge",
options: { options: {
bridge_needs: { pipeline: 'some/project' } bridge_needs: { pipeline: 'some/project' }
...@@ -1372,7 +1372,7 @@ module Gitlab ...@@ -1372,7 +1372,7 @@ module Gitlab
expect(subject.builds.size).to eq(2) expect(subject.builds.size).to eq(2)
expect(subject.builds[0]).to eq( expect(subject.builds[0]).to eq(
stage: "build", stage: "build",
stage_idx: 0, stage_idx: 1,
name: "build", name: "build",
options: { options: {
script: ["test"] script: ["test"]
...@@ -1383,7 +1383,7 @@ module Gitlab ...@@ -1383,7 +1383,7 @@ module Gitlab
) )
expect(subject.builds[1]).to eq( expect(subject.builds[1]).to eq(
stage: "test", stage: "test",
stage_idx: 1, stage_idx: 2,
name: "bridge", name: "bridge",
options: { options: {
bridge_needs: { pipeline: 'some/project' } 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