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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70847fae8bc28249be5879f8496e7436e05079077dc23ad53394d08676158be6
4
- data.tar.gz: 2ac3e45d651e069f5e11b69b022efa285c5f0c0f176fb5a17c0bc58c3d4dad88
3
+ metadata.gz: 065d0c7c4ecaca71f48ed176e3a433a379908220e7923be4604165d2d6760fe7
4
+ data.tar.gz: e79876e64df2b71896f0a34e40a7c1caf06b788914171a40e35b5feda33674d2
5
5
  SHA512:
6
- metadata.gz: c128f0afe2384d0763597a9bbc3977748282a454a7d6396680b6f6642f00aa3b6ea32ee0d6c1125846338fec29e8ec02a0bf135d16943a3a2f3ff1f7caf5e797
7
- data.tar.gz: 8a0877404587daa608bb636f6500c03578d711ab7cb8e58db97ed9cb663114374cef6f8a619f6dbc9a5c0c0ac3fe4478bf559f53df1c3b6f266d3820f7661f3c
6
+ metadata.gz: 1415234d2f29321aae904e5467a41108b44f5beb8291e6510a60dc58f72597a535e00a0a1a98d6208844717b7ca0b2c53fe6560a163983583a7ab60cc382d4dc
7
+ data.tar.gz: c1aea1bd41f011ad430ddd2c5af76d48518a2e4f099cb33615a4f81462a6cfee7777eeb80fef4607263cc403ed93580142db0166779002aa8272910da3d39f0d
@@ -82,6 +82,10 @@ class UffizziCore::ControllerClient
82
82
  patch("/namespaces/#{namespace}/cluster/#{name}", body)
83
83
  end
84
84
 
85
+ def ingresses(namespace:)
86
+ get("/namespaces/#{namespace}/ingresses")
87
+ end
88
+
85
89
  private
86
90
 
87
91
  def get(url, params = {})
@@ -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
@@ -21,5 +21,9 @@ module UffizziCore::Rbac::UserAccessService
21
21
  def any_access_to_project?(_user, _project)
22
22
  true
23
23
  end
24
+
25
+ def admin_access_to_project?(_user, _project)
26
+ true
27
+ end
24
28
  end
25
29
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.2.25'
4
+ VERSION = '2.3.0'
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.2.25
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-19 00:00:00.000000000 Z
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