uffizzi_core 0.1.15 → 0.1.16
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/docker_hub_client/not_authorized_error.rb +6 -0
- data/app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb +6 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer/container_config_file_serializer/config_file_serializer.rb +2 -2
- data/app/services/uffizzi_core/compose_file/services_options_service.rb +10 -2
- data/app/services/uffizzi_core/deployment_service.rb +3 -14
- data/app/services/uffizzi_core/user_generator_service.rb +11 -5
- data/lib/tasks/uffizzi_core_tasks.rake +1 -1
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +3 -5
- data/app/lib/uffizzi_core/concerns/models/activity_item.rb +0 -39
- data/app/lib/uffizzi_core/concerns/models/credential.rb +0 -65
- data/app/lib/uffizzi_core/concerns/models/repo.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfa4de16cbd2efbc1c9b12748807a9c283e206a490eaa4cf544eaee9e5a11733
|
4
|
+
data.tar.gz: 8d3d6a27ed932c3760669f2397deef476b57c44ec09b783de51eca3143bb7aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db9e7b5f79bf19ac9576b516e72792b3a58ff98edccea36ef1f9a4385e214d7498d5c5dc047fb989cd1c958a8ec8be32ad39d0257ab57c8b264a6fef7b85d96
|
7
|
+
data.tar.gz: a1f4c8f5a39e04357a1e9185454230b7671dffdac46f180a23310ae07f0b906912cf10fcd252fdfd1d31c7553a3074d139d504d94a916f4b2219e174771be945
|
@@ -7,6 +7,12 @@ module UffizziCore::DependencyInjectionConcern
|
|
7
7
|
UffizziCore::UserAccessService.new(module_class(:rbac))
|
8
8
|
end
|
9
9
|
|
10
|
+
def build_parser_module
|
11
|
+
return unless module_exists?(:github)
|
12
|
+
|
13
|
+
module_class(:github).new
|
14
|
+
end
|
15
|
+
|
10
16
|
private
|
11
17
|
|
12
18
|
def module_exists?(module_name)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable
|
3
|
+
# rubocop:disable Layout/LineLength
|
4
4
|
class UffizziCore::Controller::DeployContainers::ContainerSerializer::ContainerConfigFileSerializer::ConfigFileSerializer < UffizziCore::BaseSerializer
|
5
|
-
# rubocop:enable
|
5
|
+
# rubocop:enable Layout/LineLength
|
6
6
|
|
7
7
|
attributes :id, :filename, :kind, :payload
|
8
8
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
class UffizziCore::ComposeFile::ServicesOptionsService
|
4
4
|
class << self
|
5
|
+
include UffizziCore::DependencyInjectionConcern
|
6
|
+
|
5
7
|
def parse(services, global_configs_data, global_secrets_data, compose_payload)
|
6
8
|
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.no_services') if services.nil? || services.keys.empty?
|
7
9
|
|
@@ -18,7 +20,7 @@ class UffizziCore::ComposeFile::ServicesOptionsService
|
|
18
20
|
|
19
21
|
private
|
20
22
|
|
21
|
-
def prepare_service_data(service_name, service_data, global_configs_data, global_secrets_data,
|
23
|
+
def prepare_service_data(service_name, service_data, global_configs_data, global_secrets_data, compose_payload)
|
22
24
|
options_data = {}
|
23
25
|
service_data.each_pair do |key, value|
|
24
26
|
service_key = key.to_sym
|
@@ -27,7 +29,7 @@ class UffizziCore::ComposeFile::ServicesOptionsService
|
|
27
29
|
when :image
|
28
30
|
UffizziCore::ComposeFile::ServicesOptions::ImageService.parse(value)
|
29
31
|
when :build
|
30
|
-
|
32
|
+
check_and_parse_build_option(value, compose_payload)
|
31
33
|
when :env_file
|
32
34
|
UffizziCore::ComposeFile::ServicesOptions::EnvFileService.parse(value)
|
33
35
|
when :environment
|
@@ -51,5 +53,11 @@ class UffizziCore::ComposeFile::ServicesOptionsService
|
|
51
53
|
|
52
54
|
options_data
|
53
55
|
end
|
56
|
+
|
57
|
+
def check_and_parse_build_option(value, compose_payload)
|
58
|
+
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.not_implemented', option: :build) unless build_parser_module
|
59
|
+
|
60
|
+
build_parser_module.parse(value, compose_payload)
|
61
|
+
end
|
54
62
|
end
|
55
63
|
end
|
@@ -104,9 +104,8 @@ module UffizziCore::DeploymentService
|
|
104
104
|
pull_request_payload = continuous_preview_payload['pull_request']
|
105
105
|
repo_name = pull_request_payload['repository_full_name'].split('/').last
|
106
106
|
deployment_name = name(deployment)
|
107
|
-
subdomain = "pr#{pull_request_payload['id']}-#{deployment_name}-#{repo_name}-#{project.slug}"
|
108
107
|
|
109
|
-
|
108
|
+
"pr#{pull_request_payload['id']}-#{deployment_name}.#{repo_name}.#{project.slug}"
|
110
109
|
end
|
111
110
|
|
112
111
|
def build_docker_continuous_preview_subdomain(deployment)
|
@@ -116,17 +115,14 @@ module UffizziCore::DeploymentService
|
|
116
115
|
repo_name = docker_payload['image'].split('/').last.gsub('_', '-')
|
117
116
|
image_tag = docker_payload['tag'].gsub('_', '-')
|
118
117
|
deployment_name = name(deployment)
|
119
|
-
subdomain = "#{image_tag}-#{deployment_name}-#{repo_name}-#{project.slug}"
|
120
118
|
|
121
|
-
|
119
|
+
"#{image_tag}-#{deployment_name}.#{repo_name}.#{project.slug}"
|
122
120
|
end
|
123
121
|
|
124
122
|
def build_default_subdomain(deployment)
|
125
123
|
deployment_name = name(deployment)
|
126
124
|
slug = deployment.project.slug.to_s
|
127
|
-
|
128
|
-
|
129
|
-
format_subdomain(subdomain)
|
125
|
+
"#{deployment_name}.#{slug}"
|
130
126
|
end
|
131
127
|
|
132
128
|
def build_preview_url(deployment)
|
@@ -297,12 +293,5 @@ module UffizziCore::DeploymentService
|
|
297
293
|
container.variables.push(*envs)
|
298
294
|
end
|
299
295
|
end
|
300
|
-
|
301
|
-
def format_subdomain(full_subdomain_name)
|
302
|
-
subdomain_length_limit = Settings.deployment.subdomain.length_limit
|
303
|
-
return full_subdomain_name if full_subdomain_name.length <= subdomain_length_limit
|
304
|
-
|
305
|
-
full_subdomain_name.slice(0, subdomain_length_limit)
|
306
|
-
end
|
307
296
|
end
|
308
297
|
end
|
@@ -6,6 +6,12 @@ class UffizziCore::UserGeneratorService
|
|
6
6
|
DEFAULT_ACCOUNT_NAME = 'default'
|
7
7
|
|
8
8
|
class << self
|
9
|
+
def safe_generate(email, password, project_name)
|
10
|
+
generate(email, password, project_name)
|
11
|
+
rescue ActiveRecord::RecordInvalid => e
|
12
|
+
puts e.message
|
13
|
+
end
|
14
|
+
|
9
15
|
def generate(email, password, project_name)
|
10
16
|
user_attributes = build_user_attributes(email, password)
|
11
17
|
project_attributes = build_project_attributes(project_name)
|
@@ -31,19 +37,17 @@ class UffizziCore::UserGeneratorService
|
|
31
37
|
|
32
38
|
if email.present?
|
33
39
|
user_attributes[:email] = email
|
34
|
-
|
40
|
+
elsif IO::console.present?
|
35
41
|
IO::console.write("Enter User Email (default: #{DEFAULT_USER_EMAIL}): ")
|
36
42
|
user_attributes[:email] = IO::console.gets.strip.presence || DEFAULT_USER_EMAIL
|
37
43
|
end
|
38
44
|
|
39
45
|
user_attributes[:password] = if password.present?
|
40
46
|
password
|
41
|
-
|
47
|
+
elsif IO::console.present?
|
42
48
|
IO::console.getpass('Enter Password: ')
|
43
49
|
end
|
44
50
|
|
45
|
-
abort('password can\'t be blank') if user_attributes[:password].blank?
|
46
|
-
|
47
51
|
user_attributes
|
48
52
|
end
|
49
53
|
|
@@ -53,9 +57,11 @@ class UffizziCore::UserGeneratorService
|
|
53
57
|
}
|
54
58
|
if project_name.present?
|
55
59
|
project_attributes[:name] = project_name
|
56
|
-
|
60
|
+
elsif IO::console.present?
|
57
61
|
IO::console.write("Enter Project Name (default: #{DEFAULT_PROJECT_NAME}): ")
|
58
62
|
project_attributes[:name] = IO::console.gets.strip.presence || DEFAULT_PROJECT_NAME
|
63
|
+
else
|
64
|
+
project_attributes[:name] = DEFAULT_PROJECT_NAME
|
59
65
|
end
|
60
66
|
|
61
67
|
project_attributes[:slug] = prepare_project_slug(project_attributes[:name])
|
@@ -14,6 +14,6 @@ namespace :uffizzi_core do
|
|
14
14
|
|
15
15
|
desc 'Create a new user'
|
16
16
|
task create_user: :environment do
|
17
|
-
UffizziCore::UserGeneratorService.
|
17
|
+
UffizziCore::UserGeneratorService.safe_generate(ENV['UFFIZZI_USER_EMAIL'], ENV['UFFIZZI_USER_PASSWORD'], ENV['UFFIZZI_PROJECT_NAME'])
|
18
18
|
end
|
19
19
|
end
|
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: 0.1.
|
4
|
+
version: 0.1.16
|
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-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -693,6 +693,7 @@ files:
|
|
693
693
|
- app/clients/uffizzi_core/controller_client.rb
|
694
694
|
- app/clients/uffizzi_core/controller_client/request_result.rb
|
695
695
|
- app/clients/uffizzi_core/docker_hub_client.rb
|
696
|
+
- app/clients/uffizzi_core/docker_hub_client/not_authorized_error.rb
|
696
697
|
- app/clients/uffizzi_core/docker_hub_client/request_result.rb
|
697
698
|
- app/clients/uffizzi_core/github_container_registry_client.rb
|
698
699
|
- app/clients/uffizzi_core/github_container_registry_client/request_result.rb
|
@@ -758,9 +759,6 @@ files:
|
|
758
759
|
- app/jobs/uffizzi_core/deployment/delete_job.rb
|
759
760
|
- app/jobs/uffizzi_core/deployment/deploy_containers_job.rb
|
760
761
|
- app/jobs/uffizzi_core/deployment/manage_deploy_activity_item_job.rb
|
761
|
-
- app/lib/uffizzi_core/concerns/models/activity_item.rb
|
762
|
-
- app/lib/uffizzi_core/concerns/models/credential.rb
|
763
|
-
- app/lib/uffizzi_core/concerns/models/repo.rb
|
764
762
|
- app/lib/uffizzi_core/rbac/user_access_service.rb
|
765
763
|
- app/mailers/uffizzi_core/application_mailer.rb
|
766
764
|
- app/models/concerns/uffizzi_core/hashid_concern.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UffizziCore::Concerns::Models::ActivityItem
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
include UffizziCore::ActivityItemRepo
|
8
|
-
|
9
|
-
self.table_name = UffizziCore.table_names[:activity_items]
|
10
|
-
|
11
|
-
belongs_to :deployment
|
12
|
-
belongs_to :container
|
13
|
-
belongs_to :build, optional: true
|
14
|
-
|
15
|
-
has_many :events, dependent: :destroy
|
16
|
-
|
17
|
-
scope :docker, -> {
|
18
|
-
where(type: UffizziCore::ActivityItem::Docker.name)
|
19
|
-
}
|
20
|
-
|
21
|
-
scope :github, -> {
|
22
|
-
where(type: UffizziCore::ActivityItem::Github.name)
|
23
|
-
}
|
24
|
-
|
25
|
-
def docker?
|
26
|
-
type == UffizziCore::ActivityItem::Docker.name
|
27
|
-
end
|
28
|
-
|
29
|
-
def image
|
30
|
-
[namespace, name].compact.join('/')
|
31
|
-
end
|
32
|
-
|
33
|
-
def full_image
|
34
|
-
return "#{image}:#{tag}" if docker?
|
35
|
-
|
36
|
-
''
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UffizziCore::Concerns::Models::Credential
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
include AASM
|
8
|
-
include UffizziCore::CredentialRepo
|
9
|
-
|
10
|
-
self.table_name = UffizziCore.table_names[:credentials]
|
11
|
-
|
12
|
-
belongs_to :account
|
13
|
-
|
14
|
-
before_destroy :remove_token
|
15
|
-
|
16
|
-
validates :registry_url, presence: true
|
17
|
-
|
18
|
-
aasm :state, column: :state do
|
19
|
-
state :not_connected, initial: true
|
20
|
-
state :active
|
21
|
-
state :unauthorized
|
22
|
-
|
23
|
-
event :activate do
|
24
|
-
transitions from: [:not_connected, :unauthorized], to: :active
|
25
|
-
end
|
26
|
-
|
27
|
-
event :unauthorize do
|
28
|
-
transitions from: [:not_connected, :active], to: :unauthorized
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def github_container_registry?
|
33
|
-
type == UffizziCore::Credential::GithubContainerRegistry.name
|
34
|
-
end
|
35
|
-
|
36
|
-
def docker_hub?
|
37
|
-
type == UffizziCore::Credential::DockerHub.name
|
38
|
-
end
|
39
|
-
|
40
|
-
def azure?
|
41
|
-
type == UffizziCore::Credential::Azure.name
|
42
|
-
end
|
43
|
-
|
44
|
-
def google?
|
45
|
-
type == UffizziCore::Credential::Google.name
|
46
|
-
end
|
47
|
-
|
48
|
-
def amazon?
|
49
|
-
type == UffizziCore::Credential::Amazon.name
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def remove_token
|
55
|
-
account.projects.find_each do |project|
|
56
|
-
project.deployments.find_each do |deployment|
|
57
|
-
containers = deployment.containers
|
58
|
-
attributes = { continuously_deploy: UffizziCore::Container::STATE_DISABLED }
|
59
|
-
|
60
|
-
containers.with_docker_hub_repo.update_all(attributes) if docker_hub?
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UffizziCore::Concerns::Models::Repo
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
extend Enumerize
|
8
|
-
include UffizziCore::RepoRepo
|
9
|
-
|
10
|
-
self.table_name = UffizziCore.table_names[:repos]
|
11
|
-
|
12
|
-
enumerize :kind, in: [:buildpacks18, :dockerfile, :dotnet, :gatsby, :barestatic], predicates: true
|
13
|
-
|
14
|
-
belongs_to :project
|
15
|
-
has_one :container, inverse_of: :repo, dependent: :destroy
|
16
|
-
has_many :builds, dependent: :destroy
|
17
|
-
|
18
|
-
validates :dockerfile_path, presence: true, if: :dockerfile?
|
19
|
-
validates :delete_preview_after, numericality: { greater_than: 0, only_integer: true }, allow_nil: true
|
20
|
-
|
21
|
-
def docker_hub?
|
22
|
-
type == UffizziCore::Repo::DockerHub.name
|
23
|
-
end
|
24
|
-
|
25
|
-
def azure?
|
26
|
-
type == UffizziCore::Repo::Azure.name
|
27
|
-
end
|
28
|
-
|
29
|
-
def google?
|
30
|
-
type == UffizziCore::Repo::Google.name
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|