Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Stepanov committed May 26, 2022
2 parents 9ef4c4b + 8d64a85 commit 372fa5d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def port(ingress_data)

raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_integer', option: :port) unless port.is_a?(Integer)

if port < Settings.compose.port_min_value || port > Settings.compose.port_max_value
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_port')
port_min = Settings.compose.port_min_value
port_max = Settings.compose.port_max_value
if port < port_min || port > port_max
raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.port_out_of_range', port_min: port_min, port_max: port_max)
end

port
Expand Down
2 changes: 1 addition & 1 deletion core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ en:
invalid_ingress_service: Invalid ingress service '%{value}'
no_variable_name: Invalid environment variable 'name=%{name}' 'value=%{value}'
invalid_config: Invalid config value 'source=%{source}' 'target=%{target}'
invalid_port: Invalid port specification '%{value}'
port_out_of_range: Port should be specified between %{port_min} - %{port_max}
invalid_memory_postfix: The specified value for memory '%{value}' should specify the units. The postfix should be one of the `b` `k` `m` `g` characters
invalid_memory_type: Memory '%{value}' contains an invalid type, it should be a string
invalid_memory_value: Invalid memory value '%{value}'
Expand Down
3 changes: 2 additions & 1 deletion core/test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_03_29_143241) do
ActiveRecord::Schema.define(version: 2022_04_19_074956) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -151,6 +151,7 @@
t.string "entrypoint"
t.string "command"
t.string "name"
t.jsonb "healthcheck"
t.index ["deployment_id"], name: "index_containers_on_deployment_id"
t.index ["repo_id"], name: "index_containers_on_repo_id"
end
Expand Down
4 changes: 2 additions & 2 deletions core/test/services/compose_file_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ class UffizziCore::ComposeFileServiceTest < ActiveSupport::TestCase
assert_match('At least one must be provided', e.message)
end

test '#parse - check if a port is invalid' do
test '#parse - check if a port is out of acceptable range' do
content = file_fixture('files/compose_files/dockerhub_services/nginx_invalid_port.yml').read

e = assert_raise(UffizziCore::ComposeFile::ParseError) do
UffizziCore::ComposeFileService.parse(content)
end

assert_match('Invalid port specification', e.message)
assert_match("Port should be specified between #{Settings.compose.port_min_value} - #{Settings.compose.port_max_value}", e.message)
end

test '#parse - check if a memory has invalid postfix' do
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_04_12_133608) do
ActiveRecord::Schema.define(version: 2022_04_20_103952) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -151,6 +151,7 @@
t.string "entrypoint"
t.string "command"
t.string "name"
t.jsonb "healthcheck"
t.index ["deployment_id"], name: "index_containers_on_deployment_id"
t.index ["repo_id"], name: "index_containers_on_repo_id"
end
Expand Down

0 comments on commit 372fa5d

Please sign in to comment.