uffizzi_core 2.2.9 → 2.2.11
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/controllers/uffizzi_core/api/cli/v1/projects/clusters_controller.rb +16 -2
- data/app/jobs/uffizzi_core/cluster/delete_job.rb +3 -1
- data/app/jobs/uffizzi_core/cluster/deploy_job.rb +1 -1
- data/app/jobs/uffizzi_core/cluster/manage_deploying_job.rb +1 -1
- data/app/jobs/uffizzi_core/deployment/delete_job.rb +3 -1
- data/app/lib/uffizzi_core/concerns/models/container.rb +1 -5
- data/app/lib/uffizzi_core/concerns/models/user.rb +1 -1
- data/app/repositories/uffizzi_core/cluster_repo.rb +1 -0
- data/app/services/uffizzi_core/ci_service.rb +9 -0
- data/app/services/uffizzi_core/controller_service.rb +21 -0
- data/lib/uffizzi_core/version.rb +1 -1
- data/lib/uffizzi_core.rb +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a82783f7a27772ccc8463248c092baa337c91359746d13300b0399e282e7ce
|
4
|
+
data.tar.gz: 0af9485af9df35f0ac7b3e253ec7463cc0b1d7c0303eca45bb341310b80e7d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cca634776180b812c88a671ac5267019d067d713a41b1445381355e4f8ebc3b9aa14a52820e304682e8c33c75977b2ea10849e353edaf4d2232429576e574045
|
7
|
+
data.tar.gz: ff7118194e445877ca4d8d8d42ef2844977a40e60f91ee51ad181e8f0c5bb3a139d666adecb78acdcbb64e10b628ad7a9cdd846ea9af9ef2d83dd9f4e30d2c2a
|
@@ -9,8 +9,9 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersController < UffizziCore::Api
|
|
9
9
|
|
10
10
|
def index
|
11
11
|
clusters = resource_project.clusters.enabled
|
12
|
+
return respond_with clusters if request_by_admin? || valid_request_from_ci_workflow?
|
12
13
|
|
13
|
-
respond_with clusters
|
14
|
+
respond_with clusters.deployed_by_user(current_user)
|
14
15
|
end
|
15
16
|
|
16
17
|
def create
|
@@ -37,7 +38,20 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersController < UffizziCore::Api
|
|
37
38
|
private
|
38
39
|
|
39
40
|
def resource_cluster
|
40
|
-
|
41
|
+
active_project_clusters = resource_project.clusters.enabled
|
42
|
+
@resource_cluster ||= if request_by_admin? || valid_request_from_ci_workflow?
|
43
|
+
active_project_clusters.find_by!(name: params[:name])
|
44
|
+
else
|
45
|
+
active_project_clusters.deployed_by_user(current_user).find_by!(name: params[:name])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def request_by_admin?
|
50
|
+
current_user.admin_access_to_project?(resource_project)
|
51
|
+
end
|
52
|
+
|
53
|
+
def valid_request_from_ci_workflow?
|
54
|
+
ci_module.valid_request_from_ci_workflow?(params)
|
41
55
|
end
|
42
56
|
|
43
57
|
def cluster_params
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Cluster::DeleteJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :
|
4
|
+
sidekiq_options queue: :clusters,
|
5
|
+
lock: :until_executed,
|
6
|
+
retry: Settings.default_job_retry_count
|
5
7
|
|
6
8
|
def perform(id)
|
7
9
|
Rails.logger.info("DEPLOYMENT_PROCESS cluster_id=#{id} DeleteJob")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Cluster::DeployJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :
|
4
|
+
sidekiq_options queue: :clusters, retry: Settings.default_job_retry_count
|
5
5
|
|
6
6
|
def perform(id)
|
7
7
|
cluster = UffizziCore::Cluster.find(id)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Cluster::ManageDeployingJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :
|
4
|
+
sidekiq_options queue: :clusters, retry: Settings.default_job_retry_count
|
5
5
|
|
6
6
|
def perform(id, try = 1)
|
7
7
|
cluster = UffizziCore::Cluster.find(id)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Deployment::DeleteJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :
|
4
|
+
sidekiq_options queue: :disable_deployments,
|
5
|
+
lock: :until_executed,
|
6
|
+
retry: Settings.default_job_retry_count
|
5
7
|
|
6
8
|
def perform(id)
|
7
9
|
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} DeleteJob")
|
@@ -61,7 +61,7 @@ module UffizziCore::Concerns::Models::Container
|
|
61
61
|
transitions from: [:disabled], to: :active
|
62
62
|
end
|
63
63
|
|
64
|
-
event :disable
|
64
|
+
event :disable do
|
65
65
|
transitions from: [:active], to: :disabled
|
66
66
|
end
|
67
67
|
end
|
@@ -76,10 +76,6 @@ module UffizziCore::Concerns::Models::Container
|
|
76
76
|
public && active?
|
77
77
|
end
|
78
78
|
|
79
|
-
def clean
|
80
|
-
update(public: false, port: nil)
|
81
|
-
end
|
82
|
-
|
83
79
|
def set_defaults
|
84
80
|
update_target_port_value
|
85
81
|
end
|
@@ -53,7 +53,7 @@ module UffizziCore::Concerns::Models::User
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def admin_access_to_project?(project)
|
56
|
-
|
56
|
+
project.user_projects.where(user_id: id, role: UffizziCore::UserProject.role.admin).exists?
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -6,5 +6,6 @@ module UffizziCore::ClusterRepo
|
|
6
6
|
included do
|
7
7
|
scope :deployed, -> { where(state: UffizziCore::Cluster::STATE_DEPLOYED) }
|
8
8
|
scope :enabled, -> { where.not(state: UffizziCore::Cluster::STATE_DISABLED) }
|
9
|
+
scope :deployed_by_user, ->(user) { where(deployed_by: user) }
|
9
10
|
end
|
10
11
|
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::ControllerService
|
4
|
+
class InvalidPublicPort < StandardError
|
5
|
+
def initialize(containers)
|
6
|
+
msg = "Deployment with ID #{containers.first.deployment.id} does not have any public port"
|
7
|
+
|
8
|
+
super(msg)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
class << self
|
5
13
|
include UffizziCore::DependencyInjectionConcern
|
6
14
|
|
@@ -28,6 +36,10 @@ class UffizziCore::ControllerService
|
|
28
36
|
end
|
29
37
|
|
30
38
|
def deploy_containers(deployment, containers)
|
39
|
+
check_any_container_has_public_port(containers) do |exists|
|
40
|
+
UffizziCore::DeploymentService.disable!(deployment) unless exists
|
41
|
+
end
|
42
|
+
|
31
43
|
containers = containers.map do |container|
|
32
44
|
UffizziCore::Controller::DeployContainers::ContainerSerializer.new(container).as_json(include: '**')
|
33
45
|
end
|
@@ -100,6 +112,15 @@ class UffizziCore::ControllerService
|
|
100
112
|
|
101
113
|
private
|
102
114
|
|
115
|
+
def check_any_container_has_public_port(containers)
|
116
|
+
exists = containers.any? { |c| c.port.present? && c.public }
|
117
|
+
yield(exists) if block_given?
|
118
|
+
|
119
|
+
return if exists
|
120
|
+
|
121
|
+
raise InvalidPublicPort.new(containers)
|
122
|
+
end
|
123
|
+
|
103
124
|
def request_events(deployment)
|
104
125
|
controller_client(deployment).deployment_containers_events(deployment_id: deployment.id)
|
105
126
|
end
|
data/lib/uffizzi_core/version.rb
CHANGED
data/lib/uffizzi_core.rb
CHANGED
@@ -33,6 +33,7 @@ module UffizziCore
|
|
33
33
|
deployment_memory_module: 'UffizziCore::Deployment::MemoryService',
|
34
34
|
template_memory_module: 'UffizziCore::Template::MemoryService',
|
35
35
|
controller_settings: 'UffizziCore::ControllerSettingsService',
|
36
|
+
ci_module: 'UffizziCore::CiService',
|
36
37
|
}
|
37
38
|
mattr_accessor :table_names, default: {
|
38
39
|
accounts: :uffizzi_core_accounts,
|
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.2.
|
4
|
+
version: 2.2.11
|
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-08-
|
12
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -423,6 +423,20 @@ dependencies:
|
|
423
423
|
- - ">="
|
424
424
|
- !ruby/object:Gem::Version
|
425
425
|
version: '0'
|
426
|
+
- !ruby/object:Gem::Dependency
|
427
|
+
name: sidekiq-unique-jobs
|
428
|
+
requirement: !ruby/object:Gem::Requirement
|
429
|
+
requirements:
|
430
|
+
- - ">="
|
431
|
+
- !ruby/object:Gem::Version
|
432
|
+
version: '0'
|
433
|
+
type: :runtime
|
434
|
+
prerelease: false
|
435
|
+
version_requirements: !ruby/object:Gem::Requirement
|
436
|
+
requirements:
|
437
|
+
- - ">="
|
438
|
+
- !ruby/object:Gem::Version
|
439
|
+
version: '0'
|
426
440
|
- !ruby/object:Gem::Dependency
|
427
441
|
name: swagger_yard
|
428
442
|
requirement: !ruby/object:Gem::Requirement
|
@@ -981,6 +995,7 @@ files:
|
|
981
995
|
- app/serializers/uffizzi_core/controller/deploy_containers/host_volume_file_serializer.rb
|
982
996
|
- app/services/uffizzi_core/account_service.rb
|
983
997
|
- app/services/uffizzi_core/activity_item_service.rb
|
998
|
+
- app/services/uffizzi_core/ci_service.rb
|
984
999
|
- app/services/uffizzi_core/cluster_service.rb
|
985
1000
|
- app/services/uffizzi_core/compose_file/builders/container_builder_service.rb
|
986
1001
|
- app/services/uffizzi_core/compose_file/builders/container_config_files_builder_service.rb
|