diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 15:07:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-11 15:07:38 +0000 |
commit | 4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (patch) | |
tree | 2eff1ce7ac4a58de15b1f5980acfdb22c7b92ac0 /lib | |
parent | b86f474bf51e20d2db4cf0895d0a8e0894e31c08 (diff) | |
download | gitlab-ce-4eea104c69e59f6fa53c7bc15b986c69f29b60c8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/releases.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb | 23 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml | 3 | ||||
-rw-r--r-- | lib/gitlab/diff/file_collection/base.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/diff/file_collection/merge_request_diff_batch.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/diff/highlight_cache.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/diff/line.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/discussions_diff/highlight_cache.rb | 6 |
8 files changed, 47 insertions, 12 deletions
diff --git a/lib/api/releases.rb b/lib/api/releases.rb index 3f600ef4a04..2df6050967b 100644 --- a/lib/api/releases.rb +++ b/lib/api/releases.rb @@ -57,6 +57,7 @@ module API optional :milestones, type: Array, desc: 'The titles of the related milestones', default: [] optional :released_at, type: DateTime, desc: 'The date when the release will be/was ready. Defaults to the current time.' end + route_setting :authentication, job_token_allowed: true post ':id/releases' do authorize_create_release! diff --git a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb index 65445ab3fc4..465877871ea 100644 --- a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb +++ b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb @@ -63,12 +63,33 @@ module Gitlab end def create_namespace + namespace = kubernetes_namespace || build_namespace_record + + return if conflicting_ci_namespace_requested?(namespace) + Clusters::Kubernetes::CreateOrUpdateNamespaceService.new( cluster: deployment_cluster, - kubernetes_namespace: kubernetes_namespace || build_namespace_record + kubernetes_namespace: namespace ).execute end + ## + # A namespace can only be specified via gitlab-ci.yml + # for unmanaged clusters, as we currently have no way + # of preventing a job requesting a namespace it + # shouldn't have access to. + # + # To make this clear, we fail the build instead of + # silently using a namespace other than the one + # explicitly specified. + # + # Support for managed clusters will be added in + # https://gitlab.com/gitlab-org/gitlab/issues/38054 + def conflicting_ci_namespace_requested?(namespace_record) + build.expanded_kubernetes_namespace.present? && + namespace_record.namespace != build.expanded_kubernetes_namespace + end + def build_namespace_record Clusters::BuildKubernetesNamespaceService.new( deployment_cluster, diff --git a/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml b/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml index 878f2acb276..938b6f89b76 100644 --- a/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml @@ -1,12 +1,13 @@ apply: stage: deploy - image: "registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications:v0.2.0" + image: "registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications:v0.3.0" environment: name: production variables: TILLER_NAMESPACE: gitlab-managed-apps GITLAB_MANAGED_APPS_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/config.yaml INGRESS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/ingress/values.yaml + SENTRY_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/sentry/values.yaml script: - gitlab-managed-apps /usr/local/share/gitlab-managed-apps/helmfile.yaml only: diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb index c5bbf522f7c..ea915a6b84b 100644 --- a/lib/gitlab/diff/file_collection/base.rb +++ b/lib/gitlab/diff/file_collection/base.rb @@ -34,6 +34,18 @@ module Gitlab @diff_files ||= diffs.decorate! { |diff| decorate_diff!(diff) } end + def diff_file_paths + diff_files.map(&:file_path) + end + + def pagination_data + { + current_page: nil, + next_page: nil, + total_pages: nil + } + end + # This mutates `diff_files` lines. def unfold_diff_files(positions) positions_grouped_by_path = positions.group_by { |position| position.file_path } diff --git a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb index 663326e01d5..c6d1e0b93a7 100644 --- a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb +++ b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb @@ -29,10 +29,6 @@ module Gitlab } end - def diff_file_paths - diff_files.map(&:file_path) - end - override :diffs def diffs strong_memoize(:diffs) do diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb index bc1baa09d39..10363236234 100644 --- a/lib/gitlab/diff/highlight_cache.rb +++ b/lib/gitlab/diff/highlight_cache.rb @@ -21,7 +21,7 @@ module Gitlab def decorate(diff_file) if content = read_file(diff_file) diff_file.highlighted_diff_lines = content.map do |line| - Gitlab::Diff::Line.init_from_hash(line) + Gitlab::Diff::Line.safe_init_from_hash(line) end end end diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index 28ea1921f90..379fc6af875 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -34,6 +34,14 @@ module Gitlab rich_text: hash[:rich_text]) end + def self.safe_init_from_hash(hash) + line = hash.with_indifferent_access + rich_text = line[:rich_text] + line[:rich_text] = rich_text&.html_safe + + init_from_hash(line) + end + def to_hash hash = {} SERIALIZE_KEYS.each { |key| hash[key] = send(key) } # rubocop:disable GitlabSecurity/PublicSend diff --git a/lib/gitlab/discussions_diff/highlight_cache.rb b/lib/gitlab/discussions_diff/highlight_cache.rb index 369c6b87fb4..1f64883cb69 100644 --- a/lib/gitlab/discussions_diff/highlight_cache.rb +++ b/lib/gitlab/discussions_diff/highlight_cache.rb @@ -43,11 +43,7 @@ module Gitlab next unless lines JSON.parse(lines).map! do |line| - line = line.with_indifferent_access - rich_text = line[:rich_text] - line[:rich_text] = rich_text&.html_safe - - Gitlab::Diff::Line.init_from_hash(line) + Gitlab::Diff::Line.safe_init_from_hash(line) end end end |