uffizzi_core 2.2.25 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/clients/uffizzi_core/controller_client.rb +4 -0
- data/app/contexts/uffizzi_core/project/cluster_context.rb +13 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/clusters/application_controller.rb +29 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/clusters/ingresses_controller.rb +17 -0
- data/app/lib/uffizzi_core/rbac/user_access_service.rb +4 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/clusters/ingresses_policy.rb +9 -0
- data/app/services/uffizzi_core/cluster_service.rb +4 -0
- data/app/services/uffizzi_core/controller_service.rb +10 -0
- data/config/routes.rb +3 -0
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 065d0c7c4ecaca71f48ed176e3a433a379908220e7923be4604165d2d6760fe7
|
4
|
+
data.tar.gz: e79876e64df2b71896f0a34e40a7c1caf06b788914171a40e35b5feda33674d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1415234d2f29321aae904e5467a41108b44f5beb8291e6510a60dc58f72597a535e00a0a1a98d6208844717b7ca0b2c53fe6560a163983583a7ab60cc382d4dc
|
7
|
+
data.tar.gz: c1aea1bd41f011ad430ddd2c5af76d48518a2e4f099cb33615a4f81462a6cfee7777eeb80fef4607263cc403ed93580142db0166779002aa8272910da3d39f0d
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Project::ClusterContext
|
4
|
+
attr_reader :user, :user_access_module, :project, :cluster, :params
|
5
|
+
|
6
|
+
def initialize(user, project, user_access_module, cluster, params)
|
7
|
+
@user = user
|
8
|
+
@user_access_module = user_access_module
|
9
|
+
@project = project
|
10
|
+
@cluster = cluster
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Api::Cli::V1::Projects::Clusters::ApplicationController < UffizziCore::Api::Cli::V1::Projects::ApplicationController
|
4
|
+
def resource_cluster
|
5
|
+
@resource_cluster ||= if request_by_admin? || valid_request_from_ci_workflow?
|
6
|
+
active_project_clusters.find_by!(name: params[:cluster_name])
|
7
|
+
else
|
8
|
+
active_project_clusters.deployed_by_user(current_user).find_by!(name: params[:cluster_name])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def active_project_clusters
|
15
|
+
@active_project_clusters ||= resource_project.clusters.enabled
|
16
|
+
end
|
17
|
+
|
18
|
+
def request_by_admin?
|
19
|
+
current_user.admin_access_to_project?(resource_project)
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid_request_from_ci_workflow?
|
23
|
+
ci_module.valid_request_from_ci_workflow?(params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def policy_context
|
27
|
+
UffizziCore::Project::ClusterContext.new(current_user, resource_project, user_access_module, resource_cluster, params)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Api::Cli::V1::Projects::Clusters::IngressesController <
|
4
|
+
UffizziCore::Api::Cli::V1::Projects::Clusters::ApplicationController
|
5
|
+
before_action :authorize_uffizzi_core_api_cli_v1_projects_clusters_ingresses
|
6
|
+
|
7
|
+
def index
|
8
|
+
hosts = UffizziCore::ControllerService.ingress_hosts(resource_cluster)
|
9
|
+
user_hosts = UffizziCore::ClusterService.filter_user_ingress_host(resource_cluster, hosts)
|
10
|
+
|
11
|
+
data = {
|
12
|
+
ingresses: user_hosts,
|
13
|
+
}
|
14
|
+
|
15
|
+
respond_with data
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Api::Cli::V1::Projects::Clusters::IngressesPolicy < UffizziCore::ApplicationPolicy
|
4
|
+
def index?
|
5
|
+
return true if context.user_access_module.admin_access_to_project?(context.user, context.project)
|
6
|
+
|
7
|
+
context.cluster.deployed_by_id == context.user.id
|
8
|
+
end
|
9
|
+
end
|
@@ -68,6 +68,10 @@ class UffizziCore::ClusterService
|
|
68
68
|
UffizziCore::Cluster::ManageDeployingJob.perform_in(5.seconds, cluster.id, ++try)
|
69
69
|
end
|
70
70
|
|
71
|
+
def filter_user_ingress_host(cluster, ingress_hosts)
|
72
|
+
ingress_hosts.reject { |h| h == cluster.host }
|
73
|
+
end
|
74
|
+
|
71
75
|
private
|
72
76
|
|
73
77
|
def awake?(cluster)
|
@@ -117,6 +117,16 @@ class UffizziCore::ControllerService
|
|
117
117
|
controller_client(cluster).patch_cluster(name: cluster.name, namespace: cluster.namespace, body: body)
|
118
118
|
end
|
119
119
|
|
120
|
+
def ingress_hosts(cluster)
|
121
|
+
namespace = cluster.namespace
|
122
|
+
|
123
|
+
ingresses = controller_client(cluster).ingresses(namespace: namespace).result.items
|
124
|
+
|
125
|
+
ingresses.map do |ingress|
|
126
|
+
ingress.spec.rules.map(&:host)
|
127
|
+
end.flatten
|
128
|
+
end
|
129
|
+
|
120
130
|
private
|
121
131
|
|
122
132
|
def check_any_container_has_public_port(containers)
|
data/config/routes.rb
CHANGED
@@ -15,6 +15,9 @@ UffizziCore::Engine.routes.draw do
|
|
15
15
|
put :scale_down
|
16
16
|
put :scale_up
|
17
17
|
end
|
18
|
+
scope module: :clusters do
|
19
|
+
resources :ingresses, only: ['index']
|
20
|
+
end
|
18
21
|
end
|
19
22
|
resources :deployments, only: ['index', 'show', 'create', 'destroy', 'update'] do
|
20
23
|
post :deploy_containers, on: :member
|
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: 2.
|
4
|
+
version: 2.3.0
|
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-10-
|
12
|
+
date: 2023-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -774,6 +774,7 @@ files:
|
|
774
774
|
- app/clients/uffizzi_core/google_registry_client/request_result.rb
|
775
775
|
- app/contexts/uffizzi_core/account_context.rb
|
776
776
|
- app/contexts/uffizzi_core/base_context.rb
|
777
|
+
- app/contexts/uffizzi_core/project/cluster_context.rb
|
777
778
|
- app/contexts/uffizzi_core/project_context.rb
|
778
779
|
- app/contexts/uffizzi_core/webhooks_context.rb
|
779
780
|
- app/controller_modules/uffizzi_core/api/cli/v1/projects/clusters_controller_module.rb
|
@@ -791,6 +792,8 @@ files:
|
|
791
792
|
- app/controllers/uffizzi_core/api/cli/v1/ci/application_controller.rb
|
792
793
|
- app/controllers/uffizzi_core/api/cli/v1/ci/sessions_controller.rb
|
793
794
|
- app/controllers/uffizzi_core/api/cli/v1/projects/application_controller.rb
|
795
|
+
- app/controllers/uffizzi_core/api/cli/v1/projects/clusters/application_controller.rb
|
796
|
+
- app/controllers/uffizzi_core/api/cli/v1/projects/clusters/ingresses_controller.rb
|
794
797
|
- app/controllers/uffizzi_core/api/cli/v1/projects/clusters_controller.rb
|
795
798
|
- app/controllers/uffizzi_core/api/cli/v1/projects/compose_files_controller.rb
|
796
799
|
- app/controllers/uffizzi_core/api/cli/v1/projects/deployments/activity_items_controller.rb
|
@@ -936,6 +939,7 @@ files:
|
|
936
939
|
- app/policies/uffizzi_core/api/cli/v1/accounts/credentials_policy.rb
|
937
940
|
- app/policies/uffizzi_core/api/cli/v1/accounts/projects_policy.rb
|
938
941
|
- app/policies/uffizzi_core/api/cli/v1/accounts_policy.rb
|
942
|
+
- app/policies/uffizzi_core/api/cli/v1/projects/clusters/ingresses_policy.rb
|
939
943
|
- app/policies/uffizzi_core/api/cli/v1/projects/clusters_policy.rb
|
940
944
|
- app/policies/uffizzi_core/api/cli/v1/projects/compose_files_policy.rb
|
941
945
|
- app/policies/uffizzi_core/api/cli/v1/projects/deployments/activity_items_policy.rb
|