2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module AutoDevopsHelper
|
|
|
|
def show_auto_devops_callout?(project)
|
|
|
|
Feature.get(:auto_devops_banner_disabled).off? &&
|
|
|
|
show_callout?('auto_devops_settings_dismissed') &&
|
|
|
|
can?(current_user, :admin_pipeline, project) &&
|
|
|
|
project.has_auto_devops_implicitly_disabled? &&
|
|
|
|
!project.repository.gitlab_ci_yml &&
|
|
|
|
!project.ci_service
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_devops_warning_message(project)
|
|
|
|
if missing_auto_devops_service?(project)
|
|
|
|
params = {
|
|
|
|
kubernetes: link_to('Kubernetes cluster', project_clusters_path(project))
|
|
|
|
}
|
|
|
|
|
|
|
|
if missing_auto_devops_domain?(project)
|
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params
|
|
|
|
else
|
|
|
|
_('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params
|
|
|
|
end
|
|
|
|
elsif missing_auto_devops_domain?(project)
|
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-08 19:23:39 +05:30
|
|
|
def cluster_ingress_ip(project)
|
|
|
|
project
|
|
|
|
.cluster_ingresses
|
|
|
|
.where("external_ip is not null")
|
|
|
|
.limit(1)
|
|
|
|
.pluck(:external_ip)
|
|
|
|
.first
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def missing_auto_devops_domain?(project)
|
|
|
|
!(project.auto_devops || project.build_auto_devops)&.has_domain?
|
|
|
|
end
|
|
|
|
|
|
|
|
def missing_auto_devops_service?(project)
|
|
|
|
!project.deployment_platform&.active?
|
|
|
|
end
|
|
|
|
end
|