From 85f89d21aa38e6eb5c91495607078c1f3690d898 Mon Sep 17 00:00:00 2001 From: Jacques Erasmus Date: Tue, 3 Sep 2019 23:15:13 +0000 Subject: Add cluster domain warning Added a cluster domain wanring if no domain is defined --- .../projects/settings/ci_cd/_autodevops_form.html.haml | 18 +++++++++++++++--- .../unreleased/je-add-cluster-domain-warning.yml | 5 +++++ locale/gitlab.pot | 5 ++++- .../settings/ci_cd/_autodevops_form.html.haml_spec.rb | 8 +++++++- 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/je-add-cluster-domain-warning.yml diff --git a/app/views/projects/settings/ci_cd/_autodevops_form.html.haml b/app/views/projects/settings/ci_cd/_autodevops_form.html.haml index 04b77fb987a..1d5d90593ae 100644 --- a/app/views/projects/settings/ci_cd/_autodevops_form.html.haml +++ b/app/views/projects/settings/ci_cd/_autodevops_form.html.haml @@ -1,3 +1,14 @@ +- has_base_domain = @project.all_clusters.any? { |cluster| cluster.base_domain && !cluster.base_domain.empty? } + +- link_start = ''.html_safe +- link_end = ''.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 .col-lg-12 = 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' } - if @project.all_clusters.empty? %p.settings-message.text-center - - kubernetes_cluster_link = help_page_path('user/project/clusters/index') - - kubernetes_cluster_start = ''.html_safe % { url: kubernetes_cluster_link } - = 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: ''.html_safe } + = 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 } + - elsif !has_base_domain + %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 %strong= s_('CICD|Deployment strategy') .form-check diff --git a/changelogs/unreleased/je-add-cluster-domain-warning.yml b/changelogs/unreleased/je-add-cluster-domain-warning.yml new file mode 100644 index 00000000000..e7d244f730f --- /dev/null +++ b/changelogs/unreleased/je-add-cluster-domain-warning.yml @@ -0,0 +1,5 @@ +--- +title: Add cluster domain warning +merge_request: 32260 +author: +type: changed diff --git a/locale/gitlab.pot b/locale/gitlab.pot index a5619079988..167b6783073 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1960,7 +1960,10 @@ msgstr "" msgid "CICD|The Auto DevOps pipeline will run if no alternative CI configuration file is found." 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 "" msgid "CICD|group enabled" diff --git a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb index ff2d491539b..697e44be065 100644 --- a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb +++ b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb @@ -17,10 +17,16 @@ describe 'projects/settings/ci_cd/_autodevops_form' do context 'when the project has an available kubernetes cluster' do 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 expect(rendered).not_to have_text('You must add a Kubernetes cluster') 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 -- cgit v1.2.1