uffizzi_core 1.1.2 → 2.0.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: 2edcfc13672bd0bca6949f51c036ddd4fb30b09f911c309a149141ad2b3d645d
4
- data.tar.gz: 4747f7a5566cf82e782af3622aa7a8568dc61c8549805da8676ccf0dcd4c78a5
3
+ metadata.gz: a39e41ef8a1ef0300ac30d802f223c0c99c8f771591569401ba7f8835bcfb095
4
+ data.tar.gz: f3cb1e26f85f2751d7076234719d12a325eacab01ed4db85a6f7da8872442eb2
5
5
  SHA512:
6
- metadata.gz: 33f214f8203c262c402d3f081e7d3e609f2b0e3fb42168e2cfb050e92cb654cfc9d233267593c2defae5bd8365ca613f556cfcb8167413666fd84bf33e45e7af
7
- data.tar.gz: 34aa0ad85bd4450a1b4249e93cb588b2ef370c5538943d2878bfdd749dce97b90ffbe4cc1a4b775c41a28a4bd1ae6ce096bb3426ce71f23aa1579889f84566d7
6
+ metadata.gz: 62647e990dd6c5c449993a851d69b2f72e4d8d391ccb5d24bdffd62a16e76f1784f1d2e0e75838b74a320166d12ac560011cce8d7fe28fcf3414e7910853b854
7
+ data.tar.gz: cd2d7b36a7d231e6d090e29abced6c2617f0b950de0f9491e93d05e268c147102af90e6190e7cced76fe1678ec5f4dfbdd9242698c1eddb8bfb7ee07af8e1028
@@ -17,11 +17,8 @@ class UffizziCore::Api::Cli::V1::Accounts::ProjectsController < UffizziCore::Api
17
17
 
18
18
  def create
19
19
  project_form = UffizziCore::Api::Cli::V1::Project::CreateForm.new(project_params)
20
- project_form.account = current_user.organizational_account
21
-
22
- if project_form.save
23
- UffizziCore::ProjectService.add_users_to_project!(project_form, current_user)
24
- end
20
+ project_form.account = current_user.accounts.find(params[:account_id])
21
+ UffizziCore::ProjectService.add_users_to_project!(project_form, project_form.account) if project_form.save
25
22
 
26
23
  respond_with project_form
27
24
  end
@@ -53,7 +53,7 @@ class UffizziCore::Api::Cli::V1::ProjectsController < UffizziCore::Api::Cli::V1:
53
53
  end
54
54
 
55
55
  def policy_context
56
- account = resource_project&.account || current_user.organizational_account
56
+ account = resource_project&.account || current_user.default_account
57
57
 
58
58
  UffizziCore::AccountContext.new(current_user, user_access_module, account, params)
59
59
  end
@@ -17,7 +17,7 @@ class UffizziCore::Api::Cli::V1::Account::Credential::CreateForm < UffizziCore::
17
17
  end
18
18
 
19
19
  def check_credential_correctness
20
- errors.add(:username, :incorrect) unless UffizziCore::CredentialService.correct_credentials?(self)
20
+ errors.add(:username, :incorrect, type: type.text) unless UffizziCore::CredentialService.correct_credentials?(self)
21
21
  end
22
22
 
23
23
  def credential_exists?
@@ -6,6 +6,7 @@ module UffizziCore::Concerns::Models::Account
6
6
  # rubocop:disable Metrics/BlockLength
7
7
  included do
8
8
  include AASM
9
+ include UffizziCore::AccountRepo
9
10
  include UffizziCore::StateMachineConcern
10
11
  extend Enumerize
11
12
 
@@ -3,12 +3,26 @@
3
3
  module UffizziCore::Concerns::Models::Credential
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ # rubocop:disable Metrics/BlockLength
6
7
  included do
7
8
  include AASM
8
9
  include UffizziCore::CredentialRepo
10
+ extend Enumerize
9
11
 
10
12
  self.table_name = UffizziCore.table_names[:credentials]
11
13
 
14
+ const_set(:CREDENTIAL_TYPES, [
15
+ UffizziCore::Credential::Amazon.name,
16
+ UffizziCore::Credential::Azure.name,
17
+ UffizziCore::Credential::DockerHub.name,
18
+ UffizziCore::Credential::DockerRegistry.name,
19
+ UffizziCore::Credential::GithubContainerRegistry.name,
20
+ UffizziCore::Credential::Google.name,
21
+ ])
22
+
23
+ enumerize :type,
24
+ in: self::CREDENTIAL_TYPES, i18n_scope: ['enumerize.credential.type']
25
+
12
26
  belongs_to :account
13
27
 
14
28
  before_destroy :remove_token
@@ -70,4 +84,5 @@ module UffizziCore::Concerns::Models::Credential
70
84
  end
71
85
  end
72
86
  end
87
+ # rubocop:enable Metrics/BlockLength
73
88
  end
@@ -24,8 +24,12 @@ module UffizziCore::Concerns::Models::User
24
24
 
25
25
  enumerize :creation_source, in: UffizziCore.user_creation_sources, predicates: true
26
26
 
27
- def organizational_account
28
- accounts.find_by(kind: UffizziCore::Account.kind.organizational)
27
+ def default_account
28
+ personal_account
29
+ end
30
+
31
+ def personal_account
32
+ accounts.find_by(kind: UffizziCore::Account.kind.personal)
29
33
  end
30
34
 
31
35
  def active_projects
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UffizziCore::AccountRepo
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ scope :by_kind, ->(kind) { where(kind: kind) }
8
+ scope :personal, -> { by_kind(UffizziCore::Account.kind.personal) }
9
+ end
10
+ end
@@ -36,11 +36,9 @@ class UffizziCore::ProjectService
36
36
  UffizziCore::ComposeFile::ErrorsService.update_compose_errors!(compose_file, new_errors, compose_file.content)
37
37
  end
38
38
 
39
- def add_users_to_project!(project, current_user)
40
- user_projects = []
41
-
42
- current_user.organizational_account.memberships.where(role: UffizziCore::Membership.role.admin).map do |membership|
43
- user_projects << { project: project, user: membership.user, role: UffizziCore::UserProject.role.admin }
39
+ def add_users_to_project!(project, account)
40
+ user_projects = account.memberships.where(role: UffizziCore::Membership.role.admin).map do |membership|
41
+ { project: project, user: membership.user, role: UffizziCore::UserProject.role.admin }
44
42
  end
45
43
 
46
44
  UffizziCore::UserProject.create!(user_projects)
@@ -73,7 +73,7 @@ class UffizziCore::UserGeneratorService
73
73
  owner: user,
74
74
  name: DEFAULT_ACCOUNT_NAME,
75
75
  state: UffizziCore::Account::STATE_ACTIVE,
76
- kind: UffizziCore::Account.kind.organizational,
76
+ kind: UffizziCore::Account.kind.personal,
77
77
  }
78
78
  end
79
79
 
@@ -13,14 +13,14 @@ en:
13
13
  password:
14
14
  password_blank: Password/Access Token can't be blank
15
15
  username:
16
- incorrect: We were unable to log you in to docker registry. Please verify that your username and password are correct.
16
+ incorrect: "We were unable to log you into %{type}. Please verify that your username and password are correct."
17
17
  type:
18
18
  exist: Credential of that type already exist.
19
19
  uffizzi_core/deployment:
20
20
  attributes:
21
21
  containers:
22
- max_memory_limit_error: 'Memory limit of containers must be less than %{max}'
23
- max_memory_request_error: 'Memory request of containers must be less than %{max}'
22
+ max_memory_limit_error: "Memory limit of containers must be less than %{max}"
23
+ max_memory_request_error: "Memory request of containers must be less than %{max}"
24
24
  uffizzi_core/user:
25
25
  attributes:
26
26
  email:
@@ -76,3 +76,12 @@ en:
76
76
  session:
77
77
  unsupported_login_type: This type of login is not supported
78
78
  unauthorized: Unauthorized
79
+ enumerize:
80
+ credential:
81
+ type:
82
+ "UffizziCore::Credential::GithubContainerRegistry": "Github Container Registry"
83
+ "UffizziCore::Credential::DockerHub": "DockerHub"
84
+ "UffizziCore::Credential::DockerRegistry": "Docker Registry"
85
+ "UffizziCore::Credential::Azure": "Azure"
86
+ "UffizziCore::Credential::Google": "Google"
87
+ "UffizziCore::Credential::Amazon": "Amazon"
data/db/seeds.rb CHANGED
@@ -9,7 +9,7 @@ user = UffizziCore::User.create!(
9
9
  account = UffizziCore::Account.create!(
10
10
  owner: user, name: 'default',
11
11
  state: UffizziCore::Account::STATE_ACTIVE,
12
- kind: UffizziCore::Account.kind.organizational
12
+ kind: UffizziCore::Account.kind.personal
13
13
  )
14
14
  user.memberships.create!(account: account, role: UffizziCore::Membership.role.admin)
15
15
  project = account.projects.create!(name: 'default', slug: 'default', state: UffizziCore::Project::STATE_ACTIVE)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '1.1.2'
4
+ VERSION = '2.0.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: 1.1.2
4
+ version: 2.0.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: 2022-09-27 00:00:00.000000000 Z
12
+ date: 2022-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -862,6 +862,7 @@ files:
862
862
  - app/policies/uffizzi_core/api/cli/v1/projects/secrets_policy.rb
863
863
  - app/policies/uffizzi_core/api/cli/v1/projects_policy.rb
864
864
  - app/policies/uffizzi_core/application_policy.rb
865
+ - app/repositories/uffizzi_core/account_repo.rb
865
866
  - app/repositories/uffizzi_core/activity_item_repo.rb
866
867
  - app/repositories/uffizzi_core/basic_order_repo.rb
867
868
  - app/repositories/uffizzi_core/build_repo.rb