uffizzi_core 2.1.0 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c131ada77fc0357b6617553f51247c1b9194635a3b741b6f17b6ac901921c3ff
4
- data.tar.gz: 30a013a396f81d5cbfb13932222dbd020fd3b88e94511119266970114ae9d0d8
3
+ metadata.gz: 50974b21b408b32cfa4a51906d55860f0aa15e9b449a08a90ec408b3ea11a471
4
+ data.tar.gz: 899cef8ae2a7935c479ad73aade6d044588ad604c632b29be6c9a8a6185805d4
5
5
  SHA512:
6
- metadata.gz: 0060c147865cb0bf5f530159e5022dee28b5994d6a20a3b67d235482e1a398fa93228029a44ae22e31fea0c241f723c48f9a51c0597dd4c1b5db62f22083088d
7
- data.tar.gz: 91fb0c6c8dc3e3fc8fd1e85ea0de05e0a43597f5c89090f8789bb1c57fb93efcad2bdbb959c4c005179d7d4db959f9da45822a73eb65f1379773492fa885f785
6
+ metadata.gz: 41408ab5b2dee546872ff3d6a1d8f4c341edb62fc5b1822951ee3237158293e4cd4283b4d326e33878566c521f609409a34a8b3ed376f2e9604f908e8bd71248
7
+ data.tar.gz: 7d52b81047dfbf542f914d15bfd896d45e2c95f763cff9fd40f7f7e70356f30df77dc064b2705e778981858e856992cd16b4dcb261119a7e85cca948ccb4f802
@@ -37,6 +37,12 @@ module UffizziCore::DependencyInjectionConcern
37
37
  module_class(:notification_module)
38
38
  end
39
39
 
40
+ def deployment_module
41
+ return unless module_exists?(:deployment_module)
42
+
43
+ module_class(:deployment_module)
44
+ end
45
+
40
46
  private
41
47
 
42
48
  def module_exists?(module_name)
@@ -18,7 +18,6 @@ module UffizziCore::Concerns::Models::Template
18
18
  enumerize :creation_source, in: [:manual, :compose_file, :system], predicates: true, scope: true
19
19
 
20
20
  validates :name, presence: true
21
- validates :name, uniqueness: { scope: :project }, if: -> { compose_file.blank? || compose_file.kind.main? }
22
21
 
23
22
  def valid_containers_memory_limit?
24
23
  containers_attributes = payload['containers_attributes']
@@ -19,6 +19,7 @@ module UffizziCore::Concerns::Models::User
19
19
  has_many :accounts, through: :memberships
20
20
  has_many :user_projects, dependent: :destroy
21
21
  has_many :projects, through: :user_projects
22
+ has_many :deployments, class_name: UffizziCore::Deployment.name, foreign_key: :deployed_by_id, dependent: :nullify
22
23
 
23
24
  has_one_attached :avatar
24
25
 
@@ -32,14 +33,6 @@ module UffizziCore::Concerns::Models::User
32
33
  accounts.find_by(kind: UffizziCore::Account.kind.personal)
33
34
  end
34
35
 
35
- def active_projects
36
- projects.active
37
- end
38
-
39
- def deployments
40
- UffizziCore::Deployment.where(project_id: active_projects)
41
- end
42
-
43
36
  def full_name
44
37
  "#{first_name} #{last_name}"
45
38
  end
@@ -99,7 +99,7 @@ class UffizziCore::DeploymentService
99
99
  end
100
100
 
101
101
  def build_pull_request_subdomain(deployment)
102
- repo_name, pull_request_number = pull_request_data(deployment)
102
+ _, repo_name, pull_request_number = pull_request_data(deployment)
103
103
  raise UffizziCore::Deployment::LabelsNotFoundError if repo_name.nil? || pull_request_number.nil?
104
104
 
105
105
  formatted_repo_name = format_url_safe(repo_name.split('/').last.downcase)
@@ -276,6 +276,9 @@ class UffizziCore::DeploymentService
276
276
  envs.push('name' => 'UFFIZZI_URL', 'value' => "https://#{deployment.preview_url}")
277
277
  envs.push('name' => 'UFFIZZI_DOMAIN', 'value' => deployment.preview_url)
278
278
 
279
+ preview_url = "https://#{deployment_module.build_preview_url(deployment)}" if deployment_module.present?
280
+ envs.push('name' => 'UFFIZZI_PREDICTABLE_URL', 'value' => preview_url || '')
281
+
279
282
  container.variables = [] if container.variables.nil?
280
283
 
281
284
  container.variables.push(*envs)
@@ -304,13 +307,13 @@ class UffizziCore::DeploymentService
304
307
  def github_pull_request_data(deployment)
305
308
  github_data = deployment.metadata.dig('labels', 'github')
306
309
 
307
- [github_data['repository'], github_data.dig('event', 'number')]
310
+ [:github, github_data['repository'], github_data.dig('event', 'number')]
308
311
  end
309
312
 
310
313
  def gitlab_merge_request_data(deployment)
311
314
  gitlab_data = deployment.metadata.dig('labels', 'gitlab')
312
315
 
313
- [gitlab_data['repo'], gitlab_data.dig('merge_request', 'number')]
316
+ [:gitlab, gitlab_data['repo'], gitlab_data.dig('merge_request', 'number')]
314
317
  end
315
318
 
316
319
  def format_url_safe(name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.2'
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.1.0
4
+ version: 2.1.2
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: 2023-01-30 00:00:00.000000000 Z
12
+ date: 2023-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm