diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /app/models/deployment.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index c06c809538a..63d531d82c3 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -14,8 +14,8 @@ class Deployment < ApplicationRecord ARCHIVABLE_OFFSET = 50_000 - belongs_to :project, required: true - belongs_to :environment, required: true + belongs_to :project, optional: false + belongs_to :environment, optional: false belongs_to :cluster, class_name: 'Clusters::Cluster', optional: true belongs_to :user belongs_to :deployable, polymorphic: true, optional: true # rubocop:disable Cop/PolymorphicAssociations @@ -46,7 +46,7 @@ class Deployment < ApplicationRecord scope :for_project, -> (project_id) { where(project_id: project_id) } scope :for_projects, -> (projects) { where(project: projects) } - scope :visible, -> { where(status: %i[running success failed canceled blocked]) } + scope :visible, -> { where(status: VISIBLE_STATUSES) } scope :stoppable, -> { where.not(on_stop: nil).where.not(deployable_id: nil).success } scope :active, -> { where(status: %i[created running]) } scope :upcoming, -> { where(status: %i[blocked running]) } @@ -58,6 +58,7 @@ class Deployment < ApplicationRecord scope :ordered, -> { order(finished_at: :desc) } + VISIBLE_STATUSES = %i[running success failed canceled blocked].freeze FINISHED_STATUSES = %i[success failed canceled].freeze state_machine :status, initial: :created do @@ -380,6 +381,12 @@ class Deployment < ApplicationRecord status == params[:status] end + def tier_in_yaml + return unless deployable + + deployable.environment_deployment_tier + end + private def update_status!(status) |