Add cluster domain warning

Added a cluster domain wanring if no domain is defined
This commit is contained in:
Jacques Erasmus 2019-09-03 23:15:13 +00:00 committed by Mike Greiling
parent b4f9f5e7ec
commit 85f89d21aa
4 changed files with 31 additions and 5 deletions

View file

@ -1,3 +1,14 @@
- has_base_domain = @project.all_clusters.any? { |cluster| cluster.base_domain && !cluster.base_domain.empty? }
- link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe
- link_end = '</a>'.html_safe
- kubernetes_cluster_path = help_page_path('user/project/clusters/index')
- kubernetes_cluster_link_start = link_start % { url: kubernetes_cluster_path }
- base_domain_path = help_page_path('user/project/clusters/index', anchor: 'base-domain')
- base_domain_link_start = link_start % { url: base_domain_path }
.row .row
.col-lg-12 .col-lg-12
= form_for @project, url: project_settings_ci_cd_path(@project, anchor: 'autodevops-settings') do |f| = form_for @project, url: project_settings_ci_cd_path(@project, anchor: 'autodevops-settings') do |f|
@ -19,9 +30,10 @@
.card-footer.js-extra-settings{ class: auto_devops_enabled || 'hidden' } .card-footer.js-extra-settings{ class: auto_devops_enabled || 'hidden' }
- if @project.all_clusters.empty? - if @project.all_clusters.empty?
%p.settings-message.text-center %p.settings-message.text-center
- kubernetes_cluster_link = help_page_path('user/project/clusters/index') = s_('CICD|You must add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} to this project with a domain in order for your deployment strategy to work correctly.').html_safe % { kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
- kubernetes_cluster_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: kubernetes_cluster_link } - elsif !has_base_domain
= s_('CICD|You must add a %{kubernetes_cluster_start}Kubernetes cluster integration%{kubernetes_cluster_end} to this project with a domain in order for your deployment strategy to work correctly.').html_safe % { kubernetes_cluster_start: kubernetes_cluster_start, kubernetes_cluster_end: '</a>'.html_safe } %p.settings-message.text-center
= s_('CICD|You must add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} in order for your deployment strategy to work.').html_safe % { base_domain_link_start: base_domain_link_start, kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
%label.prepend-top-10 %label.prepend-top-10
%strong= s_('CICD|Deployment strategy') %strong= s_('CICD|Deployment strategy')
.form-check .form-check

View file

@ -0,0 +1,5 @@
---
title: Add cluster domain warning
merge_request: 32260
author:
type: changed

View file

@ -1960,7 +1960,10 @@ msgstr ""
msgid "CICD|The Auto DevOps pipeline will run if no alternative CI configuration file is found." msgid "CICD|The Auto DevOps pipeline will run if no alternative CI configuration file is found."
msgstr "" msgstr ""
msgid "CICD|You must add a %{kubernetes_cluster_start}Kubernetes cluster integration%{kubernetes_cluster_end} to this project with a domain in order for your deployment strategy to work correctly." msgid "CICD|You must add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} in order for your deployment strategy to work."
msgstr ""
msgid "CICD|You must add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} to this project with a domain in order for your deployment strategy to work correctly."
msgstr "" msgstr ""
msgid "CICD|group enabled" msgid "CICD|group enabled"

View file

@ -17,10 +17,16 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
context 'when the project has an available kubernetes cluster' do context 'when the project has an available kubernetes cluster' do
let!(:cluster) { create(:cluster, cluster_type: :project_type, projects: [project]) } let!(:cluster) { create(:cluster, cluster_type: :project_type, projects: [project]) }
it 'does not show a warning message' do it 'does not show a warning message about Kubernetes cluster' do
render render
expect(rendered).not_to have_text('You must add a Kubernetes cluster') expect(rendered).not_to have_text('You must add a Kubernetes cluster')
end end
it 'shows a warning message about base domain' do
render
expect(rendered).to have_text('You must add a base domain to your Kubernetes cluster in order for your deployment strategy to work.')
end
end end
end end