summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-04-20 14:17:00 +1000
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-15 10:36:57 +0200
commit46eeaafc255f9cc037f2656fcace67085519bf29 (patch)
tree54c5d5056925e90d2e54d9192ffff6be95ef26f9
parent416a5450e4d8598e87f96f9edc57983502b42397 (diff)
downloadgitlab-ce-46eeaafc255f9cc037f2656fcace67085519bf29.tar.gz
Display help text below auto devops domain with nip.io domain name (#45561)45584-add-nip-io-domain-suggestion-in-auto-devops
-rw-r--r--app/helpers/auto_devops_helper.rb9
-rw-r--r--app/models/project.rb1
-rw-r--r--app/views/projects/settings/ci_cd/_autodevops_form.html.haml4
-rw-r--r--changelogs/unreleased/45584-add-nip-io-domain-suggestion-in-auto-devops.yml5
-rw-r--r--locale/gitlab.pot13
-rw-r--r--spec/features/projects/settings/pipelines_settings_spec.rb23
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
7 files changed, 50 insertions, 6 deletions
diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb
index 16451993e93..7b076728685 100644
--- a/app/helpers/auto_devops_helper.rb
+++ b/app/helpers/auto_devops_helper.rb
@@ -24,6 +24,15 @@ module AutoDevopsHelper
end
end
+ def cluster_ingress_ip(project)
+ project
+ .cluster_ingresses
+ .where("external_ip is not null")
+ .limit(1)
+ .pluck(:external_ip)
+ .first
+ end
+
private
def missing_auto_devops_domain?(project)
diff --git a/app/models/project.rb b/app/models/project.rb
index 32d34f5e9b8..534a0e630af 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -217,6 +217,7 @@ class Project < ActiveRecord::Base
has_one :cluster_project, class_name: 'Clusters::Project'
has_many :clusters, through: :cluster_project, class_name: 'Clusters::Cluster'
+ has_many :cluster_ingresses, through: :clusters, source: :application_ingress, class_name: 'Clusters::Applications::Ingress'
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy
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 71e77dae69e..8cb6c446e18 100644
--- a/app/views/projects/settings/ci_cd/_autodevops_form.html.haml
+++ b/app/views/projects/settings/ci_cd/_autodevops_form.html.haml
@@ -35,7 +35,9 @@
= _('Domain')
= form.text_field :domain, class: 'form-control', placeholder: 'domain.com'
.help-block
- = s_('CICD|You need to specify a domain if you want to use Auto Review Apps and Auto Deploy stages.')
+ = s_('CICD|A domain is required to use Auto Review Apps and Auto Deploy Stages.')
+ - if cluster_ingress_ip = cluster_ingress_ip(@project)
+ = s_('%{nip_domain} can be used as an alternative to a custom domain.').html_safe % { nip_domain: "<code>#{cluster_ingress_ip}.nip.io</code>".html_safe }
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-devops-base-domain'), target: '_blank'
= f.submit 'Save changes', class: "btn btn-success prepend-top-15"
diff --git a/changelogs/unreleased/45584-add-nip-io-domain-suggestion-in-auto-devops.yml b/changelogs/unreleased/45584-add-nip-io-domain-suggestion-in-auto-devops.yml
new file mode 100644
index 00000000000..31b4c29e03d
--- /dev/null
+++ b/changelogs/unreleased/45584-add-nip-io-domain-suggestion-in-auto-devops.yml
@@ -0,0 +1,5 @@
+---
+title: Display help text below auto devops domain with nip.io domain name (#45561)
+merge_request: 18496
+author:
+type: added
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 20377dc81b2..1179f71353a 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-05-09 09:24+0200\n"
-"PO-Revision-Date: 2018-05-09 09:24+0200\n"
+"POT-Creation-Date: 2018-05-14 10:49+0200\n"
+"PO-Revision-Date: 2018-05-14 10:49+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
@@ -72,6 +72,9 @@ msgstr[1] ""
msgid "%{loadingIcon} Started"
msgstr ""
+msgid "%{nip_domain} can be used as an alternative to a custom domain."
+msgstr ""
+
msgid "%{number_commits_behind} commits behind %{default_branch}, %{number_commits_ahead} commits ahead"
msgstr ""
@@ -737,6 +740,9 @@ msgstr ""
msgid "CI/CD settings"
msgstr ""
+msgid "CICD|A domain is required to use Auto Review Apps and Auto Deploy Stages."
+msgstr ""
+
msgid "CICD|An explicit %{ci_file} needs to be specified before you can begin using Continuous Integration and Delivery."
msgstr ""
@@ -767,9 +773,6 @@ msgstr ""
msgid "CICD|The Auto DevOps pipeline configuration will be used when there is no %{ci_file} in the project."
msgstr ""
-msgid "CICD|You need to specify a domain if you want to use Auto Review Apps and Auto Deploy stages."
-msgstr ""
-
msgid "Can run untagged jobs"
msgstr ""
diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb
index e875a88a52b..cfdae246c09 100644
--- a/spec/features/projects/settings/pipelines_settings_spec.rb
+++ b/spec/features/projects/settings/pipelines_settings_spec.rb
@@ -75,6 +75,29 @@ describe "Projects > Settings > Pipelines settings" do
expect(project.auto_devops).not_to be_enabled
expect(project.auto_devops.domain).to eq('test.com')
end
+
+ context 'when there is a cluster with ingress and external_ip' do
+ before do
+ cluster = create(:cluster, projects: [project])
+ cluster.create_application_ingress!(external_ip: '192.168.1.100')
+ end
+
+ it 'shows the help text with the nip.io domain as an alternative to custom domain' do
+ visit project_settings_ci_cd_path(project)
+ expect(page).to have_content('192.168.1.100.nip.io can be used as an alternative to a custom domain')
+ end
+ end
+
+ context 'when there is no ingress' do
+ before do
+ create(:cluster, projects: [project])
+ end
+
+ it 'alternative to custom domain is not shown' do
+ visit project_settings_ci_cd_path(project)
+ expect(page).not_to have_content('can be used as an alternative to a custom domain')
+ end
+ end
end
end
end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index ad76adcc2e5..8b46b04b8b5 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -185,6 +185,7 @@ project:
- cluster
- clusters
- cluster_project
+- cluster_ingresses
- creator
- group
- namespace