Commit 5fc32509 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'instance-config-package-file-size-limits' into 'master'

Extend /help/instance_configuration with package file size limits

See merge request gitlab-org/gitlab!67869
parents 0d9eb3ba 7f054676
...@@ -14,6 +14,7 @@ class InstanceConfiguration ...@@ -14,6 +14,7 @@ class InstanceConfiguration
host: host, host: host,
gitlab_pages: gitlab_pages, gitlab_pages: gitlab_pages,
gitlab_ci: gitlab_ci, gitlab_ci: gitlab_ci,
package_file_size_limits: package_file_size_limits,
rate_limits: rate_limits }.deep_symbolize_keys rate_limits: rate_limits }.deep_symbolize_keys
end end
end end
...@@ -44,6 +45,22 @@ class InstanceConfiguration ...@@ -44,6 +45,22 @@ class InstanceConfiguration
default: 100.megabytes }) default: 100.megabytes })
end end
def package_file_size_limits
Plan.all.to_h { |plan| [plan.name.capitalize, plan_file_size_limits(plan)] }
end
def plan_file_size_limits(plan)
{
conan: plan.actual_limits[:conan_max_file_size],
maven: plan.actual_limits[:maven_max_file_size],
npm: plan.actual_limits[:npm_max_file_size],
nuget: plan.actual_limits[:nuget_max_file_size],
pypi: plan.actual_limits[:pypi_max_file_size],
terraform_module: plan.actual_limits[:terraform_module_max_file_size],
generic: plan.actual_limits[:generic_packages_max_file_size]
}
end
def rate_limits def rate_limits
{ {
unauthenticated: { unauthenticated: {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
= render 'help/instance_configuration/ssh_info' = render 'help/instance_configuration/ssh_info'
= render 'help/instance_configuration/gitlab_pages' = render 'help/instance_configuration/gitlab_pages'
= render 'help/instance_configuration/gitlab_ci' = render 'help/instance_configuration/gitlab_ci'
= render 'help/instance_configuration/package_registry'
= render 'help/instance_configuration/rate_limits' = render 'help/instance_configuration/rate_limits'
%p %p
%strong= _("Table of contents") %strong= _("Table of contents")
......
- package_file_size_limits = @instance_configuration.settings[:package_file_size_limits]
- content_for :table_content do
- if package_file_size_limits.present?
%li= link_to _('Package Registry'), '#package-registry'
- content_for :settings_content do
- if package_file_size_limits.present?
%h2#package-registry
= _('Package Registry')
%p
= _('There are several file size limits in place for the Package Registry.')
.table-responsive
%table
%thead
%tr
%th= _('Package type')
- package_file_size_limits.each_key do |title|
%th= title
%tbody
%tr
%td= 'Conan'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:conan])
%tr
%td= 'Maven'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:maven])
%tr
%td= 'npm'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:npm])
%tr
%td= 'NuGet'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:nuget])
%tr
%td= 'PyPI'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:pypi])
%tr
%td= 'Terraform Module'
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:terraform_module])
%tr
%td= _('Generic')
- package_file_size_limits.each_value do |limits|
%td= instance_configuration_human_size_cell(limits[:generic])
...@@ -14705,6 +14705,9 @@ msgstr "" ...@@ -14705,6 +14705,9 @@ msgstr ""
msgid "Generate site and private keys at" msgid "Generate site and private keys at"
msgstr "" msgstr ""
msgid "Generic"
msgstr ""
msgid "Generic package file size in bytes" msgid "Generic package file size in bytes"
msgstr "" msgstr ""
...@@ -23652,6 +23655,9 @@ msgstr "" ...@@ -23652,6 +23655,9 @@ msgstr ""
msgid "Package recipe already exists" msgid "Package recipe already exists"
msgstr "" msgstr ""
msgid "Package type"
msgstr ""
msgid "Package type must be Conan" msgid "Package type must be Conan"
msgstr "" msgstr ""
...@@ -33562,6 +33568,9 @@ msgstr "" ...@@ -33562,6 +33568,9 @@ msgstr ""
msgid "There are running deployments on the environment. Please retry later." msgid "There are running deployments on the environment. Please retry later."
msgstr "" msgstr ""
msgid "There are several file size limits in place for the Package Registry."
msgstr ""
msgid "There are several rate limits in place to protect the system." msgid "There are several rate limits in place to protect the system."
msgstr "" msgstr ""
......
...@@ -97,6 +97,41 @@ RSpec.describe InstanceConfiguration do ...@@ -97,6 +97,41 @@ RSpec.describe InstanceConfiguration do
end end
end end
describe '#package_file_size_limits' do
let_it_be(:plan1) { create(:plan, name: 'plan1', title: 'Plan 1') }
let_it_be(:plan2) { create(:plan, name: 'plan2', title: 'Plan 2') }
before do
create(:plan_limits,
plan: plan1,
conan_max_file_size: 1001,
maven_max_file_size: 1002,
npm_max_file_size: 1003,
nuget_max_file_size: 1004,
pypi_max_file_size: 1005,
terraform_module_max_file_size: 1006,
generic_packages_max_file_size: 1007
)
create(:plan_limits,
plan: plan2,
conan_max_file_size: 1101,
maven_max_file_size: 1102,
npm_max_file_size: 1103,
nuget_max_file_size: 1104,
pypi_max_file_size: 1105,
terraform_module_max_file_size: 1106,
generic_packages_max_file_size: 1107
)
end
it 'returns package file size limits' do
file_size_limits = subject.settings[:package_file_size_limits]
expect(file_size_limits[:Plan1]).to eq({ conan: 1001, maven: 1002, npm: 1003, nuget: 1004, pypi: 1005, terraform_module: 1006, generic: 1007 })
expect(file_size_limits[:Plan2]).to eq({ conan: 1101, maven: 1102, npm: 1103, nuget: 1104, pypi: 1105, terraform_module: 1106, generic: 1107 })
end
end
describe '#rate_limits' do describe '#rate_limits' do
before do before do
Gitlab::CurrentSettings.current_application_settings.update!( Gitlab::CurrentSettings.current_application_settings.update!(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment