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 +4 -4
- data/app/controllers/uffizzi_core/api/cli/v1/accounts/projects_controller.rb +2 -5
- data/app/controllers/uffizzi_core/api/cli/v1/projects_controller.rb +1 -1
- data/app/forms/uffizzi_core/api/cli/v1/account/credential/create_form.rb +1 -1
- data/app/lib/uffizzi_core/concerns/models/account.rb +1 -0
- data/app/lib/uffizzi_core/concerns/models/credential.rb +15 -0
- data/app/lib/uffizzi_core/concerns/models/user.rb +6 -2
- data/app/repositories/uffizzi_core/account_repo.rb +10 -0
- data/app/services/uffizzi_core/project_service.rb +3 -5
- data/app/services/uffizzi_core/user_generator_service.rb +1 -1
- data/config/locales/en.activerecord.yml +3 -3
- data/config/locales/en.yml +9 -0
- data/db/seeds.rb +1 -1
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a39e41ef8a1ef0300ac30d802f223c0c99c8f771591569401ba7f8835bcfb095
|
4
|
+
data.tar.gz: f3cb1e26f85f2751d7076234719d12a325eacab01ed4db85a6f7da8872442eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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?
|
@@ -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
|
28
|
-
|
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
|
@@ -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,
|
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)
|
@@ -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
|
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:
|
23
|
-
max_memory_request_error:
|
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:
|
data/config/locales/en.yml
CHANGED
@@ -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.
|
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)
|
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:
|
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-
|
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
|