Class: Clusters::ClusterPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/presenters/clusters/cluster_presenter.rb

Instance Method Summary collapse

Methods inherited from Gitlab::View::Presenter::Delegated

#initialize

Methods included from Gitlab::Utils::DelegatorOverride

#delegator_override, #delegator_override_with, #delegator_target, validator, validators, verify!

Methods included from Gitlab::View::Presenter::Base

#__subject__, #can?, #declarative_policy_delegate, #is_a?, #path_with_line_numbers, #present, #url_builder, #web_path, #web_url

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

This class inherits a constructor from Gitlab::View::Presenter::Delegated

Instance Method Details

#can_read_cluster?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/presenters/clusters/cluster_presenter.rb', line 27

def can_read_cluster?
  can?(current_user, :read_cluster, cluster)
end

#health_data(clusterable) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/presenters/clusters/cluster_presenter.rb', line 59

def health_data(clusterable)
  {
    'clusters-path': clusterable.index_path,
    'dashboard-endpoint': clusterable.metrics_dashboard_path(cluster),
    'documentation-path': help_page_path('user/infrastructure/clusters/manage/clusters_health'),
    'add-dashboard-documentation-path': help_page_path('operations/metrics/dashboards/index.md', anchor: 'add-a-new-dashboard-to-your-project'),
    'empty-getting-started-svg-path': image_path('illustrations/monitoring/getting_started.svg'),
    'empty-loading-svg-path': image_path('illustrations/monitoring/loading.svg'),
    'empty-no-data-svg-path': image_path('illustrations/monitoring/no_data.svg'),
    'empty-no-data-small-svg-path': image_path('illustrations/chart-empty-state-small.svg'),
    'empty-unable-to-connect-svg-path': image_path('illustrations/monitoring/unable_to_connect.svg'),
    'settings-path': '',
    'project-path': '',
    'tags-path': ''
  }
end

#integrations_pathObject



43
44
45
46
47
48
49
50
51
52
53
# File 'app/presenters/clusters/cluster_presenter.rb', line 43

def integrations_path
  if cluster.project_type?
    create_or_update_project_cluster_integration_path(project, cluster)
  elsif cluster.group_type?
    create_or_update_group_cluster_integration_path(group, cluster)
  elsif cluster.instance_type?
    create_or_update_admin_cluster_integration_path(cluster)
  else
    raise NotImplementedError
  end
end

#provider_labelObject



11
12
13
14
15
16
17
# File 'app/presenters/clusters/cluster_presenter.rb', line 11

def provider_label
  if aws?
    s_('ClusterIntegration|Elastic Kubernetes Service')
  elsif gcp?
    s_('ClusterIntegration|Google Kubernetes Engine')
  end
end

#provider_management_urlObject



19
20
21
22
23
24
25
# File 'app/presenters/clusters/cluster_presenter.rb', line 19

def provider_management_url
  if aws?
    "https://console.aws.amazon.com/eks/home?region=#{provider.region}\#/clusters/#{name}"
  elsif gcp?
    "https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}"
  end
end

#read_only_kubernetes_platform_fields?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/presenters/clusters/cluster_presenter.rb', line 55

def read_only_kubernetes_platform_fields?
  !cluster.provided_by_user?
end

#show_path(params: {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'app/presenters/clusters/cluster_presenter.rb', line 31

def show_path(params: {})
  if cluster.project_type?
    project_cluster_path(project, cluster, params)
  elsif cluster.group_type?
    group_cluster_path(group, cluster, params)
  elsif cluster.instance_type?
    admin_cluster_path(cluster, params)
  else
    raise NotImplementedError
  end
end