summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 00:07:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 00:07:31 +0000
commit3888bc4261500c275759683076e07baaf352e5ec (patch)
treeeb70e0415be41a1d713cc89f211a6045778cd6b8 /app
parent33e1622bfe5afb2eea08ff06e44de490383a93e3 (diff)
downloadgitlab-ce-3888bc4261500c275759683076e07baaf352e5ec.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/prometheus/metrics_controller.rb2
-rw-r--r--app/models/ci/build.rb8
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/ci/pipeline_config.rb14
-rw-r--r--app/models/environment.rb2
-rw-r--r--app/serializers/build_artifact_entity.rb2
-rw-r--r--app/serializers/build_details_entity.rb2
-rw-r--r--app/services/prometheus/adapter_service.rb15
8 files changed, 27 insertions, 20 deletions
diff --git a/app/controllers/projects/prometheus/metrics_controller.rb b/app/controllers/projects/prometheus/metrics_controller.rb
index 267dca74f96..f212ae52ecc 100644
--- a/app/controllers/projects/prometheus/metrics_controller.rb
+++ b/app/controllers/projects/prometheus/metrics_controller.rb
@@ -23,7 +23,7 @@ module Projects
private
def prometheus_adapter
- @prometheus_adapter ||= ::Prometheus::AdapterService.new(project).prometheus_adapter
+ @prometheus_adapter ||= ::Prometheus::AdapterService.new(project, project.deployment_platform&.cluster).prometheus_adapter
end
def require_prometheus_metrics!
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index fbf76f2c36a..f0930705a3f 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -719,8 +719,8 @@ module Ci
end
end
- def has_expiring_archive_artifacts?
- has_expiring_artifacts? && artifacts_file&.exists?
+ def has_expiring_artifacts?
+ artifacts_expire_at.present? && artifacts_expire_at > Time.now
end
def keep_artifacts!
@@ -935,10 +935,6 @@ module Ci
value.with_indifferent_access
end
end
-
- def has_expiring_artifacts?
- artifacts_expire_at.present? && artifacts_expire_at > Time.now
- end
end
end
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 29ec41ef1a1..42a40e06240 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -62,6 +62,8 @@ module Ci
has_one :triggered_by_pipeline, through: :source_pipeline, source: :source_pipeline
has_one :source_job, through: :source_pipeline, source: :source_job
+ has_one :pipeline_config, class_name: 'Ci::PipelineConfig', inverse_of: :pipeline
+
accepts_nested_attributes_for :variables, reject_if: :persisted?
delegate :id, to: :project, prefix: true
diff --git a/app/models/ci/pipeline_config.rb b/app/models/ci/pipeline_config.rb
new file mode 100644
index 00000000000..d5a8da2bc1e
--- /dev/null
+++ b/app/models/ci/pipeline_config.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Ci
+ class PipelineConfig < ApplicationRecord
+ extend Gitlab::Ci::Model
+
+ self.table_name = 'ci_pipelines_config'
+ self.primary_key = :pipeline_id
+
+ belongs_to :pipeline, class_name: "Ci::Pipeline", inverse_of: :pipeline_config
+ validates :pipeline, presence: true
+ validates :content, presence: true
+ end
+end
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 84a72fee77b..7ef38ab4cf4 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -223,7 +223,7 @@ class Environment < ApplicationRecord
# rubocop: disable CodeReuse/ServiceClass
def prometheus_adapter
- @prometheus_adapter ||= Prometheus::AdapterService.new(project, deployment_platform).prometheus_adapter
+ @prometheus_adapter ||= Prometheus::AdapterService.new(project, deployment_platform&.cluster).prometheus_adapter
end
# rubocop: enable CodeReuse/ServiceClass
diff --git a/app/serializers/build_artifact_entity.rb b/app/serializers/build_artifact_entity.rb
index c173c155edf..414f436e76e 100644
--- a/app/serializers/build_artifact_entity.rb
+++ b/app/serializers/build_artifact_entity.rb
@@ -14,7 +14,7 @@ class BuildArtifactEntity < Grape::Entity
download_project_job_artifacts_path(project, job)
end
- expose :keep_path, if: -> (*) { job.has_expiring_archive_artifacts? } do |job|
+ expose :keep_path, if: -> (*) { job.has_expiring_artifacts? } do |job|
keep_project_job_artifacts_path(project, job)
end
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 0ef71ff8af5..480a8cab6ff 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -31,7 +31,7 @@ class BuildDetailsEntity < JobEntity
browse_project_job_artifacts_path(project, build)
end
- expose :keep_path, if: -> (*) { build.has_expiring_archive_artifacts? && can?(current_user, :update_build, build) } do |build|
+ expose :keep_path, if: -> (*) { build.has_expiring_artifacts? && can?(current_user, :update_build, build) } do |build|
keep_project_job_artifacts_path(project, build)
end
diff --git a/app/services/prometheus/adapter_service.rb b/app/services/prometheus/adapter_service.rb
index 399f4c35d66..5e8357a83f6 100644
--- a/app/services/prometheus/adapter_service.rb
+++ b/app/services/prometheus/adapter_service.rb
@@ -2,18 +2,13 @@
module Prometheus
class AdapterService
- def initialize(project, deployment_platform = nil)
- @project = project
+ attr_reader :project, :cluster
- @deployment_platform = if deployment_platform
- deployment_platform
- else
- project.deployment_platform
- end
+ def initialize(project, cluster)
+ @project = project
+ @cluster = cluster
end
- attr_reader :deployment_platform, :project
-
def prometheus_adapter
@prometheus_adapter ||= if service_prometheus_adapter.can_query?
service_prometheus_adapter
@@ -27,7 +22,7 @@ module Prometheus
end
def cluster_prometheus_adapter
- application = deployment_platform&.cluster&.application_prometheus
+ application = cluster&.application_prometheus
application if application&.available?
end