uffizzi_core 2.1.23 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0006c772fa6daeaecbd5eab034433a8e66b5b6090b5af1f52dc93627ddbab788
4
- data.tar.gz: 2df15f2b34462e716536e71bb55567cab5792dffbe7e6f797d0ceee8de5badca
3
+ metadata.gz: 891fe1a03e5dd0dbc635156b946213cbedef67a792537d706e7247ec241c8c7a
4
+ data.tar.gz: a81611e8aa150c0d6bf1ac9f3bdbd549aefdfcfc1434f3ebe68688488bd509b8
5
5
  SHA512:
6
- metadata.gz: 9b4082dc0121834a765c085c7554ffc6aa789018d77d33d5390a5a422c313fe39460cc5fdeed9c26d3bfaffb56c4e744ec7110bdb30c8d3cbc2be6302a72e6b0
7
- data.tar.gz: f4b51425b29c3fb7cf81b6964503e45acee38ab0d193a019261bd94d4bee2d8c564694795a49438c10a7029871cb0157e7cfcc624dcbed425f1c0db2aeb7a21e
6
+ metadata.gz: 7de4b67a8fc79849717ac31c2e74511d8c017dad1adc70cdc94dc83ab022290c819dfd7cf68fda8b411399ec7b39efd0f774e351daecd25845cc84f82879cf33
7
+ data.tar.gz: '028258a7a6c4550b9921642df1d38e8ef3e87e63b0f95fefbb866eaf46614df97b114f6bf51fdfa82ff0190ed2abcf910a4602ada23e6850a6ddedbfa1fdd603'
@@ -1,6 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore::DependencyInjectionConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def include_module_if_exists(module_name)
8
+ include(Object.const_get(module_name)) if Object.const_defined?(module_name)
9
+ end
10
+ end
11
+
4
12
  def user_access_module
5
13
  return unless module_exists?(:rbac)
6
14
 
@@ -51,6 +51,8 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
51
51
  # @response [object<errors: object<title: string>>] 404 Not found
52
52
  # @response 401 Not authorized
53
53
  def create
54
+ return render_deployment_exists_error if deployments.with_metadata.with_labels(metadata_params).exists?
55
+
54
56
  compose_file, errors = find_or_create_compose_file
55
57
  return render_invalid_file if compose_file.invalid_file?
56
58
  return render_errors(errors) if errors.present?
@@ -193,6 +195,10 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
193
195
  end
194
196
 
195
197
  def render_invalid_file
196
- render json: { errors: { state: ['Invalid compose file'] } }, status: :unprocessable_entity
198
+ render json: { errors: { state: [I18n.t('compose.invalid_compose')] } }, status: :unprocessable_entity
199
+ end
200
+
201
+ def render_deployment_exists_error
202
+ render json: { errors: { state: [I18n.t('deployment.already_exists')] } }, status: :unprocessable_entity
197
203
  end
198
204
  end
@@ -12,7 +12,7 @@ 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
-
15
+ scope :with_metadata, -> { where.not(metadata: {}) }
16
16
  scope :with_labels, ->(labels) {
17
17
  where("#{UffizziCore::Deployment.table_name}.metadata @> ?", labels.to_json)
18
18
  }
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer < UffizziCore::BaseSerializer
4
+ include UffizziCore::DependencyInjectionConcern
5
+ include_module_if_exists('UffizziCore::Api::Cli::V1::Projects::DeploymentSerializerModule')
6
+
4
7
  type :deployment
5
8
 
6
9
  attributes :id,
@@ -37,6 +37,9 @@ class UffizziCore::ContainerRegistry::DockerHubService
37
37
  token = docker_hub_client.get_token(image).result.token
38
38
  response = docker_hub_client.digest(image: image, tag: tag, token: token)
39
39
  response.headers['docker-content-digest']
40
+ # FIXME: can't get digest for private image: {"code":"UNAUTHORIZED","message":"authentication required"...}
41
+ rescue UffizziCore::ContainerRegistryError
42
+ 'unknown'
40
43
  end
41
44
 
42
45
  def credential_correct?(credential)
@@ -14,6 +14,7 @@ en:
14
14
  compose:
15
15
  unsupported_file: Unsupported compose file
16
16
  invalid_file: 'Syntax error: %{err} at line %{line} column %{column}'
17
+ invalid_compose: Invalid compose file
17
18
  invalid_config_option: Invalid config option '%{value}' - only a-zA-Z0-9._- characters are allowed
18
19
  no_services: Service services has neither an image nor a build context specified. At least one must be provided.
19
20
  invalid_service_name: "Invalid service name '%{value}': a service name must consist of lower case alphanumeric characters, ''-'', and must start and end with an alphanumeric character"
@@ -80,6 +81,7 @@ en:
80
81
 
81
82
  deployment:
82
83
  invalid_state: Preview with ID deployment-%{id} %{state}
84
+ already_exists: An active deployment already exists
83
85
 
84
86
  session:
85
87
  unsupported_login_type: This type of login is not supported
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.1.23'
4
+ VERSION = '2.1.25'
5
5
  end
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: 2.1.23
4
+ version: 2.1.25
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: 2023-05-18 00:00:00.000000000 Z
12
+ date: 2023-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm