2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-18 08:13:57 -05:00
|
|
|
module ClustersHelper
|
2018-10-18 21:42:30 -04:00
|
|
|
# EE overrides this
|
|
|
|
def has_multiple_clusters?
|
2017-12-18 08:35:08 -05:00
|
|
|
false
|
2017-12-18 08:13:57 -05:00
|
|
|
end
|
2018-05-07 14:06:02 -04:00
|
|
|
|
2019-11-08 01:06:24 -05:00
|
|
|
def create_new_cluster_label(provider: nil)
|
|
|
|
case provider
|
|
|
|
when 'aws'
|
2019-12-17 19:08:09 -05:00
|
|
|
s_('ClusterIntegration|Create new cluster on EKS')
|
2019-11-08 01:06:24 -05:00
|
|
|
when 'gcp'
|
2019-12-17 19:08:09 -05:00
|
|
|
s_('ClusterIntegration|Create new cluster on GKE')
|
2019-11-08 01:06:24 -05:00
|
|
|
else
|
2019-12-17 19:08:09 -05:00
|
|
|
s_('ClusterIntegration|Create new cluster')
|
2019-11-08 01:06:24 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-07 14:06:02 -04:00
|
|
|
def render_gcp_signup_offer
|
2018-07-10 09:20:05 -04:00
|
|
|
return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers?
|
2018-05-07 14:06:02 -04:00
|
|
|
return unless show_gcp_signup_offer?
|
|
|
|
|
|
|
|
content_tag :section, class: 'no-animate expanded' do
|
2018-10-31 20:39:01 -04:00
|
|
|
render 'clusters/clusters/gcp_signup_offer_banner'
|
2018-05-07 14:06:02 -04:00
|
|
|
end
|
|
|
|
end
|
2019-03-25 11:18:39 -04:00
|
|
|
|
2020-03-12 11:09:39 -04:00
|
|
|
def render_cluster_info_tab_content(tab, expanded)
|
|
|
|
case tab
|
|
|
|
when 'environments'
|
|
|
|
render_if_exists 'clusters/clusters/environments'
|
|
|
|
when 'health'
|
|
|
|
render_if_exists 'clusters/clusters/health'
|
|
|
|
when 'apps'
|
|
|
|
render 'applications'
|
|
|
|
when 'settings'
|
|
|
|
render 'advanced_settings_container'
|
|
|
|
else
|
|
|
|
render('details', expanded: expanded)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-10 11:09:50 -04:00
|
|
|
def cluster_type_label(cluster_type)
|
|
|
|
case cluster_type
|
|
|
|
when 'project_type'
|
|
|
|
s_('ClusterIntegration|Project cluster')
|
|
|
|
when 'group_type'
|
|
|
|
s_('ClusterIntegration|Group cluster')
|
|
|
|
when 'instance_type'
|
|
|
|
s_('ClusterIntegration|Instance cluster')
|
|
|
|
else
|
|
|
|
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
|
|
|
|
ArgumentError.new('Cluster Type Missing'),
|
|
|
|
cluster_error: { error: 'Cluster Type Missing', cluster_type: cluster_type }
|
|
|
|
)
|
|
|
|
_('Cluster')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-25 11:18:39 -04:00
|
|
|
def has_rbac_enabled?(cluster)
|
|
|
|
return cluster.platform_kubernetes_rbac? if cluster.platform_kubernetes
|
|
|
|
|
2019-11-13 01:06:38 -05:00
|
|
|
cluster.provider.has_rbac_enabled?
|
2019-03-25 11:18:39 -04:00
|
|
|
end
|
2020-03-12 11:09:39 -04:00
|
|
|
|
|
|
|
def project_cluster?(cluster)
|
|
|
|
cluster.cluster_type.in?('project_type')
|
|
|
|
end
|
|
|
|
|
|
|
|
def cluster_created?(cluster)
|
|
|
|
!cluster.status_name.in?(%i/scheduled creating/)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_admin_cluster?(user, cluster)
|
|
|
|
can?(user, :admin_cluster, cluster)
|
|
|
|
end
|
2017-12-18 08:13:57 -05:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
ClustersHelper.prepend_if_ee('EE::ClustersHelper')
|