From 7ac3723be04ba08cb476ba628cb5c1573ca832c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Thu, 6 Jun 2019 20:49:04 +0200 Subject: [PATCH] Backport CE changes Backports CE changes from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14011/ --- ...uired_template_name_to_application_settings.rb | 15 +++++++++++++++ db/schema.rb | 1 + lib/gitlab/ci/config.rb | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190527011309_add_required_template_name_to_application_settings.rb diff --git a/db/migrate/20190527011309_add_required_template_name_to_application_settings.rb b/db/migrate/20190527011309_add_required_template_name_to_application_settings.rb new file mode 100644 index 00000000000..6cbac0ed507 --- /dev/null +++ b/db/migrate/20190527011309_add_required_template_name_to_application_settings.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddRequiredTemplateNameToApplicationSettings < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :application_settings, :required_instance_ci_template, :string, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index fcf9e397ac1..1b4e50ffd6e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -193,6 +193,7 @@ ActiveRecord::Schema.define(version: 20190530154715) do t.integer "elasticsearch_replicas", default: 1, null: false t.text "encrypted_lets_encrypt_private_key" t.text "encrypted_lets_encrypt_private_key_iv" + t.string "required_instance_ci_template" t.boolean "dns_rebinding_protection_enabled", default: true, null: false t.index ["usage_stats_set_by_user_id"], name: "index_application_settings_on_usage_stats_set_by_user_id", using: :btree end diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index f187e456993..a0275515906 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -8,6 +8,12 @@ module Gitlab class Config ConfigError = Class.new(StandardError) + RESCUE_ERRORS = [ + Gitlab::Config::Loader::FormatError, + Extendable::ExtensionError, + External::Processor::IncludeError + ].freeze + def initialize(config, project: nil, sha: nil, user: nil) @config = Config::Extendable .new(build_config(config, project: project, sha: sha, user: user)) @@ -15,9 +21,7 @@ module Gitlab @global = Entry::Global.new(@config) @global.compose! - rescue Gitlab::Config::Loader::FormatError, - Extendable::ExtensionError, - External::Processor::IncludeError => e + rescue *rescue_errors => e raise Config::ConfigError, e.message end @@ -83,6 +87,11 @@ module Gitlab user: user, expandset: Set.new).perform end + + # Overriden in EE + def rescue_errors + RESCUE_ERRORS + end end end end