uffizzi_core 0.3.1 → 0.3.4

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: 3e2b2cafe23575e7c21cd2108009cf69b9f96684929648f20aabdfe15f4f174b
4
- data.tar.gz: 48501037f9780aaede4255937497fe7a4e62ff74eaeebf5d35f38324c74bccd3
3
+ metadata.gz: 34e197de1424923114ad82fd43fa818b4841058bd0681e3320c4ba4e2352c452
4
+ data.tar.gz: 4b94e04a11bcef28b4fc732fbf0c0d2f51a6512b609fbbc8cbe9b52d2123fd4f
5
5
  SHA512:
6
- metadata.gz: 53784fee926eda545a859338847377dbbffdbfe45b81ab1beb8a461dddb9d9d87393f6a29d936f0b96dc7b33e45db1019b3ca14f4d89cc06b31054d5bace04c3
7
- data.tar.gz: 1c29d8d4c7077f640dfe253faa7ef2c3417db14745ecff19d749fd4daa3743e6c626c670eb4a40e00d78a932c206e766d7bdd45eed04e799d51b917d8289e5fa
6
+ metadata.gz: 97b2382ee4af9787273b595d1d8840332c51dba8d861cc7752a773137ab1e2639129219ad361ef1f752e5cc88e3a3524b142c84fca22e4076f4da273c461e8ae
7
+ data.tar.gz: 195a8f935b0866004c1e6a0a7beb9b42f613042d36f66f2331f19bb86c5c8bb67df5f190d8a42ab5d97c42ddb9fb51685d9082e5370e8edc3fcf51cf872e9e11
@@ -13,6 +13,12 @@ module UffizziCore::DependencyInjectionConcern
13
13
  module_class(:github)
14
14
  end
15
15
 
16
+ def password_protection_module
17
+ return unless module_exists?(:password_protection)
18
+
19
+ module_class(:password_protection)
20
+ end
21
+
16
22
  private
17
23
 
18
24
  def module_exists?(module_name)
@@ -5,7 +5,7 @@ class UffizziCore::ConfigFile::ApplyJob < UffizziCore::ApplicationJob
5
5
 
6
6
  sidekiq_retry_in do |count, exception|
7
7
  case exception
8
- when UffizziCore::ControllerService::DeploymentNotFoundError
8
+ when UffizziCore::DeploymentNotFoundError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS ApplyJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
10
  Settings.controller.resource_create_retry_time
11
11
  end
@@ -22,7 +22,7 @@ class UffizziCore::ConfigFile::ApplyJob < UffizziCore::ApplicationJob
22
22
  end
23
23
 
24
24
  unless UffizziCore::ControllerService.deployment_exists?(deployment)
25
- raise UffizziCore::ControllerService::DeploymentNotFoundError,
25
+ raise UffizziCore::DeploymentNotFoundError,
26
26
  deployment_id
27
27
  end
28
28
 
@@ -57,6 +57,7 @@ module UffizziCore::Concerns::Models::Deployment
57
57
 
58
58
  def after_disable
59
59
  clean
60
+ update!(disabled_at: Time.now)
60
61
  end
61
62
 
62
63
  def after_fail
@@ -67,5 +68,9 @@ module UffizziCore::Concerns::Models::Deployment
67
68
  active_containers.each(&:disable!)
68
69
  UffizziCore::Deployment::DeleteJob.perform_async(id)
69
70
  end
71
+
72
+ def preview_url
73
+ "#{subdomain}.#{Settings.app.managed_dns_zone}"
74
+ end
70
75
  end
71
76
  end
@@ -6,8 +6,4 @@ class UffizziCore::Api::Cli::V1::ProjectSerializer::DeploymentSerializer < Uffiz
6
6
  attributes :id,
7
7
  :preview_url,
8
8
  :state
9
-
10
- def preview_url
11
- UffizziCore::DeploymentService.build_preview_url(object)
12
- end
13
9
  end
@@ -30,10 +30,6 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer < UffizziCore::B
30
30
  object.containers.active
31
31
  end
32
32
 
33
- def preview_url
34
- UffizziCore::DeploymentService.build_preview_url(object)
35
- end
36
-
37
33
  def tag
38
34
  object.ingress_container&.tag
39
35
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  class UffizziCore::ControllerService
4
4
  class << self
5
+ include UffizziCore::DependencyInjectionConcern
6
+
5
7
  def apply_config_file(deployment, config_file)
6
8
  body = {
7
9
  config_file: UffizziCore::Controller::ApplyConfigFile::ConfigFileSerializer.new(config_file).as_json,
@@ -50,9 +52,13 @@ class UffizziCore::ControllerService
50
52
  body = {
51
53
  containers: containers,
52
54
  credentials: credentials,
53
- deployment_url: UffizziCore::DeploymentService.build_preview_url(deployment),
55
+ deployment_url: deployment.preview_url,
54
56
  }
55
57
 
58
+ if password_protection_module.present?
59
+ body = password_protection_module.add_password_configuration(body, deployment.project_id)
60
+ end
61
+
56
62
  controller_client.deploy_containers(deployment_id: deployment.id, body: body)
57
63
  end
58
64
 
@@ -62,7 +62,7 @@ class UffizziCore::DeploymentService
62
62
  Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} start deploying into controller")
63
63
 
64
64
  containers = deployment.active_containers
65
- containers = add_default_deployment_variables!(containers)
65
+ containers = add_default_deployment_variables!(containers, deployment)
66
66
 
67
67
  UffizziCore::ControllerService.deploy_containers(deployment, containers)
68
68
  else
@@ -284,13 +284,15 @@ class UffizziCore::DeploymentService
284
284
  Digest::SHA256.hexdigest("#{container.id}:#{container.image}")[0, 10]
285
285
  end
286
286
 
287
- def add_default_deployment_variables!(containers)
287
+ def add_default_deployment_variables!(containers, deployment)
288
288
  containers.each do |container|
289
289
  envs = []
290
290
  if container.port.present? && !UffizziCore::ContainerService.defines_env?(container, 'PORT')
291
291
  envs.push('name' => 'PORT', 'value' => container.target_port.to_s)
292
292
  end
293
293
 
294
+ envs.push('name' => 'UFFIZZI_URL', 'value' => "https://#{deployment.preview_url}")
295
+
294
296
  container.variables = [] if container.variables.nil?
295
297
 
296
298
  container.variables.push(*envs)
@@ -49,13 +49,13 @@ class UffizziCore::DockerHubService
49
49
  end
50
50
 
51
51
  def user_client(credential)
52
- if @client.nil?
53
- @client = UffizziCore::DockerHubClient.new(credential)
52
+ return @client if @client&.credential&.username == credential.username
54
53
 
55
- unless @client.authentificated?
56
- Rails.logger.warn("broken credentials, DockerHubService credential_id=#{credential.id}")
57
- credential.unauthorize! unless credential.unauthorized?
58
- end
54
+ @client = UffizziCore::DockerHubClient.new(credential)
55
+
56
+ unless @client.authentificated?
57
+ Rails.logger.warn("broken credentials, DockerHubService credential_id=#{credential.id}")
58
+ credential.unauthorize! unless credential.unauthorized?
59
59
  end
60
60
 
61
61
  @client
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDisabledAtToDeployments < ActiveRecord::Migration[6.1]
4
+ def up
5
+ change_table :uffizzi_core_deployments do |t|
6
+ t.datetime :disabled_at
7
+ end
8
+ UffizziCore::Deployment.disabled.update_all('disabled_at = updated_at')
9
+ end
10
+
11
+ def down
12
+ change_table :uffizzi_core_deployments do |t|
13
+ t.remove :disabled_at
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.4'
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: 0.3.1
4
+ version: 0.3.4
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-07-18 00:00:00.000000000 Z
12
+ date: 2022-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -957,6 +957,7 @@ files:
957
957
  - db/migrate/20220419074956_add_health_check_to_containers.rb
958
958
  - db/migrate/20220422151523_add_volumes_to_uffizzi_core_containers.rb
959
959
  - db/migrate/20220525113412_rename_name_to_uffizzi_containers.rb
960
+ - db/migrate/20220704135629_add_disabled_at_to_deployments.rb
960
961
  - db/seeds.rb
961
962
  - lib/tasks/uffizzi_core_tasks.rake
962
963
  - lib/uffizzi_core.rb