2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-05 09:39:19 -04:00
|
|
|
module AutoDevopsHelper
|
2017-09-05 07:35:31 -04:00
|
|
|
def show_auto_devops_callout?(project)
|
2017-09-12 08:00:50 -04:00
|
|
|
Feature.get(:auto_devops_banner_disabled).off? &&
|
|
|
|
show_callout?('auto_devops_settings_dismissed') &&
|
2017-09-07 07:23:05 -04:00
|
|
|
can?(current_user, :admin_pipeline, project) &&
|
2017-09-12 03:21:47 -04:00
|
|
|
project.has_auto_devops_implicitly_disabled? &&
|
|
|
|
!project.repository.gitlab_ci_yml &&
|
2017-09-16 09:02:37 -04:00
|
|
|
!project.ci_service
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_devops_warning_message(project)
|
2018-02-02 13:54:00 -05:00
|
|
|
if missing_auto_devops_service?(project)
|
2017-09-16 09:02:37 -04:00
|
|
|
params = {
|
2018-01-25 04:27:10 -05:00
|
|
|
kubernetes: link_to('Kubernetes cluster', project_clusters_path(project))
|
2017-09-16 09:02:37 -04:00
|
|
|
}
|
|
|
|
|
2018-02-02 13:54:00 -05:00
|
|
|
if missing_auto_devops_domain?(project)
|
2018-01-25 04:27:10 -05:00
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params
|
2017-09-16 09:02:37 -04:00
|
|
|
else
|
2018-01-25 04:27:10 -05:00
|
|
|
_('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params
|
2017-09-16 09:02:37 -04:00
|
|
|
end
|
2018-02-02 13:54:00 -05:00
|
|
|
elsif missing_auto_devops_domain?(project)
|
2017-09-16 09:02:37 -04:00
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
|
|
|
|
end
|
2017-09-05 07:35:31 -04:00
|
|
|
end
|
2018-02-01 17:29:11 -05:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-04-20 00:17:00 -04:00
|
|
|
def cluster_ingress_ip(project)
|
|
|
|
project
|
|
|
|
.cluster_ingresses
|
|
|
|
.where("external_ip is not null")
|
|
|
|
.limit(1)
|
|
|
|
.pluck(:external_ip)
|
|
|
|
.first
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-04-20 00:17:00 -04:00
|
|
|
|
2018-02-01 17:29:11 -05:00
|
|
|
private
|
|
|
|
|
2018-02-02 13:54:00 -05:00
|
|
|
def missing_auto_devops_domain?(project)
|
2018-02-02 17:06:13 -05:00
|
|
|
!(project.auto_devops || project.build_auto_devops)&.has_domain?
|
2018-02-01 17:29:11 -05:00
|
|
|
end
|
|
|
|
|
2018-02-02 13:54:00 -05:00
|
|
|
def missing_auto_devops_service?(project)
|
2018-02-01 17:29:11 -05:00
|
|
|
!project.deployment_platform&.active?
|
|
|
|
end
|
2017-09-05 07:35:31 -04:00
|
|
|
end
|