2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module ClustersHelper
|
2019-12-26 22:10:19 +05:30
|
|
|
def create_new_cluster_label(provider: nil)
|
|
|
|
case provider
|
|
|
|
when 'aws'
|
2020-01-01 13:55:28 +05:30
|
|
|
s_('ClusterIntegration|Create new cluster on EKS')
|
2019-12-26 22:10:19 +05:30
|
|
|
when 'gcp'
|
2020-01-01 13:55:28 +05:30
|
|
|
s_('ClusterIntegration|Create new cluster on GKE')
|
2019-12-26 22:10:19 +05:30
|
|
|
else
|
2020-01-01 13:55:28 +05:30
|
|
|
s_('ClusterIntegration|Create new cluster')
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def display_cluster_agents?(_clusterable)
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def js_cluster_agents_list_data(clusterable_project)
|
|
|
|
{
|
|
|
|
default_branch_name: clusterable_project.default_branch,
|
|
|
|
empty_state_image: image_path('illustrations/clusters_empty.svg'),
|
2021-09-30 23:02:18 +05:30
|
|
|
project_path: clusterable_project.full_path,
|
|
|
|
agent_docs_url: help_page_path('user/clusters/agent/index'),
|
|
|
|
install_docs_url: help_page_path('administration/clusters/kas'),
|
|
|
|
get_started_docs_url: help_page_path('user/clusters/agent/index', anchor: 'define-a-configuration-repository'),
|
|
|
|
integration_docs_url: help_page_path('user/clusters/agent/index', anchor: 'get-started-with-gitops-and-the-gitlab-agent')
|
2021-01-03 14:25:43 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def js_clusters_list_data(path = nil)
|
|
|
|
{
|
2020-07-28 23:09:34 +05:30
|
|
|
ancestor_help_path: help_page_path('user/group/clusters/index', anchor: 'cluster-precedence'),
|
2020-06-23 00:09:42 +05:30
|
|
|
endpoint: path,
|
|
|
|
img_tags: {
|
|
|
|
aws: { path: image_path('illustrations/logos/amazon_eks.svg'), text: s_('ClusterIntegration|Amazon EKS') },
|
|
|
|
default: { path: image_path('illustrations/logos/kubernetes.svg'), text: _('Kubernetes Cluster') },
|
|
|
|
gcp: { path: image_path('illustrations/logos/google_gke.svg'), text: s_('ClusterIntegration|Google GKE') }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
def js_cluster_form_data(cluster, can_edit)
|
|
|
|
{
|
|
|
|
enabled: cluster.enabled?.to_s,
|
|
|
|
editable: can_edit.to_s,
|
|
|
|
environment_scope: cluster.environment_scope,
|
|
|
|
base_domain: cluster.base_domain,
|
|
|
|
application_ingress_external_ip: cluster.application_ingress_external_ip,
|
|
|
|
auto_devops_help_path: help_page_path('topics/autodevops/index'),
|
2021-09-04 01:27:46 +05:30
|
|
|
external_endpoint_help_path: help_page_path('user/project/clusters/index.md', anchor: 'base-domain')
|
2020-10-24 23:57:45 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def js_cluster_new
|
|
|
|
{
|
|
|
|
cluster_connect_help_path: help_page_path('user/project/clusters/add_remove_clusters', anchor: 'add-existing-cluster')
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
def render_gcp_signup_offer
|
2018-11-08 19:23:39 +05:30
|
|
|
return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers?
|
2018-10-15 14:42:47 +05:30
|
|
|
return unless show_gcp_signup_offer?
|
|
|
|
|
|
|
|
content_tag :section, class: 'no-animate expanded' do
|
2018-12-13 13:39:08 +05:30
|
|
|
render 'clusters/clusters/gcp_signup_offer_banner'
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
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'
|
2021-04-29 21:17:54 +05:30
|
|
|
when 'integrations'
|
|
|
|
render 'integrations'
|
2020-04-08 14:13:33 +05:30
|
|
|
when 'settings'
|
|
|
|
render 'advanced_settings_container'
|
|
|
|
else
|
|
|
|
render('details', expanded: expanded)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
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-07-07 11:18:12 +05:30
|
|
|
def has_rbac_enabled?(cluster)
|
|
|
|
return cluster.platform_kubernetes_rbac? if cluster.platform_kubernetes
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
cluster.provider.has_rbac_enabled?
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|