diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-07 15:41:32 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-07 15:41:32 +0300 |
commit | d08bf247bc2a99120498e939ba573f44e5f27f07 (patch) | |
tree | 6fe348f4ffdc1b104374743a8e4a19621188e895 /app | |
parent | 2b5d5b107ccc852f498d226d05d276160fc30c5a (diff) | |
parent | 5291c0bb51ae19109e09ff0ee7fca6f118288923 (diff) |
Merge branch '38175-add-domain-field-to-auto-devops-application-setting' into 'master'
Resolve "Add domain field to Auto DevOps application setting"
Closes #38175
See merge request gitlab-org/gitlab-ce!16604
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_settings_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/auto_devops_helper.rb | 19 | ||||
-rw-r--r-- | app/models/application_setting.rb | 5 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/models/project_auto_devops.rb | 8 | ||||
-rw-r--r-- | app/views/admin/application_settings/_form.html.haml | 7 |
6 files changed, 32 insertions, 10 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 7548bc30247..e293b3ef329 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -146,6 +146,7 @@ module ApplicationSettingsHelper :akismet_enabled, :authorized_keys_enabled, :auto_devops_enabled, + :auto_devops_domain, :circuitbreaker_access_retries, :circuitbreaker_check_interval, :circuitbreaker_failure_count_threshold, diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb index d72457efec0..16451993e93 100644 --- a/app/helpers/auto_devops_helper.rb +++ b/app/helpers/auto_devops_helper.rb @@ -9,21 +9,28 @@ module AutoDevopsHelper end def auto_devops_warning_message(project) - missing_domain = !project.auto_devops&.has_domain? - missing_service = !project.deployment_platform&.active? - - if missing_service + if missing_auto_devops_service?(project) params = { kubernetes: link_to('Kubernetes cluster', project_clusters_path(project)) } - if missing_domain + if missing_auto_devops_domain?(project) _('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params else _('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params end - elsif missing_domain + elsif missing_auto_devops_domain?(project) _('Auto Review Apps and Auto Deploy need a domain name to work correctly.') end end + + private + + def missing_auto_devops_domain?(project) + !(project.auto_devops || project.build_auto_devops)&.has_domain? + end + + def missing_auto_devops_service?(project) + !project.deployment_platform&.active? + end end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 80bda7f22ff..0dee6df525d 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -117,6 +117,11 @@ class ApplicationSetting < ActiveRecord::Base validates :repository_storages, presence: true validate :check_repository_storages + validates :auto_devops_domain, + allow_blank: true, + hostname: { allow_numeric_hostname: true, require_valid_tld: true }, + if: :auto_devops_enabled? + validates :enabled_git_access_protocol, inclusion: { in: %w(ssh http), allow_blank: true, allow_nil: true } diff --git a/app/models/project.rb b/app/models/project.rb index 34fb39dd28e..fd8917467e9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1601,7 +1601,7 @@ class Project < ActiveRecord::Base def auto_devops_variables return [] unless auto_devops_enabled? - auto_devops&.variables || [] + (auto_devops || build_auto_devops)&.variables end def append_or_update_attribute(name, value) diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb index 9a52edbff8e..112ed7ed434 100644 --- a/app/models/project_auto_devops.rb +++ b/app/models/project_auto_devops.rb @@ -6,13 +6,17 @@ class ProjectAutoDevops < ActiveRecord::Base validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true } + def instance_domain + Gitlab::CurrentSettings.auto_devops_domain + end + def has_domain? - domain.present? + domain.present? || instance_domain.present? end def variables variables = [] - variables << { key: 'AUTO_DEVOPS_DOMAIN', value: domain, public: true } if domain.present? + variables << { key: 'AUTO_DEVOPS_DOMAIN', value: domain.presence || instance_domain, public: true } if has_domain? variables end end diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index fb5e6f337a7..60f12030f98 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -249,7 +249,12 @@ .help-block It will automatically build, test, and deploy applications based on a predefined CI/CD configuration = link_to icon('question-circle'), help_page_path('topics/autodevops/index.md') - + .form-group + = f.label :auto_devops_domain, class: 'control-label col-sm-2' + .col-sm-10 + = f.text_field :auto_devops_domain, class: 'form-control', placeholder: 'domain.com' + .help-block + = s_("AdminSettings|Specify a domain to use by default for every project's Auto Review Apps and Auto Deploy stages.") .form-group .col-sm-offset-2.col-sm-10 .checkbox |