2018-10-26 00:12:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-28 07:08:42 -05:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
module Policy
|
|
|
|
class Variables < Policy::Specification
|
|
|
|
def initialize(expressions)
|
|
|
|
@expressions = Array(expressions)
|
|
|
|
end
|
|
|
|
|
2019-11-17 16:06:14 -05:00
|
|
|
def satisfied_by?(pipeline, context)
|
|
|
|
variables = context.variables
|
2018-03-23 08:44:12 -04:00
|
|
|
|
2018-02-28 07:08:42 -05:00
|
|
|
statements = @expressions.map do |statement|
|
|
|
|
::Gitlab::Ci::Pipeline::Expression::Statement
|
2018-03-23 08:44:12 -04:00
|
|
|
.new(statement, variables)
|
2018-02-28 07:08:42 -05:00
|
|
|
end
|
|
|
|
|
2018-03-01 07:08:39 -05:00
|
|
|
statements.any?(&:truthful?)
|
2018-02-28 07:08:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|