uffizzi_core 0.6.1 → 0.7.0
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 +4 -4
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb +12 -4
- data/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +1 -0
- data/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb +41 -40
- data/app/repositories/uffizzi_core/deployment_repo.rb +4 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb +2 -5
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer/user_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer.rb +14 -0
- data/app/services/uffizzi_core/deployment_service.rb +8 -5
- data/db/migrate/20220805164628_add_metadata_to_deployment.rb +7 -0
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9863f1734f5ee6937e8b498f95a78ff853b1b546c9f33a30578755c2a580869
|
4
|
+
data.tar.gz: 036277c7c8913e0cfda95f5bf413296dd65bccf9d11c7d8f47b0ca70e26da661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbfe3b99fb50fd90bf91d8894eb89104d7239ac58a27dfd0a60e022c9d525995586a074b236f642b85c903d9c5d21f2837610feeef61ade40357d1e55bb649bd
|
7
|
+
data.tar.gz: da2f031e15feb3b3350e4a42bed43f465b581854a77f402b9365fad976f1f000ac53066618224a1521dea0a0d0e0dcdcafd4888ac183d5c955ee820974f220ad
|
@@ -14,7 +14,10 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
|
|
14
14
|
# @response [Array<Deployment>] 200 OK
|
15
15
|
# @response 401 Not authorized
|
16
16
|
def index
|
17
|
-
|
17
|
+
search_labels = JSON.parse(q_param)
|
18
|
+
filtered_deployments = deployments.with_labels(search_labels)
|
19
|
+
|
20
|
+
respond_with filtered_deployments, each_serializer: UffizziCore::Api::Cli::V1::Projects::DeploymentsSerializer
|
18
21
|
end
|
19
22
|
|
20
23
|
# Get deployment information by id
|
@@ -51,7 +54,7 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
|
|
51
54
|
errors = check_credentials(compose_file)
|
52
55
|
return render_errors(errors) if errors.present?
|
53
56
|
|
54
|
-
deployment = UffizziCore::DeploymentService.create_from_compose(compose_file, resource_project, current_user)
|
57
|
+
deployment = UffizziCore::DeploymentService.create_from_compose(compose_file, resource_project, current_user, metadata_params)
|
55
58
|
|
56
59
|
respond_with deployment
|
57
60
|
end
|
@@ -82,8 +85,9 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
|
|
82
85
|
errors = check_credentials(compose_file)
|
83
86
|
return render_errors(errors) if errors.present?
|
84
87
|
|
85
|
-
deployment =
|
86
|
-
updated_deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment
|
88
|
+
deployment = deployments.find(params[:id])
|
89
|
+
updated_deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment,
|
90
|
+
metadata_params)
|
87
91
|
|
88
92
|
respond_with updated_deployment
|
89
93
|
end
|
@@ -171,6 +175,10 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
|
|
171
175
|
params.permit(dependencies: [:name, :path, :source, :content])
|
172
176
|
end
|
173
177
|
|
178
|
+
def metadata_params
|
179
|
+
params[:metadata]
|
180
|
+
end
|
181
|
+
|
174
182
|
def render_invalid_file
|
175
183
|
render json: { errors: { state: ['Invalid compose file'] } }, status: :unprocessable_entity
|
176
184
|
end
|
@@ -3,46 +3,47 @@
|
|
3
3
|
class UffizziCore::Api::Cli::V1::Deployment::UpdateForm < UffizziCore::Deployment
|
4
4
|
include UffizziCore::ApplicationForm
|
5
5
|
|
6
|
-
permit
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
6
|
+
permit :metadata,
|
7
|
+
containers_attributes: [
|
8
|
+
:image,
|
9
|
+
:service_name,
|
10
|
+
:tag,
|
11
|
+
:port,
|
12
|
+
:public,
|
13
|
+
:memory_limit,
|
14
|
+
:memory_request,
|
15
|
+
:entrypoint,
|
16
|
+
:command,
|
17
|
+
:receive_incoming_requests,
|
18
|
+
:continuously_deploy,
|
19
|
+
{ variables: [:name, :value],
|
20
|
+
secret_variables: [:name, :value],
|
21
|
+
volumes: [:source, :target, :type, :read_only],
|
22
|
+
repo_attributes: [
|
23
|
+
:namespace,
|
24
|
+
:name,
|
25
|
+
:slug,
|
26
|
+
:type,
|
27
|
+
:description,
|
28
|
+
:is_private,
|
29
|
+
:repository_id,
|
30
|
+
:branch,
|
31
|
+
:kind,
|
32
|
+
:dockerfile_path,
|
33
|
+
:dockerfile_context_path,
|
34
|
+
:deploy_preview_when_pull_request_is_opened,
|
35
|
+
:delete_preview_when_pull_request_is_closed,
|
36
|
+
:deploy_preview_when_image_tag_is_created,
|
37
|
+
:delete_preview_when_image_tag_is_updated,
|
38
|
+
:share_to_github,
|
39
|
+
:delete_preview_after,
|
40
|
+
{ args: [:name, :value] },
|
41
|
+
],
|
42
|
+
container_config_files_attributes: [
|
43
|
+
:config_file_id,
|
44
|
+
:mount_path,
|
45
|
+
] },
|
46
|
+
]
|
46
47
|
|
47
48
|
validate :check_all_containers_have_unique_ports
|
48
49
|
validate :check_exists_ingress_container
|
@@ -12,5 +12,9 @@ module UffizziCore::DeploymentRepo
|
|
12
12
|
scope :active_for_credential_id, ->(credential_id) {
|
13
13
|
active.joins(project: :credentials).merge(UffizziCore::Project.active).where(credentials: { id: credential_id })
|
14
14
|
}
|
15
|
+
|
16
|
+
scope :with_labels, ->(labels) {
|
17
|
+
where("#{UffizziCore::Deployment.table_name}.metadata @> ?", labels.to_json)
|
18
|
+
}
|
15
19
|
end
|
16
20
|
end
|
@@ -16,16 +16,13 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer < UffizziCore::B
|
|
16
16
|
:image_id,
|
17
17
|
:ingress_container_ready,
|
18
18
|
:ingress_container_state,
|
19
|
-
:creation_source
|
19
|
+
:creation_source,
|
20
|
+
:metadata
|
20
21
|
|
21
22
|
has_many :containers
|
22
23
|
|
23
24
|
belongs_to :deployed_by
|
24
25
|
|
25
|
-
def deployed_by
|
26
|
-
object.deployed_by
|
27
|
-
end
|
28
|
-
|
29
26
|
def containers
|
30
27
|
object.containers.active
|
31
28
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::Api::Cli::V1::Projects::DeploymentsSerializer < UffizziCore::BaseSerializer
|
4
|
+
type :deployment
|
5
|
+
|
6
|
+
attributes :id,
|
7
|
+
:created_at,
|
8
|
+
:updated_at,
|
9
|
+
:state,
|
10
|
+
:preview_url,
|
11
|
+
:metadata
|
12
|
+
|
13
|
+
belongs_to :deployed_by
|
14
|
+
end
|
@@ -12,12 +12,13 @@ class UffizziCore::DeploymentService
|
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
class << self
|
15
|
-
def create_from_compose(compose_file, project, user)
|
15
|
+
def create_from_compose(compose_file, project, user, metadata)
|
16
16
|
deployment_attributes = ActionController::Parameters.new(compose_file.template.payload)
|
17
17
|
deployment_form = UffizziCore::Api::Cli::V1::Deployment::CreateForm.new(deployment_attributes)
|
18
18
|
deployment_form.assign_dependences!(project, user)
|
19
19
|
deployment_form.compose_file = compose_file
|
20
20
|
deployment_form.creation_source = UffizziCore::Deployment.creation_source.compose_file_manual
|
21
|
+
deployment_form.metadata = metadata || {}
|
21
22
|
|
22
23
|
if deployment_form.save
|
23
24
|
update_subdomain!(deployment_form)
|
@@ -28,22 +29,24 @@ class UffizziCore::DeploymentService
|
|
28
29
|
deployment_form
|
29
30
|
end
|
30
31
|
|
31
|
-
def update_from_compose(compose_file, project, user, deployment)
|
32
|
+
def update_from_compose(compose_file, project, user, deployment, metadata)
|
32
33
|
deployment_attributes = ActionController::Parameters.new(compose_file.template.payload)
|
33
34
|
|
34
35
|
deployment_form = UffizziCore::Api::Cli::V1::Deployment::UpdateForm.new(deployment_attributes)
|
35
36
|
deployment_form.assign_dependences!(project, user)
|
36
37
|
deployment_form.compose_file = compose_file
|
38
|
+
deployment_form.metadata = metadata || {}
|
37
39
|
|
38
40
|
ActiveRecord::Base.transaction do
|
39
41
|
deployment.containers.destroy_all
|
40
42
|
deployment.compose_file.destroy! if deployment.compose_file&.kind&.temporary?
|
41
|
-
|
42
|
-
deployment.update!(
|
43
|
+
params = {
|
43
44
|
containers: deployment_form.containers,
|
44
45
|
compose_file_id: compose_file.id,
|
45
46
|
creation_source: UffizziCore::Deployment.creation_source.compose_file_manual,
|
46
|
-
|
47
|
+
metadata: deployment_form.metadata,
|
48
|
+
}
|
49
|
+
deployment.update!(params)
|
47
50
|
end
|
48
51
|
|
49
52
|
deployment
|
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.
|
4
|
+
version: 0.7.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-08-
|
12
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -877,6 +877,8 @@ files:
|
|
877
877
|
- app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer.rb
|
878
878
|
- app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer.rb
|
879
879
|
- app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer/config_file_serializer.rb
|
880
|
+
- app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer.rb
|
881
|
+
- app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer/user_serializer.rb
|
880
882
|
- app/serializers/uffizzi_core/api/cli/v1/projects/secret_serializer.rb
|
881
883
|
- app/serializers/uffizzi_core/api/cli/v1/short_project_serializer.rb
|
882
884
|
- app/serializers/uffizzi_core/api/cli/v1/user_serializer.rb
|
@@ -964,6 +966,7 @@ files:
|
|
964
966
|
- db/migrate/20220422151523_add_volumes_to_uffizzi_core_containers.rb
|
965
967
|
- db/migrate/20220525113412_rename_name_to_uffizzi_containers.rb
|
966
968
|
- db/migrate/20220704135629_add_disabled_at_to_deployments.rb
|
969
|
+
- db/migrate/20220805164628_add_metadata_to_deployment.rb
|
967
970
|
- db/seeds.rb
|
968
971
|
- lib/tasks/uffizzi_core_tasks.rake
|
969
972
|
- lib/uffizzi_core.rb
|