diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-05-15 19:33:06 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-05-15 19:33:06 +0300 |
commit | bdf279b151c2a530155425f352daac0576f1ec60 (patch) | |
tree | 6f0ce92e18056804697db30a718a13c085c02911 /app | |
parent | be5fdff13e001bcb644d447f6f74cce8b190c8c9 (diff) | |
parent | 46eeaafc255f9cc037f2656fcace67085519bf29 (diff) |
Merge branch '45584-add-nip-io-domain-suggestion-in-auto-devops' into 'master'
Resolve "Add nip.io domain suggestion in the Kubernetes cluster details view"
Closes #45584
See merge request gitlab-org/gitlab-ce!18496
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/auto_devops_helper.rb | 9 | ||||
-rw-r--r-- | app/models/project.rb | 1 | ||||
-rw-r--r-- | app/views/projects/settings/ci_cd/_autodevops_form.html.haml | 4 |
3 files changed, 13 insertions, 1 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" |