uffizzi_core 2.0.13 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce237a7f1c46dcb9abbe62124bae678aa95e5a91a371da56c1358295dfaf035
4
- data.tar.gz: a5afbb4dbe4b8bd0df78b4f7abb8f402dee2a0122ec409a004b344abadf560c7
3
+ metadata.gz: 28934eb7317d49a31d36b7563e17536b0cb9ce375a7c92d4ef7102f2eb3f998f
4
+ data.tar.gz: f86564b713075d3762622329be0d96333cc6a8a5f7c1f9352a06f26d746c89d4
5
5
  SHA512:
6
- metadata.gz: 3c96a8dbd89bf163574a28c4d5d01f884a64d4f82f5f665c6322e1030fe33107976410d418478f997824fd2b1d9be4b568e34efa6dcd7c6963d5aa8a309b9be5
7
- data.tar.gz: c60515fe9eff88d86a9b5a3d8bd30617a56e33271e671d02a52737e369ee09bdf17a83ab7e9a378f4d7c21161e0e0bad6ee24340b50a952f65471a0208b5100a
6
+ metadata.gz: 21f814b2a44d75f89128e33fb067fa56c7f83fda3a5ca7938fc026108b95d6056d405cf38da15730d593756b1479cd297c6c5f66865eb85c8b5c5bbae2a4b23f
7
+ data.tar.gz: 3cc681f0cde118c45ebf0b07d240f70cb8690a4a4ed399421d1d07f6524fa1de7b214a3ca97a39950584c69bafe0b7166c8482ced38b065fc79441f3c72de83a
@@ -31,6 +31,12 @@ module UffizziCore::DependencyInjectionConcern
31
31
  module_class(:ingress_parser)
32
32
  end
33
33
 
34
+ def notification_module
35
+ return unless module_exists?(:notification_module)
36
+
37
+ module_class(:notification_module)
38
+ end
39
+
34
40
  private
35
41
 
36
42
  def module_exists?(module_name)
@@ -16,8 +16,6 @@ module UffizziCore::Concerns::Models::Account
16
16
  validates :kind, presence: true
17
17
  validates :domain, uniqueness: true, if: :domain
18
18
 
19
- belongs_to :owner, class_name: UffizziCore::User.name, foreign_key: :owner_id
20
-
21
19
  has_many :memberships, dependent: :destroy
22
20
  has_many :users, through: :memberships
23
21
  has_many :credentials, dependent: :destroy
@@ -47,7 +47,7 @@ module UffizziCore::Concerns::Models::Deployment
47
47
  transitions from: [:disabled], to: :active
48
48
  end
49
49
 
50
- event :fail, after: :after_fail do
50
+ event :fail do
51
51
  transitions from: [:active], to: :failed
52
52
  end
53
53
 
@@ -61,10 +61,6 @@ module UffizziCore::Concerns::Models::Deployment
61
61
  update!(disabled_at: Time.now)
62
62
  end
63
63
 
64
- def after_fail
65
- active_containers.each(&:disable!)
66
- end
67
-
68
64
  def clean
69
65
  active_containers.each(&:disable!)
70
66
  UffizziCore::Deployment::DeleteJob.perform_async(id)
@@ -2,4 +2,6 @@
2
2
 
3
3
  class UffizziCore::Account < UffizziCore::ApplicationRecord
4
4
  include UffizziCore::Concerns::Models::Account
5
+
6
+ belongs_to :owner, class_name: UffizziCore::User.name, foreign_key: :owner_id
5
7
  end
@@ -4,6 +4,8 @@ class UffizziCore::ActivityItemService
4
4
  COMPLETED_STATES = ['deployed', 'failed', 'cancelled'].freeze
5
5
 
6
6
  class << self
7
+ include UffizziCore::DependencyInjectionConcern
8
+
7
9
  def create_docker_item!(repo, container)
8
10
  activity_item_attributes = {
9
11
  namespace: repo.namespace,
@@ -27,8 +29,9 @@ class UffizziCore::ActivityItemService
27
29
 
28
30
  def fail_deployment!(activity_item)
29
31
  deployment = activity_item.container.deployment
32
+ last_event = activity_item.events.order_by_id.last
30
33
 
31
- activity_item.events.create(state: UffizziCore::Event.state.failed)
34
+ activity_item.events.create(state: UffizziCore::Event.state.failed) unless last_event&.failed?
32
35
 
33
36
  UffizziCore::DeploymentService.fail!(deployment)
34
37
  end
@@ -55,6 +58,11 @@ class UffizziCore::ActivityItemService
55
58
 
56
59
  activity_item.events.create(state: status) if last_event&.state != status
57
60
 
61
+ if failed?(status)
62
+ UffizziCore::ActivityItemService.fail_deployment!(activity_item)
63
+ notification_module.notify_about_failed_deployment(deployment) if notification_module.present?
64
+ end
65
+
58
66
  return unless [UffizziCore::Event.state.building, UffizziCore::Event.state.deploying].include?(status)
59
67
 
60
68
  UffizziCore::Deployment::ManageDeployActivityItemJob.perform_in(5.seconds, activity_item.id)
@@ -75,5 +83,9 @@ class UffizziCore::ActivityItemService
75
83
  last_event = activity_item.events.last
76
84
  COMPLETED_STATES.include?(last_event.state)
77
85
  end
86
+
87
+ def failed?(status)
88
+ status == UffizziCore::Event.state.failed
89
+ end
78
90
  end
79
91
  end
@@ -135,7 +135,7 @@ class UffizziCore::DeploymentService
135
135
  end
136
136
 
137
137
  def build_deployment_url(deployment)
138
- "#{Settings.app.managed_dns_zone}/projects/#{deployment.project_id}/deployments"
138
+ "#{Settings.app.host}/projects/#{deployment.project_id}/deployments"
139
139
  end
140
140
 
141
141
  def all_containers_have_unique_ports?(containers)
@@ -6,7 +6,7 @@ class UffizziCore::UserAccessService
6
6
  delegate :admin_access_to_account?, :developer_access_to_account?, :viewer_access_to_account?,
7
7
  :admin_or_developer_access_to_account?, :any_access_to_account?, :admin_access_to_project?,
8
8
  :developer_access_to_project?, :viewer_access_to_project?, :admin_or_developer_access_to_project?,
9
- :any_access_to_project?, :global_admin?, to: :@user_access_module
9
+ :any_access_to_project?, :global_admin?, :valid_token?, to: :@user_access_module
10
10
 
11
11
  def initialize(user_access_module)
12
12
  @user_access_module = user_access_module
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.0.13'
4
+ VERSION = '2.0.15'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-29 00:00:00.000000000 Z
12
+ date: 2022-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm