uffizzi_core 0.3.4 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb +21 -0
  3. data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb +15 -17
  4. data/app/forms/uffizzi_core/api/cli/v1/account/credential/check_credential_form.rb +1 -1
  5. data/app/forms/uffizzi_core/api/cli/v1/account/credential/update_form.rb +21 -0
  6. data/app/jobs/uffizzi_core/account/update_credential_job.rb +10 -0
  7. data/app/jobs/uffizzi_core/deployment/update_credential_job.rb +32 -0
  8. data/app/lib/uffizzi_core/concerns/models/activity_item.rb +0 -8
  9. data/app/lib/uffizzi_core/concerns/models/user.rb +0 -5
  10. data/app/models/uffizzi_core/user.rb +5 -0
  11. data/app/policies/uffizzi_core/api/cli/v1/account/credentials_policy.rb +4 -0
  12. data/app/repositories/uffizzi_core/activity_item_repo.rb +4 -0
  13. data/app/repositories/uffizzi_core/compose_file_repo.rb +0 -3
  14. data/app/repositories/uffizzi_core/config_file_repo.rb +0 -22
  15. data/app/repositories/uffizzi_core/container_repo.rb +0 -5
  16. data/app/repositories/uffizzi_core/credential_repo.rb +0 -8
  17. data/app/repositories/uffizzi_core/deployment_repo.rb +3 -11
  18. data/app/repositories/uffizzi_core/membership_repo.rb +0 -1
  19. data/app/repositories/uffizzi_core/repo_repo.rb +0 -1
  20. data/app/repositories/uffizzi_core/template_repo.rb +0 -87
  21. data/app/services/uffizzi_core/account_service.rb +10 -8
  22. data/app/services/uffizzi_core/compose_file_service.rb +11 -0
  23. data/app/services/uffizzi_core/credential_service.rb +1 -2
  24. data/app/services/uffizzi_core/deployment_service.rb +5 -7
  25. data/config/routes.rb +1 -1
  26. data/lib/uffizzi_core/version.rb +1 -1
  27. data/swagger/v1/swagger.json +90 -26
  28. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34e197de1424923114ad82fd43fa818b4841058bd0681e3320c4ba4e2352c452
4
- data.tar.gz: 4b94e04a11bcef28b4fc732fbf0c0d2f51a6512b609fbbc8cbe9b52d2123fd4f
3
+ metadata.gz: 9e55dc8e6b2d5e6cde4394b3f3f526a82e8a0ddc7d0d5ce6aa9e42ad407783c9
4
+ data.tar.gz: 44fdd5695f09b5a93b146370ebc1076278bc55e89f22029e6f30d07cfa3f2d66
5
5
  SHA512:
6
- metadata.gz: 97b2382ee4af9787273b595d1d8840332c51dba8d861cc7752a773137ab1e2639129219ad361ef1f752e5cc88e3a3524b142c84fca22e4076f4da273c461e8ae
7
- data.tar.gz: 195a8f935b0866004c1e6a0a7beb9b42f613042d36f66f2331f19bb86c5c8bb67df5f190d8a42ab5d97c42ddb9fb51685d9082e5370e8edc3fcf51cf872e9e11
6
+ metadata.gz: dbd3510abe5c9919eba8f9abcf35cf9b49b03952d84da0dbe43e12d5615544b1ceaea9125fc877694d56c878d8b372f5777912006c9b361800ed3b02543a5be1
7
+ data.tar.gz: 2b37022d8b1d9142ab4d9977bbe1adc5e03ae7d5492a60a27df2975ba0d0c7808a3f6c1b7542a8bd4f8f7214a6b753a25036bbbbd836b7dc94a59262aaaa9779
@@ -40,6 +40,27 @@ class UffizziCore::Api::Cli::V1::Account::CredentialsController < UffizziCore::A
40
40
  respond_with credential_form
41
41
  end
42
42
 
43
+ # Update existing credential of the given type
44
+ #
45
+ # @path [PUT] /api/cli/v1/account/credentials/{type}
46
+ #
47
+ # @parameter type(required,path) [string] Credential type
48
+ # @parameter credential(required,body) [object<type:string>]
49
+ # @response [object<id:integer, registry_url:string, username:string, password:string>] 200 OK
50
+ # @response [object<errors>] 422 Unprocessable entity
51
+ def update
52
+ credential = resource_account.credentials.find_by!(type: params[:type])
53
+ credential_form = credential.becomes(UffizziCore::Api::Cli::V1::Account::Credential::UpdateForm)
54
+ credential_form.assign_attributes(credential_params)
55
+
56
+ if credential_form.save
57
+ UffizziCore::Account::UpdateCredentialJob.perform_async(credential_form.id)
58
+ respond_with credential_form
59
+ else
60
+ respond_with credential_form, status: :unprocessable_entity
61
+ end
62
+ end
63
+
43
64
  # Check if credential of the type already exists in the account
44
65
  #
45
66
  # @path [GET] /api/cli/v1/account/credentials/{type}/check_credential
@@ -70,17 +70,22 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
70
70
  # @response [object<errors: object<title: string>>] 404 Not found
71
71
  # @response 401 Not authorized
72
72
  def update
73
- compose_file, errors = create_temporary_compose_file
73
+ compose_file, errors = UffizziCore::ComposeFileService.create_temporary_compose(
74
+ resource_project,
75
+ current_user,
76
+ compose_file_params,
77
+ dependencies_params[:dependencies],
78
+ )
74
79
  return render_invalid_file if compose_file.invalid_file?
75
80
  return render_errors(errors) if errors.present?
76
81
 
77
82
  errors = check_credentials(compose_file)
78
83
  return render_errors(errors) if errors.present?
79
84
 
80
- deployment_id = params[:id]
81
- deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment_id)
85
+ deployment = UffizziCore::Deployment.find(params[:id])
86
+ updated_deployment = UffizziCore::DeploymentService.update_from_compose(compose_file, resource_project, current_user, deployment)
82
87
 
83
- respond_with deployment
88
+ respond_with updated_deployment
84
89
  end
85
90
 
86
91
  # @path [POST] /api/cli/v1/projects/{project_slug}/deployments/{id}/deploy_containers
@@ -126,7 +131,12 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
126
131
  def find_or_create_compose_file
127
132
  existing_compose_file = resource_project.compose_file
128
133
  if compose_file_params.present?
129
- create_temporary_compose_file
134
+ UffizziCore::ComposeFileService.create_temporary_compose(
135
+ resource_project,
136
+ current_user,
137
+ compose_file_params,
138
+ dependencies_params[:dependencies],
139
+ )
130
140
  else
131
141
  raise ActiveRecord::RecordNotFound if existing_compose_file.blank?
132
142
 
@@ -135,18 +145,6 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
135
145
  end
136
146
  end
137
147
 
138
- def create_temporary_compose_file
139
- create_params = {
140
- project: resource_project,
141
- user: current_user,
142
- compose_file_params: compose_file_params,
143
- dependencies: dependencies_params[:dependencies] || [],
144
- }
145
-
146
- kind = UffizziCore::ComposeFile.kind.temporary
147
- UffizziCore::ComposeFileService.create(create_params, kind)
148
- end
149
-
150
148
  def check_credentials(compose_file)
151
149
  credentials = resource_project.account.credentials
152
150
  check_credentials_form = UffizziCore::Api::Cli::V1::ComposeFile::CheckCredentialsForm.new
@@ -11,6 +11,6 @@ class UffizziCore::Api::Cli::V1::Account::Credential::CheckCredentialForm
11
11
  private
12
12
 
13
13
  def credential_exists?
14
- errors.add(:type, 'Credential of that type already exist.') if account.credentials.by_type(type).exists?
14
+ errors.add(:type, :exist) if account.credentials.by_type(type).exists?
15
15
  end
16
16
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Account::Credential::UpdateForm < UffizziCore::Credential
4
+ include UffizziCore::ApplicationForm
5
+
6
+ permit :registry_url, :username, :password
7
+
8
+ validates :password, presence: { message: :password_blank }
9
+ validate :check_registry_url, if: -> { errors[:password].empty? }
10
+ validate :check_credential_correctness, if: -> { errors[:password].empty? }
11
+
12
+ private
13
+
14
+ def check_registry_url
15
+ errors.add(:registry_url, :invalid_scheme) if URI.parse(registry_url).scheme.nil?
16
+ end
17
+
18
+ def check_credential_correctness
19
+ errors.add(:username, :incorrect) unless UffizziCore::CredentialService.correct_credentials?(self)
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Account::UpdateCredentialJob < UffizziCore::ApplicationJob
4
+ sidekiq_options queue: :accounts, retry: 5
5
+
6
+ def perform(id)
7
+ credential = UffizziCore::Credential.find(id)
8
+ UffizziCore::AccountService.update_credential(credential)
9
+ end
10
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Deployment::UpdateCredentialJob < UffizziCore::ApplicationJob
4
+ sidekiq_options queue: :deployments, retry: Settings.controller.resource_update_retry_count
5
+
6
+ sidekiq_retry_in do |count, exception|
7
+ case exception
8
+ when UffizziCore::DeploymentNotFoundError
9
+ Rails.logger.info("DEPLOYMENT_PROCESS UpdateCredentialJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
+ Settings.controller.resource_update_retry_time
11
+ end
12
+ end
13
+
14
+ def perform(deployment_id, credential_id)
15
+ Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} UpdateCredentialJob(cred_id:#{credential_id})")
16
+
17
+ deployment = UffizziCore::Deployment.find(deployment_id)
18
+ credential = UffizziCore::Credential.find(credential_id)
19
+
20
+ if deployment.disabled?
21
+ Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} deployment was disabled. Stop updating credential")
22
+ return
23
+ end
24
+
25
+ unless UffizziCore::ControllerService.deployment_exists?(deployment)
26
+ raise UffizziCore::DeploymentNotFoundError,
27
+ deployment_id
28
+ end
29
+
30
+ UffizziCore::ControllerService.apply_credential(deployment, credential)
31
+ end
32
+ end
@@ -14,14 +14,6 @@ module UffizziCore::Concerns::Models::ActivityItem
14
14
 
15
15
  has_many :events, dependent: :destroy
16
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
17
  def docker?
26
18
  type == UffizziCore::ActivityItem::Docker.name
27
19
  end
@@ -15,11 +15,6 @@ module UffizziCore::Concerns::Models::User
15
15
 
16
16
  rolify({ role_cname: UffizziCore::Role.name, role_join_table_name: UffizziCore.table_names[:users_roles] })
17
17
 
18
- has_secure_password
19
-
20
- validates :email, presence: true, 'uffizzi_core/email': true, uniqueness: { case_sensitive: false }
21
- validates :password, allow_nil: true, length: { minimum: 8 }, on: :update
22
-
23
18
  has_many :memberships, dependent: :destroy
24
19
  has_many :accounts, through: :memberships
25
20
  has_many :user_projects, dependent: :destroy
@@ -2,4 +2,9 @@
2
2
 
3
3
  class UffizziCore::User < ActiveRecord::Base
4
4
  include UffizziCore::Concerns::Models::User
5
+
6
+ has_secure_password
7
+
8
+ validates :email, presence: true, 'uffizzi_core/email': true, uniqueness: { case_sensitive: false }
9
+ validates :password, allow_nil: true, length: { minimum: 8 }, on: :update
5
10
  end
@@ -9,6 +9,10 @@ class UffizziCore::Api::Cli::V1::Account::CredentialsPolicy < UffizziCore::Appli
9
9
  context.user_access_module.admin_access_to_account?(context.user, context.account)
10
10
  end
11
11
 
12
+ def update?
13
+ context.user_access_module.admin_access_to_account?(context.user, context.account)
14
+ end
15
+
12
16
  def check_credential?
13
17
  context.user_access_module.admin_access_to_account?(context.user, context.account)
14
18
  end
@@ -5,5 +5,9 @@ module UffizziCore::ActivityItemRepo
5
5
 
6
6
  included do
7
7
  include UffizziCore::BasicOrderRepo
8
+
9
+ scope :docker, -> {
10
+ where(type: UffizziCore::ActivityItem::Docker.name)
11
+ }
8
12
  end
9
13
  end
@@ -4,8 +4,5 @@ module UffizziCore::ComposeFileRepo
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- scope :with_auto_deploy, -> {
8
- where(auto_deploy: UffizziCore::ComposeFile::STATE_ENABLED)
9
- }
10
7
  end
11
8
  end
@@ -14,27 +14,5 @@ module UffizziCore::ConfigFileRepo
14
14
  scope :by_source, ->(source) {
15
15
  where(source: source)
16
16
  }
17
-
18
- scope :only_used_config_files, -> {
19
- select(:id)
20
- .where("(id = ANY(ARRAY(select distinct(
21
- jsonb_array_elements(
22
- (
23
- jsonb_array_elements(
24
- jsonb_extract_path_text(
25
- payload::jsonb, 'containers_attributes'
26
- )::jsonb
27
- ) ->> 'container_config_files_attributes'
28
- )::jsonb
29
- ) ->> 'config_file_id'
30
- ) as ids from templates)::int[]))")
31
- .or(
32
- UffizziCore::ConfigFile.where(
33
- id: UffizziCore::ContainerConfigFile.where(
34
- container_id: UffizziCore::Container.active.select(:id),
35
- ).select(:config_file_id),
36
- ),
37
- )
38
- }
39
17
  end
40
18
  end
@@ -6,7 +6,6 @@ module UffizziCore::ContainerRepo
6
6
  included do
7
7
  include UffizziCore::BasicOrderRepo
8
8
 
9
- scope :with_github_repo, -> { includes(:repo).where(repo: { type: UffizziCore::Repo::Github.name }) }
10
9
  scope :with_amazon_repo, -> { includes(:repo).where(repo: { type: UffizziCore::Repo::Amazon.name }) }
11
10
  scope :with_docker_hub_repo, -> { includes(:repo).where(repo: { type: UffizziCore::Repo::DockerHub.name }) }
12
11
 
@@ -14,10 +13,6 @@ module UffizziCore::ContainerRepo
14
13
  where(public: true)
15
14
  }
16
15
 
17
- scope :with_enabled_continuously_deploy, -> {
18
- where(continuously_deploy: UffizziCore::Container::STATE_ENABLED)
19
- }
20
-
21
16
  scope :by_repo_type, ->(type) {
22
17
  includes(:repo).where(repo: { type: type })
23
18
  }
@@ -5,19 +5,11 @@ module UffizziCore::CredentialRepo
5
5
 
6
6
  included do
7
7
  scope :by_type, ->(type) { where(type: type) }
8
-
9
8
  scope :docker_hub, -> { by_type(UffizziCore::Credential::DockerHub.name) }
10
-
11
- scope :github, -> { by_type(UffizziCore::Credential::Github.name) }
12
-
13
9
  scope :azure, -> { by_type(UffizziCore::Credential::Azure.name) }
14
-
15
10
  scope :google, -> { by_type(UffizziCore::Credential::Google.name) }
16
-
17
11
  scope :amazon, -> { by_type(UffizziCore::Credential::Amazon.name) }
18
-
19
12
  scope :github_container_registry, -> { by_type(UffizziCore::Credential::GithubContainerRegistry.name) }
20
-
21
13
  scope :deployable, -> {
22
14
  by_type([
23
15
  UffizziCore::Credential::DockerHub.name,
@@ -7,18 +7,10 @@ module UffizziCore::DeploymentRepo
7
7
  scope :with_name, ->(name) {
8
8
  where(name: name)
9
9
  }
10
- scope :by_config_file, ->(config_file) {
11
- container_config_files = UffizziCore::ContainerConfigFile.where(config_file: config_file)
12
- containers = UffizziCore::Container.where(id: container_config_files.select(:container_id))
13
- where(id: containers.select(:deployment_id))
14
- }
15
10
  scope :with_amazon_repos, -> { includes(containers: [:repo]).where(containers: { repos: { type: UffizziCore::Repo::Amazon.name } }) }
16
- scope :by_templates, ->(templates) {
17
- where(template: templates).where.not(templates: nil)
18
- }
19
- scope :with_containers, ->(source, image, tag) {
20
- includes(containers: :repo).where(containers: { image: image, tag: tag, repos: { type: source } })
21
- }
22
11
  scope :existed, -> { where(state: [:active, :failed]) }
12
+ scope :active_for_credential_id, ->(credential_id) {
13
+ active.joins(project: :credentials).merge(UffizziCore::Project.active).where(credentials: { id: credential_id })
14
+ }
23
15
  end
24
16
  end
@@ -4,7 +4,6 @@ module UffizziCore::MembershipRepo
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- scope :by_role, ->(role) { where(role: role) }
8
7
  scope :by_role_admin, -> { by_role(UffizziCore::Membership.role.admin) }
9
8
  end
10
9
  end
@@ -5,6 +5,5 @@ module UffizziCore::RepoRepo
5
5
 
6
6
  included do
7
7
  scope :docker_hub, -> { where(type: UffizziCore::Repo::DockerHub.name) }
8
- scope :github, -> { where(type: UffizziCore::Repo::Github.name) }
9
8
  end
10
9
  end
@@ -4,92 +4,5 @@ module UffizziCore::TemplateRepo
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- scope :by_docker_containers_with_deploy_preview_when_image_tag_is_created, ->(source, image, tag) {
8
- general_query = {
9
- containers_attributes: [
10
- {
11
- image: image,
12
- repo_attributes: {
13
- type: source,
14
- deploy_preview_when_image_tag_is_created: true,
15
- },
16
- },
17
- ],
18
- }
19
-
20
- excluding_query = {
21
- containers_attributes: [
22
- {
23
- image: image,
24
- tag: tag,
25
- repo_attributes: {
26
- type: source,
27
- deploy_preview_when_image_tag_is_created: true,
28
- },
29
- },
30
- ],
31
- }
32
-
33
- where('templates.payload @> ?', general_query.to_json).where.not('templates.payload @> ?', excluding_query.to_json)
34
- }
35
-
36
- scope :by_docker_containers_with_delete_preview_when_image_tag_is_updated, ->(source, image, tag) {
37
- general_query = {
38
- containers_attributes: [
39
- {
40
- image: image,
41
- tag: tag,
42
- repo_attributes: {
43
- type: source,
44
- delete_preview_when_image_tag_is_updated: true,
45
- },
46
- },
47
- ],
48
- }
49
-
50
- where('templates.payload @> ?', general_query.to_json)
51
- }
52
-
53
- scope :by_github_containers_with_deploy_preview_when_pull_request_is_opened, ->(repository_id, branch) {
54
- query = {
55
- containers_attributes: [
56
- {
57
- repo_attributes: {
58
- type: UffizziCore::Repo::Github.name,
59
- repository_id: repository_id,
60
- branch: branch,
61
- deploy_preview_when_pull_request_is_opened: true,
62
- },
63
- },
64
- ],
65
- }
66
-
67
- where('templates.payload @> ?', query.to_json)
68
- }
69
-
70
- scope :by_github_containers_with_delete_preview_when_pull_request_is_closed, ->(repository_id, branch) {
71
- query = {
72
- containers_attributes: [
73
- {
74
- repo_attributes: {
75
- type: UffizziCore::Repo::Github.name,
76
- repository_id: repository_id,
77
- branch: branch,
78
- delete_preview_when_pull_request_is_closed: true,
79
- },
80
- },
81
- ],
82
- }
83
-
84
- where('templates.payload @> ?', query.to_json)
85
- }
86
-
87
- scope :by_compose_file_kind, ->(kind) {
88
- left_joins(:compose_file).where(compose_files: { kind: kind })
89
- }
90
-
91
- scope :without_compose, -> {
92
- left_joins(:compose_file).where(compose_files: { id: nil })
93
- }
94
7
  end
95
8
  end
@@ -3,18 +3,20 @@
3
3
  class UffizziCore::AccountService
4
4
  class << self
5
5
  def create_credential(credential)
6
- credential.account.projects.active.each do |project|
7
- project.deployments.active.each do |deployment|
8
- UffizziCore::Deployment::CreateCredentialJob.perform_async(deployment.id, credential.id)
9
- end
6
+ UffizziCore::Deployment.active_for_credential_id(credential.id).pluck(:id).each do |deployment_id|
7
+ UffizziCore::Deployment::CreateCredentialJob.perform_async(deployment_id, credential.id)
8
+ end
9
+ end
10
+
11
+ def update_credential(credential)
12
+ UffizziCore::Deployment.active_for_credential_id(credential.id).pluck(:id).each do |deployment_id|
13
+ UffizziCore::Deployment::UpdateCredentialJob.perform_async(deployment_id, credential.id)
10
14
  end
11
15
  end
12
16
 
13
17
  def delete_credential(credential)
14
- credential.account.projects.active.each do |project|
15
- project.deployments.active.each do |deployment|
16
- UffizziCore::Deployment::DeleteCredentialJob.perform_async(deployment.id, credential.id)
17
- end
18
+ UffizziCore::Deployment.active_for_credential_id(credential.id).pluck(:id).each do |deployment_id|
19
+ UffizziCore::Deployment::DeleteCredentialJob.perform_async(deployment_id, credential.id)
18
20
  end
19
21
  end
20
22
  end
@@ -87,6 +87,17 @@ class UffizziCore::ComposeFileService
87
87
  end
88
88
  end
89
89
 
90
+ def create_temporary_compose(resource_project, current_user, compose_file_params, dependencies)
91
+ create_params = {
92
+ project: resource_project,
93
+ user: current_user,
94
+ compose_file_params: compose_file_params,
95
+ dependencies: dependencies || [],
96
+ }
97
+ kind = UffizziCore::ComposeFile.kind.temporary
98
+ UffizziCore::ComposeFileService.create(create_params, kind)
99
+ end
100
+
90
101
  private
91
102
 
92
103
  def process_compose_file(compose_file_form, params)
@@ -19,8 +19,7 @@ class UffizziCore::CredentialService
19
19
  end
20
20
 
21
21
  if credential.persisted? && credential.active? && !status
22
- Rails.logger.warn("broken credentials, credential_correct? credential_id=#{credential.id}")
23
- credential.unauthorize!
22
+ Rails.logger.warn("Wrong credential: credential_correct? credential_id=#{credential.id}")
24
23
  end
25
24
 
26
25
  status
@@ -29,23 +29,21 @@ class UffizziCore::DeploymentService
29
29
  deployment_form
30
30
  end
31
31
 
32
- def update_from_compose(compose_file, project, user, deployment_id)
32
+ def update_from_compose(compose_file, project, user, deployment)
33
33
  deployment_attributes = ActionController::Parameters.new(compose_file.template.payload)
34
34
 
35
35
  deployment_form = UffizziCore::Api::Cli::V1::Deployment::UpdateForm.new(deployment_attributes)
36
36
  deployment_form.assign_dependences!(project, user)
37
37
  deployment_form.compose_file = compose_file
38
38
 
39
- if deployment_form.valid?
40
- deployment = UffizziCore::Deployment.find(deployment_id)
39
+ ActiveRecord::Base.transaction do
41
40
  deployment.containers.destroy_all
42
- deployment.compose_file.destroy if deployment.compose_file.kind.temporary?
43
- deployment.update!(containers: deployment_form.containers, compose_file_id: compose_file.id)
41
+ deployment.compose_file.destroy! if deployment.compose_file.kind.temporary?
44
42
 
45
- return deployment
43
+ deployment.update!(containers: deployment_form.containers, compose_file_id: compose_file.id)
46
44
  end
47
45
 
48
- deployment_form
46
+ deployment
49
47
  end
50
48
 
51
49
  def deploy_containers(deployment, repeated = false)
data/config/routes.rb CHANGED
@@ -46,7 +46,7 @@ UffizziCore::Engine.routes.draw do
46
46
 
47
47
  resource :account, only: [] do
48
48
  scope module: :account do
49
- resources :credentials, only: ['index', 'create', 'destroy'], param: :type do
49
+ resources :credentials, only: ['index', 'create', 'update', 'destroy'], param: :type do
50
50
  member do
51
51
  get :check_credential
52
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '0.3.4'
4
+ VERSION = '0.3.7'
5
5
  end
@@ -122,12 +122,12 @@
122
122
  "x-action": "create"
123
123
  }
124
124
  },
125
- "/api/cli/v1/account/credentials/{type}/check_credential": {
126
- "get": {
125
+ "/api/cli/v1/account/credentials/{type}": {
126
+ "put": {
127
127
  "tags": [
128
128
  "Account/Credential"
129
129
  ],
130
- "operationId": "Account/Credential-check_credential",
130
+ "operationId": "Account/Credential-update",
131
131
  "parameters": [
132
132
  {
133
133
  "name": "credential",
@@ -145,27 +145,48 @@
145
145
  },
146
146
  {
147
147
  "name": "type",
148
- "description": "Scope response to type",
148
+ "description": "Credential type",
149
149
  "required": true,
150
150
  "in": "path",
151
151
  "type": "string"
152
152
  }
153
153
  ],
154
154
  "responses": {
155
- "422": {
156
- "description": "Unprocessable entity"
157
- },
158
155
  "200": {
159
- "description": "OK"
156
+ "description": "OK",
157
+ "schema": {
158
+ "type": "object",
159
+ "properties": {
160
+ "id": {
161
+ "type": "integer"
162
+ },
163
+ "registry_url": {
164
+ "type": "string"
165
+ },
166
+ "username": {
167
+ "type": "string"
168
+ },
169
+ "password": {
170
+ "type": "string"
171
+ }
172
+ }
173
+ }
174
+ },
175
+ "422": {
176
+ "description": "Unprocessable entity",
177
+ "schema": {
178
+ "type": "object",
179
+ "additionalProperties": {
180
+ "type": "errors"
181
+ }
182
+ }
160
183
  }
161
184
  },
162
- "description": "Check if credential of the type already exists in the account",
163
- "summary": "Check if credential of the type already exists in the account",
185
+ "description": "Update existing credential of the given type",
186
+ "summary": "Update existing credential of the given type",
164
187
  "x-controller": "uffizzi_core/api/cli/v1/account/credentials",
165
- "x-action": "check_credential"
166
- }
167
- },
168
- "/api/cli/v1/account/credentials/{type}": {
188
+ "x-action": "update"
189
+ },
169
190
  "delete": {
170
191
  "tags": [
171
192
  "Account/Credential"
@@ -210,6 +231,49 @@
210
231
  "x-action": "destroy"
211
232
  }
212
233
  },
234
+ "/api/cli/v1/account/credentials/{type}/check_credential": {
235
+ "get": {
236
+ "tags": [
237
+ "Account/Credential"
238
+ ],
239
+ "operationId": "Account/Credential-check_credential",
240
+ "parameters": [
241
+ {
242
+ "name": "credential",
243
+ "description": "credential",
244
+ "required": true,
245
+ "in": "body",
246
+ "schema": {
247
+ "type": "object",
248
+ "properties": {
249
+ "type": {
250
+ "type": "string"
251
+ }
252
+ }
253
+ }
254
+ },
255
+ {
256
+ "name": "type",
257
+ "description": "Scope response to type",
258
+ "required": true,
259
+ "in": "path",
260
+ "type": "string"
261
+ }
262
+ ],
263
+ "responses": {
264
+ "422": {
265
+ "description": "Unprocessable entity"
266
+ },
267
+ "200": {
268
+ "description": "OK"
269
+ }
270
+ },
271
+ "description": "Check if credential of the type already exists in the account",
272
+ "summary": "Check if credential of the type already exists in the account",
273
+ "x-controller": "uffizzi_core/api/cli/v1/account/credentials",
274
+ "x-action": "check_credential"
275
+ }
276
+ },
213
277
  "/api/cli/v1/projects/{project_slug}/compose_file": {
214
278
  "get": {
215
279
  "tags": [
@@ -1237,8 +1301,16 @@
1237
1301
  }
1238
1302
  ],
1239
1303
  "responses": {
1240
- "204": {
1241
- "description": "No content"
1304
+ "200": {
1305
+ "description": "OK",
1306
+ "schema": {
1307
+ "type": "object",
1308
+ "properties": {
1309
+ "project": {
1310
+ "$ref": "#/definitions/Project"
1311
+ }
1312
+ }
1313
+ }
1242
1314
  },
1243
1315
  "404": {
1244
1316
  "description": "Not Found"
@@ -1267,16 +1339,8 @@
1267
1339
  }
1268
1340
  ],
1269
1341
  "responses": {
1270
- "200": {
1271
- "description": "OK",
1272
- "schema": {
1273
- "type": "object",
1274
- "properties": {
1275
- "project": {
1276
- "$ref": "#/definitions/Project"
1277
- }
1278
- }
1279
- }
1342
+ "204": {
1343
+ "description": "No content"
1280
1344
  },
1281
1345
  "404": {
1282
1346
  "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.3.4
4
+ version: 0.3.7
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-07-21 00:00:00.000000000 Z
12
+ date: 2022-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -729,6 +729,7 @@ files:
729
729
  - app/errors/uffizzi_core/deployment_not_found_error.rb
730
730
  - app/forms/uffizzi_core/api/cli/v1/account/credential/check_credential_form.rb
731
731
  - app/forms/uffizzi_core/api/cli/v1/account/credential/create_form.rb
732
+ - app/forms/uffizzi_core/api/cli/v1/account/credential/update_form.rb
732
733
  - app/forms/uffizzi_core/api/cli/v1/compose_file/check_credentials_form.rb
733
734
  - app/forms/uffizzi_core/api/cli/v1/compose_file/cli_form.rb
734
735
  - app/forms/uffizzi_core/api/cli/v1/compose_file/create_form.rb
@@ -747,6 +748,7 @@ files:
747
748
  - app/forms/uffizzi_core/mass_assignment_control_concern.rb
748
749
  - app/helpers/uffizzi_core/application_helper.rb
749
750
  - app/jobs/uffizzi_core/account/create_credential_job.rb
751
+ - app/jobs/uffizzi_core/account/update_credential_job.rb
750
752
  - app/jobs/uffizzi_core/activity_item/docker/update_digest_job.rb
751
753
  - app/jobs/uffizzi_core/application_job.rb
752
754
  - app/jobs/uffizzi_core/config_file/apply_job.rb
@@ -759,6 +761,7 @@ files:
759
761
  - app/jobs/uffizzi_core/deployment/delete_job.rb
760
762
  - app/jobs/uffizzi_core/deployment/deploy_containers_job.rb
761
763
  - app/jobs/uffizzi_core/deployment/manage_deploy_activity_item_job.rb
764
+ - app/jobs/uffizzi_core/deployment/update_credential_job.rb
762
765
  - app/lib/uffizzi_core/concerns/models/account.rb
763
766
  - app/lib/uffizzi_core/concerns/models/activity_item.rb
764
767
  - app/lib/uffizzi_core/concerns/models/build.rb