uffizzi_core 0.3.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb +6 -0
- data/app/jobs/uffizzi_core/config_file/apply_job.rb +2 -2
- data/app/lib/uffizzi_core/concerns/models/deployment.rb +5 -0
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer/deployment_serializer.rb +0 -4
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb +0 -4
- data/app/services/uffizzi_core/controller_service.rb +7 -1
- data/app/services/uffizzi_core/deployment_service.rb +4 -2
- data/app/services/uffizzi_core/docker_hub_service.rb +6 -6
- data/db/migrate/20220704135629_add_disabled_at_to_deployments.rb +16 -0
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34e197de1424923114ad82fd43fa818b4841058bd0681e3320c4ba4e2352c452
|
4
|
+
data.tar.gz: 4b94e04a11bcef28b4fc732fbf0c0d2f51a6512b609fbbc8cbe9b52d2123fd4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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::
|
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::
|
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
|
@@ -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:
|
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.
|
53
|
-
@client = UffizziCore::DockerHubClient.new(credential)
|
52
|
+
return @client if @client&.credential&.username == credential.username
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
data/lib/uffizzi_core/version.rb
CHANGED
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.
|
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-
|
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
|