Commit d8a44cef authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '7204-follow-up-protected-environments-technical-debt' into 'master'

Protected Environments follow up: Use class method to override CE constants on EE

Closes #7204

See merge request gitlab-org/gitlab-ee!7256
parents d1a39374 65bc55ee
# frozen_string_literal: true
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
prepend ::EE::CommitStatusPresenter
CALLOUT_FAILURE_MESSAGES = {
unknown_failure: 'There is an unknown failure, please try again',
script_failure: nil,
......@@ -10,12 +8,19 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
runner_system_failure: 'There has been a runner system failure, please try again',
missing_dependency_failure: 'There has been a missing dependency failure',
runner_unsupported: 'Your runner is outdated, please upgrade your runner'
}.merge(EE_CALLOUT_FAILURE_MESSAGES).freeze
}.freeze
private_constant :CALLOUT_FAILURE_MESSAGES
presents :build
prepend ::EE::CommitStatusPresenter
def self.callout_failure_messages
CALLOUT_FAILURE_MESSAGES
end
def callout_failure_message
CALLOUT_FAILURE_MESSAGES.fetch(failure_reason.to_sym)
self.class.callout_failure_messages.fetch(failure_reason.to_sym)
end
def recoverable?
......
# frozen_string_literal: true
module EE
module CommitStatusPresenter
EE_CALLOUT_FAILURE_MESSAGES = {
protected_environment_failure: 'The environment this job is deploying to is protected. Only users with permission may successfully run this job'
}.freeze
extend ActiveSupport::Concern
prepended do
EE_CALLOUT_FAILURE_MESSAGES = const_get(:CALLOUT_FAILURE_MESSAGES).merge(
protected_environment_failure: 'The environment this job is deploying to is protected. Only users with permission may successfully run this job'
).freeze
EE::CommitStatusPresenter.private_constant :EE_CALLOUT_FAILURE_MESSAGES
end
class_methods do
def callout_failure_messages
EE_CALLOUT_FAILURE_MESSAGES
end
end
end
end
......@@ -5,9 +5,21 @@ module EE
module Status
module Build
module Failed
EE_REASONS = {
protected_environment_failure: 'protected environment failure'
}.freeze
extend ActiveSupport::Concern
prepended do
EE_REASONS = const_get(:REASONS).merge(
protected_environment_failure: 'protected environment failure'
).freeze
EE::Gitlab::Ci::Status::Build::Failed.private_constant :EE_REASONS
end
class_methods do
def reasons
EE_REASONS
end
end
end
end
end
......
......@@ -3,8 +3,6 @@ module Gitlab
module Status
module Build
class Failed < Status::Extended
prepend ::EE::Gitlab::Ci::Status::Build::Failed
REASONS = {
unknown_failure: 'unknown failure',
script_failure: 'script failure',
......@@ -13,7 +11,10 @@ module Gitlab
runner_system_failure: 'runner system failure',
missing_dependency_failure: 'missing dependency failure',
runner_unsupported: 'unsupported runner'
}.merge(EE_REASONS).freeze
}.freeze
private_constant :REASONS
prepend ::EE::Gitlab::Ci::Status::Build::Failed
def status_tooltip
base_message
......@@ -27,6 +28,10 @@ module Gitlab
build.failed?
end
def self.reasons
REASONS
end
private
def base_message
......@@ -38,7 +43,7 @@ module Gitlab
end
def failure_reason_message
REASONS.fetch(subject.failure_reason.to_sym)
self.class.reasons.fetch(subject.failure_reason.to_sym)
end
end
end
......
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