uffizzi_core 2.2.16 → 2.2.18

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: 7aeb2490e838cc774c8abea9c3fcba1264d367916b16326844e42e7c95c33b99
4
- data.tar.gz: 511f4027d656c51f96043f15c427fcf7fa9e47b199446dc33415fa35e51e734c
3
+ metadata.gz: ac821f837d64d420f64d0820763c1936a5729e58949aec8b7806f5ed6aa30805
4
+ data.tar.gz: 7b47949da56f4d7416d17ec4e628d0104cbdbd210db37c7a4d25802e96a2614e
5
5
  SHA512:
6
- metadata.gz: '0950a88eeea3a7f949777d8f759d9d784e46dbf9e0650dd50aa2db38682967c2adb1e6b1eba626e1220c61eb86075a8ec50379b89f0427ba83d732dda99cc91e'
7
- data.tar.gz: d9e10ef11020d139d03e8091e7def3951a73f5ad849bb9df1c3422522613bbb42c03b404ed29acbb5707bd293040c9928ec0dc6a2b9cac4d2dbc5c4d19a89019
6
+ metadata.gz: ceeec356d175119ca83f7da7642ab5607788fefd180a97d0dbbbcc40466e7668de0a70b9982053809b5c701499993648bf13c29a078ce1278e950d6e0931442d
7
+ data.tar.gz: 4c924c77d4201c61548797f2273b5325caec1bdddb9e89eb5f5bc9cafbcdc3173387e38cb825113a5cc1708f30e9f51ac82343f36d987167f502992968b98589
@@ -27,6 +27,12 @@ module UffizziCore::DependencyInjectionConcern
27
27
  module_class(:volume_parser)
28
28
  end
29
29
 
30
+ def ci_module
31
+ return unless module_exists?(:ci_module)
32
+
33
+ module_class(:ci_module)
34
+ end
35
+
30
36
  def ci_session
31
37
  return unless module_exists?(:ci_session)
32
38
 
@@ -73,12 +79,6 @@ module UffizziCore::DependencyInjectionConcern
73
79
  module_class(:controller_settings)
74
80
  end
75
81
 
76
- def ci_module
77
- return unless module_exists?(:ci_module)
78
-
79
- module_class(:ci_module)
80
- end
81
-
82
82
  private
83
83
 
84
84
  def module_exists?(module_name)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Accounts::ClustersController < UffizziCore::Api::Cli::V1::Accounts::ApplicationController
4
+ include UffizziCore::DependencyInjectionConcern
5
+ before_action :authorize_uffizzi_core_api_cli_v1_accounts_clusters
6
+
7
+ def index
8
+ return respond_with(clusters_by_account.includes(:project)) if valid_request_from_ci_workflow?
9
+
10
+ clusters = clusters_by_user.or(clusters_by_admin_projects)
11
+ respond_with(clusters.includes(:project))
12
+ end
13
+
14
+ private
15
+
16
+ def valid_request_from_ci_workflow?
17
+ ci_module.valid_request_from_ci_workflow?(params)
18
+ end
19
+
20
+ def clusters_by_admin_projects
21
+ projects = UffizziCore::Project
22
+ .active
23
+ .joins(:user_projects)
24
+ .where(account: resource_account)
25
+ .where(user_projects: { role: UffizziCore::UserProject.role.admin, user: current_user })
26
+
27
+ UffizziCore::Cluster.enabled.where(project_id: projects.select(:id))
28
+ end
29
+
30
+ def clusters_by_user
31
+ UffizziCore::Cluster.enabled.by_projects(account_projects).deployed_by_user(current_user)
32
+ end
33
+
34
+ def clusters_by_account
35
+ UffizziCore::Cluster.enabled.by_projects(account_projects)
36
+ end
37
+
38
+ def account_projects
39
+ UffizziCore::Project.active.where(account: resource_account)
40
+ end
41
+ end
@@ -4,7 +4,7 @@ module UffizziCore::Concerns::Models::Cluster
4
4
  extend ActiveSupport::Concern
5
5
  include UffizziCore::ClusterRepo
6
6
 
7
- NAMESPACE_PREFIX = 'cluster'
7
+ NAMESPACE_PREFIX = 'c'
8
8
 
9
9
  included do
10
10
  include AASM
@@ -55,7 +55,7 @@ module UffizziCore::Concerns::Models::Cluster
55
55
  end
56
56
 
57
57
  def namespace
58
- [NAMESPACE_PREFIX, id].join('-')
58
+ [NAMESPACE_PREFIX, id].join
59
59
  end
60
60
  end
61
61
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Accounts::ClustersPolicy < UffizziCore::ApplicationPolicy
4
+ def index?
5
+ context.user_access_module.any_access_to_account?(context.user, context.account)
6
+ end
7
+ end
@@ -7,5 +7,6 @@ module UffizziCore::ClusterRepo
7
7
  scope :deployed, -> { where(state: UffizziCore::Cluster::STATE_DEPLOYED) }
8
8
  scope :enabled, -> { where.not(state: UffizziCore::Cluster::STATE_DISABLED) }
9
9
  scope :deployed_by_user, ->(user) { where(deployed_by: user) }
10
+ scope :by_projects, ->(projects) { where(project_id: projects.select(:id)) }
10
11
  end
11
12
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Accounts::ClusterSerializer::ProjectSerializer < UffizziCore::BaseSerializer
4
+ type :project
5
+
6
+ attributes :name
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Accounts::ClusterSerializer < UffizziCore::BaseSerializer
4
+ type :cluster
5
+
6
+ belongs_to :project
7
+
8
+ attributes :name
9
+ end
data/config/routes.rb CHANGED
@@ -47,6 +47,7 @@ UffizziCore::Engine.routes.draw do
47
47
  resources :accounts, only: ['index'] do
48
48
  scope module: :accounts do
49
49
  resources :projects, only: ['index', 'create']
50
+ resources :clusters, only: ['index']
50
51
  resources :credentials, only: ['index', 'create', 'update', 'destroy'], param: :type do
51
52
  member do
52
53
  get :check_credential
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.2.16'
4
+ VERSION = '2.2.18'
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.16
4
+ version: 2.2.18
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-21 00:00:00.000000000 Z
12
+ date: 2023-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -783,6 +783,7 @@ files:
783
783
  - app/controllers/concerns/uffizzi_core/authorization_concern.rb
784
784
  - app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb
785
785
  - app/controllers/uffizzi_core/api/cli/v1/accounts/application_controller.rb
786
+ - app/controllers/uffizzi_core/api/cli/v1/accounts/clusters_controller.rb
786
787
  - app/controllers/uffizzi_core/api/cli/v1/accounts/credentials_controller.rb
787
788
  - app/controllers/uffizzi_core/api/cli/v1/accounts/projects_controller.rb
788
789
  - app/controllers/uffizzi_core/api/cli/v1/accounts_controller.rb
@@ -926,6 +927,7 @@ files:
926
927
  - app/models/uffizzi_core/template.rb
927
928
  - app/models/uffizzi_core/user.rb
928
929
  - app/models/uffizzi_core/user_project.rb
930
+ - app/policies/uffizzi_core/api/cli/v1/accounts/clusters_policy.rb
929
931
  - app/policies/uffizzi_core/api/cli/v1/accounts/credentials_policy.rb
930
932
  - app/policies/uffizzi_core/api/cli/v1/accounts/projects_policy.rb
931
933
  - app/policies/uffizzi_core/api/cli/v1/accounts_policy.rb
@@ -960,6 +962,8 @@ files:
960
962
  - app/repositories/uffizzi_core/user_repo.rb
961
963
  - app/responders/uffizzi_core/json_responder.rb
962
964
  - app/serializers/uffizzi_core/api/cli/v1/account_serializer.rb
965
+ - app/serializers/uffizzi_core/api/cli/v1/accounts/cluster_serializer.rb
966
+ - app/serializers/uffizzi_core/api/cli/v1/accounts/cluster_serializer/project_serializer.rb
963
967
  - app/serializers/uffizzi_core/api/cli/v1/accounts/credential_serializer.rb
964
968
  - app/serializers/uffizzi_core/api/cli/v1/accounts/project_serializer.rb
965
969
  - app/serializers/uffizzi_core/api/cli/v1/project_serializer.rb