uffizzi_core 0.1.12 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb +3 -3
- data/app/controllers/uffizzi_core/api/cli/v1/projects_controller.rb +1 -12
- data/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +0 -1
- data/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb +1 -1
- data/app/lib/uffizzi_core/rbac/user_access_service.rb +1 -21
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer.rb +5 -1
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/container_serializer.rb +1 -2
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer.rb +1 -1
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer.rb +1 -16
- data/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb +7 -11
- data/app/services/uffizzi_core/compose_file/services_options_service.rb +0 -2
- data/app/services/uffizzi_core/compose_file/template_service.rb +4 -4
- data/app/services/uffizzi_core/deployment_service.rb +2 -1
- data/app/services/uffizzi_core/manage_activity_items_service.rb +0 -8
- data/app/services/uffizzi_core/user_generator_service.rb +5 -11
- data/config/locales/en.yml +0 -1
- data/config/routes.rb +0 -10
- data/lib/tasks/uffizzi_core_tasks.rake +1 -1
- data/lib/uffizzi_core/version.rb +1 -1
- data/swagger/v1/swagger.json +13 -13
- metadata +2 -5
- data/app/services/uffizzi_core/compose_file/parsers/services/healthcheck_parser_service.rb +0 -73
- data/app/services/uffizzi_core/starter_template_service.rb +0 -200
- data/db/migrate/20220419074956_add_health_check_to_containers.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 398869abc38d2bc2416b1589de95feb828d73abdc34a388f74339fae083332d0
|
4
|
+
data.tar.gz: a58d996964d92dd95a0bd5e4ebffab62dd84eaafcc7580bf3462cc6a58ccee46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a70937d88e1d4733d113184b702f99226f5bee51dbed31cf8d8a9bbf2b2e93f8b702a68a72bf6fcb992f8493be910d0d1d18f0c2af90328bdda755a54405617e
|
7
|
+
data.tar.gz: cc53ee6c8d52ad74d732ea97996e84999e2f660e47b18d251695fa81f60010060955d6e9ef5e27fe7312d56faa329bf54243eb99138efa7a1e4a92907e6a8c98
|
data/README.md
CHANGED
@@ -15,6 +15,7 @@ class UffizziCore::Api::Cli::V1::Account::CredentialsController < UffizziCore::A
|
|
15
15
|
render json: { credentials: credentials }, status: :ok
|
16
16
|
end
|
17
17
|
|
18
|
+
# rubocop:disable Layout/LineLength
|
18
19
|
# Create account credential
|
19
20
|
#
|
20
21
|
# @path [POST] /api/cli/v1/account/credentials
|
@@ -24,9 +25,8 @@ class UffizziCore::Api::Cli::V1::Account::CredentialsController < UffizziCore::A
|
|
24
25
|
# @response [object<errors>] 422 Unprocessable entity
|
25
26
|
#
|
26
27
|
# @example
|
27
|
-
# type can be one of UffizziCore::Credential::Amazon, UffizziCore::Credential::Azure,
|
28
|
-
#
|
29
|
-
|
28
|
+
# type can be one of UffizziCore::Credential::Amazon, UffizziCore::Credential::Azure, UffizziCore::Credential::DockerHub, UffizziCore::Credential::Google, UffizziCore::Credential::GithubContainerRegistry
|
29
|
+
# rubocop:enable Layout/LineLength
|
30
30
|
def create
|
31
31
|
credential_form = UffizziCore::Api::Cli::V1::Account::Credential::CreateForm.new
|
32
32
|
credential_form.assign_attributes(credential_params)
|
@@ -45,18 +45,7 @@ class UffizziCore::Api::Cli::V1::ProjectsController < UffizziCore::Api::Cli::V1:
|
|
45
45
|
project_form.account = current_user.organizational_account
|
46
46
|
|
47
47
|
if project_form.save
|
48
|
-
|
49
|
-
user_projects = []
|
50
|
-
|
51
|
-
if current_membership.developer?
|
52
|
-
user_projects << { project: project_form, user: current_user, role: UffizziCore::UserProject.role.developer }
|
53
|
-
end
|
54
|
-
|
55
|
-
current_user.organizational_account.memberships.where(role: UffizziCore::Membership.role.admin).map do |membership|
|
56
|
-
user_projects << { project: project_form, user: membership.user, role: UffizziCore::UserProject.role.admin }
|
57
|
-
end
|
58
|
-
|
59
|
-
UffizziCore::UserProject.create!(user_projects)
|
48
|
+
UffizziCore::ProjectService.add_users_to_project!(project_form, current_user)
|
60
49
|
end
|
61
50
|
|
62
51
|
respond_with project_form
|
@@ -16,7 +16,6 @@ class UffizziCore::Api::Cli::V1::Deployment::CreateForm < UffizziCore::Deploymen
|
|
16
16
|
:command,
|
17
17
|
:receive_incoming_requests,
|
18
18
|
:continuously_deploy,
|
19
|
-
{ healthcheck: {} },
|
20
19
|
{ variables: [:name, :value],
|
21
20
|
secret_variables: [:name, :value],
|
22
21
|
repo_attributes: [
|
@@ -6,31 +6,11 @@ module UffizziCore::Rbac::UserAccessService
|
|
6
6
|
true
|
7
7
|
end
|
8
8
|
|
9
|
-
def developer_access_to_account?(_user, _account)
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
def viewer_access_to_account?(_user, _account)
|
14
|
-
true
|
15
|
-
end
|
16
|
-
|
17
|
-
def admin_or_developer_access_to_account?(_user, _account)
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
9
|
def any_access_to_account?(_user, _account)
|
22
10
|
true
|
23
11
|
end
|
24
12
|
|
25
|
-
def
|
26
|
-
true
|
27
|
-
end
|
28
|
-
|
29
|
-
def developer_access_to_project?(_user, _project)
|
30
|
-
true
|
31
|
-
end
|
32
|
-
|
33
|
-
def viewer_access_to_project?(_user, _project)
|
13
|
+
def admin_or_developer_access_to_account?(_user, _account)
|
34
14
|
true
|
35
15
|
end
|
36
16
|
|
@@ -17,7 +17,11 @@ class UffizziCore::Api::Cli::V1::ProjectSerializer < UffizziCore::BaseSerializer
|
|
17
17
|
|
18
18
|
def deployments
|
19
19
|
object.deployments.active.map do |deployment|
|
20
|
-
deployment.state = UffizziCore::DeploymentService.failed?(deployment)
|
20
|
+
deployment.state = if UffizziCore::DeploymentService.failed?(deployment)
|
21
|
+
UffizziCore::Deployment::STATE_FAILED
|
22
|
+
else
|
23
|
+
UffizziCore::Deployment::STATE_ACTIVE
|
24
|
+
end
|
21
25
|
deployment
|
22
26
|
end
|
23
27
|
end
|
data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/container_serializer.rb
CHANGED
@@ -19,8 +19,7 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer::ContainerSerial
|
|
19
19
|
:public,
|
20
20
|
:repo_id,
|
21
21
|
:continuously_deploy,
|
22
|
-
:receive_incoming_requests
|
23
|
-
:healthcheck
|
22
|
+
:receive_incoming_requests
|
24
23
|
|
25
24
|
def secret_variables
|
26
25
|
return unless object.secret_variables.present?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Api::Cli::V1::Projects::Deployments::ContainerSerializer < UffizziCore::BaseSerializer
|
4
|
-
attributes :id, :name, :memory_limit, :memory_request, :continuously_deploy, :variables, :secret_variables
|
4
|
+
attributes :id, :name, :memory_limit, :memory_request, :continuously_deploy, :variables, :secret_variables
|
5
5
|
|
6
6
|
has_many :container_config_files
|
7
7
|
|
@@ -15,8 +15,7 @@ class UffizziCore::Controller::DeployContainers::ContainerSerializer < UffizziCo
|
|
15
15
|
:target_port,
|
16
16
|
:public,
|
17
17
|
:controller_name,
|
18
|
-
:receive_incoming_requests
|
19
|
-
:healthcheck
|
18
|
+
:receive_incoming_requests
|
20
19
|
|
21
20
|
has_many :container_config_files
|
22
21
|
|
@@ -53,18 +52,4 @@ class UffizziCore::Controller::DeployContainers::ContainerSerializer < UffizziCo
|
|
53
52
|
def command
|
54
53
|
object.command.blank? ? nil : JSON.parse(object.command)
|
55
54
|
end
|
56
|
-
|
57
|
-
def healthcheck
|
58
|
-
return {} if object.healthcheck.nil?
|
59
|
-
|
60
|
-
command = object.healthcheck['test']
|
61
|
-
new_command = if command.is_a?(Array)
|
62
|
-
items_to_remove = ['CMD', 'CMD-SHELL']
|
63
|
-
command.select { |item| items_to_remove.exclude?(item) }
|
64
|
-
elsif object.healthcheck['test'].is_a?(String)
|
65
|
-
command.split
|
66
|
-
end
|
67
|
-
|
68
|
-
object.healthcheck.merge(test: new_command)
|
69
|
-
end
|
70
55
|
end
|
@@ -17,14 +17,18 @@ class UffizziCore::ComposeFile::Builders::ContainerBuilderService
|
|
17
17
|
configs_data = container_data[:configs] || []
|
18
18
|
secrets = container_data[:secrets] || []
|
19
19
|
container_name = container_data[:container_name]
|
20
|
-
|
20
|
+
continuous_preview_container_data = container_data[:'x-uffizzi-continuous-preview'] || container_data[:'x-uffizzi-continuous-previews']
|
21
21
|
|
22
22
|
env_file_dependencies = UffizziCore::ComposeFile::GithubDependenciesService.env_file_dependencies_for_container(compose_dependencies,
|
23
23
|
container_name)
|
24
24
|
configs_dependencies = UffizziCore::ComposeFile::GithubDependenciesService.configs_dependencies_for_container(compose_dependencies,
|
25
25
|
container_name)
|
26
|
+
|
26
27
|
is_ingress = ingress_container?(container_name, ingress_data)
|
27
|
-
repo_attributes =
|
28
|
+
repo_attributes = build_repo_attributes(container_data, image_data, build_data, credentials)
|
29
|
+
|
30
|
+
repo_attributes = set_continuous_preview_attributes_to_repo(repo_attributes, continuous_preview_global_data.to_h,
|
31
|
+
continuous_preview_container_data.to_h)
|
28
32
|
|
29
33
|
{
|
30
34
|
tag: tag(image_data, repo_attributes),
|
@@ -47,13 +51,6 @@ class UffizziCore::ComposeFile::Builders::ContainerBuilderService
|
|
47
51
|
|
48
52
|
private
|
49
53
|
|
50
|
-
def repo_attributes(container_data, continuous_preview_global_data)
|
51
|
-
repo_attributes = build_repo_attributes(container_data)
|
52
|
-
continuous_preview_container_data = container_data[:'x-uffizzi-continuous-preview'] || container_data[:'x-uffizzi-continuous-previews']
|
53
|
-
|
54
|
-
set_continuous_preview_attributes_to_repo(repo_attributes, continuous_preview_global_data.to_h, continuous_preview_container_data.to_h)
|
55
|
-
end
|
56
|
-
|
57
54
|
def set_continuous_preview_attributes_to_repo(repo_attributes, global_data, container_data)
|
58
55
|
condition_attributes = [
|
59
56
|
:deploy_preview_when_pull_request_is_opened,
|
@@ -151,9 +148,8 @@ class UffizziCore::ComposeFile::Builders::ContainerBuilderService
|
|
151
148
|
memory_value
|
152
149
|
end
|
153
150
|
|
154
|
-
def build_repo_attributes(container_data)
|
151
|
+
def build_repo_attributes(container_data, image_data, _build_data, credentials)
|
155
152
|
repo_type = repo_type(container_data)
|
156
|
-
image_data = container_data[:image]
|
157
153
|
|
158
154
|
case repo_type
|
159
155
|
when UffizziCore::Repo::DockerHub.name
|
@@ -42,8 +42,6 @@ class UffizziCore::ComposeFile::ServicesOptionsService
|
|
42
42
|
UffizziCore::ComposeFile::ServicesOptions::EntrypointService.parse(value)
|
43
43
|
when :command
|
44
44
|
UffizziCore::ComposeFile::ServicesOptions::CommandService.parse(value)
|
45
|
-
when :healthcheck
|
46
|
-
UffizziCore::ComposeFile::Parsers::Services::HealthcheckParserService.parse(value)
|
47
45
|
when :'x-uffizzi-continuous-preview', :'x-uffizzi-continuous-previews'
|
48
46
|
UffizziCore::ComposeFile::ContinuousPreviewOptionsService.parse(value)
|
49
47
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::ComposeFile::TemplateService
|
4
|
-
def initialize(
|
4
|
+
def initialize(github_form, project, user)
|
5
5
|
@project = project
|
6
6
|
@user = user
|
7
|
-
@compose_dependencies =
|
8
|
-
@compose_data =
|
9
|
-
@compose_repositories =
|
7
|
+
@compose_dependencies = github_form.compose_dependencies
|
8
|
+
@compose_data = github_form.compose_data
|
9
|
+
@compose_repositories = github_form.compose_repositories
|
10
10
|
end
|
11
11
|
|
12
12
|
def create_template(compose_file_form)
|
@@ -14,6 +14,7 @@ module UffizziCore::DeploymentService
|
|
14
14
|
class << self
|
15
15
|
def create_from_compose(compose_file, project, user)
|
16
16
|
deployment_attributes = ActionController::Parameters.new(compose_file.template.payload)
|
17
|
+
|
17
18
|
deployment_form = UffizziCore::Api::Cli::V1::Deployment::CreateForm.new(deployment_attributes)
|
18
19
|
deployment_form.assign_dependences!(project, user)
|
19
20
|
deployment_form.compose_file = compose_file
|
@@ -246,7 +247,7 @@ module UffizziCore::DeploymentService
|
|
246
247
|
events = activity_items.map { |activity_item| activity_item.events.order_by_id.last&.state }
|
247
248
|
events = events.flatten.uniq
|
248
249
|
|
249
|
-
return DEPLOYMENT_PROCESS_STATUSES[:queued] if
|
250
|
+
return DEPLOYMENT_PROCESS_STATUSES[:queued] if events.empty?
|
250
251
|
return DEPLOYMENT_PROCESS_STATUSES[:failed] if events.include?(UffizziCore::Event.state.failed)
|
251
252
|
return DEPLOYMENT_PROCESS_STATUSES[:building] if events.include?(UffizziCore::Event.state.building)
|
252
253
|
|
@@ -116,26 +116,18 @@ class UffizziCore::ManageActivityItemsService
|
|
116
116
|
state = pod_container[:state][pod_container_status]
|
117
117
|
reason = state&.reason
|
118
118
|
|
119
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} pod_container_status: #{pod_container_status}")
|
120
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} state: #{state}")
|
121
|
-
ap(pod_container[:state])
|
122
|
-
|
123
119
|
case pod_container_status.to_sym
|
124
120
|
when :running
|
125
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} running")
|
126
121
|
UffizziCore::Event.state.deployed
|
127
122
|
when :terminated
|
128
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} terminated")
|
129
123
|
UffizziCore::Event.state.failed
|
130
124
|
when :waiting
|
131
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} waiting")
|
132
125
|
return UffizziCore::Event.state.failed if ['CrashLoopBackOff'].include?(reason)
|
133
126
|
|
134
127
|
raise UffizziCore::Deployment::ImagePullError, @deployment.id if ['ErrImagePull', 'ImagePullBackOff'].include?(reason)
|
135
128
|
|
136
129
|
UffizziCore::Event.state.deploying
|
137
130
|
else
|
138
|
-
Rails.logger.info("manage_activity_items get_status dep_id=#{container.deployment.id} else")
|
139
131
|
UffizziCore::Event.state.deploying
|
140
132
|
end
|
141
133
|
end
|
@@ -6,12 +6,6 @@ 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 StandardError => e
|
12
|
-
puts e.message
|
13
|
-
end
|
14
|
-
|
15
9
|
def generate(email, password, project_name)
|
16
10
|
user_attributes = build_user_attributes(email, password)
|
17
11
|
project_attributes = build_project_attributes(project_name)
|
@@ -37,17 +31,19 @@ class UffizziCore::UserGeneratorService
|
|
37
31
|
|
38
32
|
if email.present?
|
39
33
|
user_attributes[:email] = email
|
40
|
-
|
34
|
+
else
|
41
35
|
IO::console.write("Enter User Email (default: #{DEFAULT_USER_EMAIL}): ")
|
42
36
|
user_attributes[:email] = IO::console.gets.strip.presence || DEFAULT_USER_EMAIL
|
43
37
|
end
|
44
38
|
|
45
39
|
user_attributes[:password] = if password.present?
|
46
40
|
password
|
47
|
-
|
41
|
+
else
|
48
42
|
IO::console.getpass('Enter Password: ')
|
49
43
|
end
|
50
44
|
|
45
|
+
abort('password can\'t be blank') if user_attributes[:password].blank?
|
46
|
+
|
51
47
|
user_attributes
|
52
48
|
end
|
53
49
|
|
@@ -57,11 +53,9 @@ class UffizziCore::UserGeneratorService
|
|
57
53
|
}
|
58
54
|
if project_name.present?
|
59
55
|
project_attributes[:name] = project_name
|
60
|
-
|
56
|
+
else
|
61
57
|
IO::console.write("Enter Project Name (default: #{DEFAULT_PROJECT_NAME}): ")
|
62
58
|
project_attributes[:name] = IO::console.gets.strip.presence || DEFAULT_PROJECT_NAME
|
63
|
-
else
|
64
|
-
project_attributes[:name] = DEFAULT_PROJECT_NAME
|
65
59
|
end
|
66
60
|
|
67
61
|
project_attributes[:slug] = prepare_project_slug(project_attributes[:name])
|
data/config/locales/en.yml
CHANGED
@@ -57,7 +57,6 @@ en:
|
|
57
57
|
continuous_preview_in_service_level: The option '%{option}' is not supported for service-level. Use 'x-uffizzi-continuous-preview' instead
|
58
58
|
file_already_exists: A compose file already exists for this project. Run 'uffizzi compose update' to update this file or 'uffizzi compose rm' to remove it. For more options, see 'uffizzi compose --help'
|
59
59
|
invalid_healthcheck_command: "Service '%{name}' defines an invalid healthcheck: when 'test' is a list the first item must be either NONE, CMD or CMD-SHELL"
|
60
|
-
invalid_time_interval: The time interval should be in the following format '{hours}h{minutes}m{seconds}s'. At least one value must be present.
|
61
60
|
string_or_array_error: "'%{option}' contains an invalid type, it should be a string, or an array"
|
62
61
|
not_implemented: "'%{option}' option is not implemented"
|
63
62
|
infinite_recursion: "Found infinite recursion for key '%{key}'"
|
data/config/routes.rb
CHANGED
@@ -22,16 +22,6 @@ UffizziCore::Engine.routes.draw do
|
|
22
22
|
post :deploy_containers, on: :member
|
23
23
|
scope module: :deployments do
|
24
24
|
resources :activity_items, only: ['index']
|
25
|
-
resources :containers, only: ['index'], param: :name do
|
26
|
-
scope module: :containers do
|
27
|
-
resources :logs, only: ['index']
|
28
|
-
resources :builds, only: [] do
|
29
|
-
collection do
|
30
|
-
get :logs
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
25
|
resources :events, only: ['index']
|
36
26
|
resources :containers, only: ['index'], param: :name do
|
37
27
|
scope module: :containers do
|
@@ -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.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
data/swagger/v1/swagger.json
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
"default": {
|
81
81
|
"description": "Create account credential",
|
82
82
|
"examples": {
|
83
|
-
"application/json": "type can be one of UffizziCore::Credential::Amazon, UffizziCore::Credential::Azure
|
83
|
+
"application/json": "type can be one of UffizziCore::Credential::Amazon, UffizziCore::Credential::Azure, UffizziCore::Credential::DockerHub, UffizziCore::Credential::Google, UffizziCore::Credential::GithubContainerRegistry"
|
84
84
|
}
|
85
85
|
},
|
86
86
|
"201": {
|
@@ -1237,16 +1237,8 @@
|
|
1237
1237
|
}
|
1238
1238
|
],
|
1239
1239
|
"responses": {
|
1240
|
-
"
|
1241
|
-
"description": "
|
1242
|
-
"schema": {
|
1243
|
-
"type": "object",
|
1244
|
-
"properties": {
|
1245
|
-
"project": {
|
1246
|
-
"$ref": "#/definitions/Project"
|
1247
|
-
}
|
1248
|
-
}
|
1249
|
-
}
|
1240
|
+
"204": {
|
1241
|
+
"description": "No content"
|
1250
1242
|
},
|
1251
1243
|
"404": {
|
1252
1244
|
"description": "Not Found"
|
@@ -1275,8 +1267,16 @@
|
|
1275
1267
|
}
|
1276
1268
|
],
|
1277
1269
|
"responses": {
|
1278
|
-
"
|
1279
|
-
"description": "
|
1270
|
+
"200": {
|
1271
|
+
"description": "OK",
|
1272
|
+
"schema": {
|
1273
|
+
"type": "object",
|
1274
|
+
"properties": {
|
1275
|
+
"project": {
|
1276
|
+
"$ref": "#/definitions/Project"
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
}
|
1280
1280
|
},
|
1281
1281
|
"404": {
|
1282
1282
|
"description": "Not Found"
|
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.15
|
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-05-
|
12
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -880,7 +880,6 @@ files:
|
|
880
880
|
- app/services/uffizzi_core/compose_file/errors_service.rb
|
881
881
|
- app/services/uffizzi_core/compose_file/github_dependencies_service.rb
|
882
882
|
- app/services/uffizzi_core/compose_file/ingress_options_service.rb
|
883
|
-
- app/services/uffizzi_core/compose_file/parsers/services/healthcheck_parser_service.rb
|
884
883
|
- app/services/uffizzi_core/compose_file/secrets_options_service.rb
|
885
884
|
- app/services/uffizzi_core/compose_file/services_options/command_service.rb
|
886
885
|
- app/services/uffizzi_core/compose_file/services_options/configs_service.rb
|
@@ -907,7 +906,6 @@ files:
|
|
907
906
|
- app/services/uffizzi_core/project_service.rb
|
908
907
|
- app/services/uffizzi_core/repo_service.rb
|
909
908
|
- app/services/uffizzi_core/response_service.rb
|
910
|
-
- app/services/uffizzi_core/starter_template_service.rb
|
911
909
|
- app/services/uffizzi_core/template_service.rb
|
912
910
|
- app/services/uffizzi_core/token_service.rb
|
913
911
|
- app/services/uffizzi_core/user_access_service.rb
|
@@ -929,7 +927,6 @@ files:
|
|
929
927
|
- db/migrate/20220329123323_rename_project_secrets_to_secrets.rb
|
930
928
|
- db/migrate/20220329124542_add_resource_to_secrets.rb
|
931
929
|
- db/migrate/20220329143241_remove_project_ref_from_secrets.rb
|
932
|
-
- db/migrate/20220419074956_add_health_check_to_containers.rb
|
933
930
|
- db/migrate/20220525113412_rename_name_to_uffizzi_containers.rb
|
934
931
|
- db/seeds.rb
|
935
932
|
- lib/tasks/uffizzi_core_tasks.rake
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class UffizziCore::ComposeFile::Parsers::Services::HealthcheckParserService
|
4
|
-
REQUIRED_START_COMMANDS = ['NONE', 'CMD', 'CMD-SHELL'].freeze
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def parse(healthcheck_data)
|
8
|
-
return {} if healthcheck_data.blank?
|
9
|
-
|
10
|
-
command = parse_command(healthcheck_data)
|
11
|
-
|
12
|
-
{
|
13
|
-
test: command,
|
14
|
-
interval: parse_time(healthcheck_data['interval']),
|
15
|
-
timeout: parse_time(healthcheck_data['timeout']),
|
16
|
-
retries: parse_retries(healthcheck_data['retries']),
|
17
|
-
start_period: parse_time(healthcheck_data['start_period']),
|
18
|
-
disable: parse_disable_option(healthcheck_data['disable'], command),
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def parse_command(healthcheck_data)
|
25
|
-
command = healthcheck_data['test']
|
26
|
-
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.string_or_array_error', option: :test) if command.nil?
|
27
|
-
|
28
|
-
case command
|
29
|
-
when Array
|
30
|
-
start_command = command.first
|
31
|
-
raise UffizziCore::ComposeFile::ParseError unless REQUIRED_START_COMMANDS.include?(start_command)
|
32
|
-
|
33
|
-
command
|
34
|
-
when String
|
35
|
-
command
|
36
|
-
else
|
37
|
-
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_type', option: :test)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def parse_retries(value)
|
42
|
-
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_integer', option: :retries) unless value.is_a?(Integer)
|
43
|
-
end
|
44
|
-
|
45
|
-
def parse_time(value)
|
46
|
-
tokens = {
|
47
|
-
's' => 1,
|
48
|
-
'm' => 60,
|
49
|
-
'h' => (60 * 60),
|
50
|
-
'd' => (60 * 60 * 24),
|
51
|
-
}
|
52
|
-
|
53
|
-
time_parts = value.scan(/(\d+)(\w)/).compact
|
54
|
-
|
55
|
-
time_parts.reduce(0) do |acc, part|
|
56
|
-
amount, measure = part
|
57
|
-
acc += amount.to_i * tokens[measure]
|
58
|
-
|
59
|
-
acc
|
60
|
-
rescue StandardError
|
61
|
-
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_time_interval')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def parse_disable_option(value, command)
|
66
|
-
return true if command.is_a?(Array) && command.first == 'NONE'
|
67
|
-
return false if value.nil?
|
68
|
-
return value if value.in?([true, false])
|
69
|
-
|
70
|
-
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_bool_value', field: 'disable', value: value)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,200 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class UffizziCore::StarterTemplateService
|
4
|
-
class << self
|
5
|
-
def create(project, user)
|
6
|
-
voting_app_config_file = create_config_file(project, user)
|
7
|
-
create_containers(project, user, voting_app_config_file)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def create_config_file(project, user)
|
13
|
-
starter_template_config_file = config_file_attributes
|
14
|
-
|
15
|
-
starter_template_config_file_params = ActionController::Parameters.new(starter_template_config_file)
|
16
|
-
|
17
|
-
starter_template_config_file_form = UffizziCore::Api::Cli::V1::ConfigFile::CreateForm.new(starter_template_config_file_params)
|
18
|
-
starter_template_config_file_form.project = project
|
19
|
-
starter_template_config_file_form.added_by = user
|
20
|
-
starter_template_config_file_form.creation_source = UffizziCore::ConfigFile.creation_source.system
|
21
|
-
starter_template_config_file_form.save
|
22
|
-
|
23
|
-
starter_template_config_file_form
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_containers(project, user, voting_app_config_file)
|
27
|
-
starter_template_containers = {
|
28
|
-
name: 'Voting App (from base images)',
|
29
|
-
payload: {
|
30
|
-
containers_attributes: containers_attributes(voting_app_config_file),
|
31
|
-
},
|
32
|
-
}
|
33
|
-
|
34
|
-
starter_template = ActionController::Parameters.new(starter_template_containers)
|
35
|
-
|
36
|
-
starter_template_form = UffizziCore::Api::Cli::V1::Template::CreateForm.new(starter_template)
|
37
|
-
starter_template_form.creation_source = UffizziCore::Template.creation_source.system
|
38
|
-
starter_template_form.added_by = user
|
39
|
-
starter_template_form.project = project
|
40
|
-
starter_template_form.save
|
41
|
-
end
|
42
|
-
|
43
|
-
def containers_attributes(voting_app_config_file)
|
44
|
-
[
|
45
|
-
postgres_container_attributes,
|
46
|
-
nginx_container_attributes(voting_app_config_file),
|
47
|
-
redis_container_attributes,
|
48
|
-
example_worker_container_attributes,
|
49
|
-
example_result_container_attributes,
|
50
|
-
example_vote_container_attributes,
|
51
|
-
]
|
52
|
-
end
|
53
|
-
|
54
|
-
def postgres_container_attributes
|
55
|
-
{
|
56
|
-
image: 'library/postgres',
|
57
|
-
tag: '9.6',
|
58
|
-
port: nil,
|
59
|
-
public: false,
|
60
|
-
memory_limit: 250,
|
61
|
-
memory_request: 250,
|
62
|
-
receive_incoming_requests: false,
|
63
|
-
continuously_deploy: 'disabled',
|
64
|
-
secret_variables: nil,
|
65
|
-
variables: [
|
66
|
-
{
|
67
|
-
name: 'POSTGRES_USER',
|
68
|
-
value: 'postgres',
|
69
|
-
},
|
70
|
-
{
|
71
|
-
name: 'POSTGRES_PASSWORD',
|
72
|
-
value: 'postgres',
|
73
|
-
},
|
74
|
-
],
|
75
|
-
repo_attributes: repo_attributes('library/postgres'),
|
76
|
-
container_config_files_attributes: [],
|
77
|
-
}
|
78
|
-
end
|
79
|
-
|
80
|
-
def nginx_container_attributes(voting_app_config_file)
|
81
|
-
{
|
82
|
-
image: 'library/nginx',
|
83
|
-
tag: 'latest',
|
84
|
-
port: 8080,
|
85
|
-
public: true,
|
86
|
-
memory_limit: 125,
|
87
|
-
memory_request: 125,
|
88
|
-
receive_incoming_requests: true,
|
89
|
-
continuously_deploy: 'disabled',
|
90
|
-
secret_variables: nil,
|
91
|
-
variables: nil,
|
92
|
-
repo_attributes: repo_attributes('library/nginx'),
|
93
|
-
container_config_files_attributes: [{
|
94
|
-
config_file_id: voting_app_config_file.id,
|
95
|
-
mount_path: '/etc/nginx/conf.d/',
|
96
|
-
}],
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
def redis_container_attributes
|
101
|
-
{
|
102
|
-
image: 'library/redis',
|
103
|
-
tag: 'latest',
|
104
|
-
port: nil,
|
105
|
-
public: false,
|
106
|
-
memory_limit: 125,
|
107
|
-
memory_request: 125,
|
108
|
-
receive_incoming_requests: false,
|
109
|
-
continuously_deploy: 'disabled',
|
110
|
-
secret_variables: nil,
|
111
|
-
variables: nil,
|
112
|
-
repo_attributes: repo_attributes('library/redis'),
|
113
|
-
container_config_files_attributes: [],
|
114
|
-
}
|
115
|
-
end
|
116
|
-
|
117
|
-
def example_worker_container_attributes
|
118
|
-
{
|
119
|
-
image: 'uffizzicloud/example-worker',
|
120
|
-
tag: 'latest',
|
121
|
-
port: nil,
|
122
|
-
public: false,
|
123
|
-
memory_limit: 250,
|
124
|
-
memory_request: 250,
|
125
|
-
receive_incoming_requests: false,
|
126
|
-
continuously_deploy: 'disabled',
|
127
|
-
secret_variables: nil,
|
128
|
-
variables: nil,
|
129
|
-
repo_attributes: repo_attributes('uffizzicloud/example-worker'),
|
130
|
-
container_config_files_attributes: [],
|
131
|
-
}
|
132
|
-
end
|
133
|
-
|
134
|
-
def example_result_container_attributes
|
135
|
-
{
|
136
|
-
image: 'uffizzicloud/example-result',
|
137
|
-
tag: 'latest',
|
138
|
-
port: nil,
|
139
|
-
public: false,
|
140
|
-
memory_limit: 125,
|
141
|
-
memory_request: 125,
|
142
|
-
receive_incoming_requests: false,
|
143
|
-
continuously_deploy: 'disabled',
|
144
|
-
secret_variables: nil,
|
145
|
-
variables: nil,
|
146
|
-
repo_attributes: repo_attributes('uffizzicloud/example-result'),
|
147
|
-
container_config_files_attributes: [],
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
|
-
def example_vote_container_attributes
|
152
|
-
{
|
153
|
-
image: 'uffizzicloud/example-vote',
|
154
|
-
tag: 'latest',
|
155
|
-
port: nil,
|
156
|
-
public: false,
|
157
|
-
memory_limit: 250,
|
158
|
-
memory_request: 250,
|
159
|
-
receive_incoming_requests: false,
|
160
|
-
continuously_deploy: 'disabled',
|
161
|
-
secret_variables: nil,
|
162
|
-
variables: nil,
|
163
|
-
repo_attributes: repo_attributes('uffizzicloud/example-vote'),
|
164
|
-
container_config_files_attributes: [],
|
165
|
-
}
|
166
|
-
end
|
167
|
-
|
168
|
-
def config_file_attributes
|
169
|
-
{
|
170
|
-
filename: 'vote.conf',
|
171
|
-
kind: 'config_map',
|
172
|
-
payload: "server {
|
173
|
-
listen 8080;
|
174
|
-
server_name example.com;
|
175
|
-
location / {
|
176
|
-
proxy_pass http://127.0.0.1:80/;
|
177
|
-
}
|
178
|
-
location /vote/ {
|
179
|
-
proxy_pass http://127.0.0.1:8888/;
|
180
|
-
}
|
181
|
-
}",
|
182
|
-
}
|
183
|
-
end
|
184
|
-
|
185
|
-
def repo_attributes(image)
|
186
|
-
namespace, name = image.split('/')
|
187
|
-
{
|
188
|
-
namespace: namespace,
|
189
|
-
name: name,
|
190
|
-
slug: name,
|
191
|
-
type: 'UffizziCore::Repo::DockerHub',
|
192
|
-
description: '',
|
193
|
-
is_private: false,
|
194
|
-
repository_id: nil,
|
195
|
-
branch: '',
|
196
|
-
kind: nil,
|
197
|
-
}
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|