Commit 7f054676 authored by Jonas Wälter's avatar Jonas Wälter Committed by Heinrich Lee Yu

Extend /help/instance_configuration with package file size limits

parent 0f757067
......@@ -14,6 +14,7 @@ class InstanceConfiguration
host: host,
gitlab_pages: gitlab_pages,
gitlab_ci: gitlab_ci,
package_file_size_limits: package_file_size_limits,
rate_limits: rate_limits }.deep_symbolize_keys
end
end
......@@ -44,6 +45,22 @@ class InstanceConfiguration
default: 100.megabytes })
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
{
unauthenticated: {
......
......@@ -8,6 +8,7 @@
= render 'help/instance_configuration/ssh_info'
= render 'help/instance_configuration/gitlab_pages'
= render 'help/instance_configuration/gitlab_ci'
= render 'help/instance_configuration/package_registry'
= render 'help/instance_configuration/rate_limits'
%p
%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 ""
msgid "Generate site and private keys at"
msgstr ""
msgid "Generic"
msgstr ""
msgid "Generic package file size in bytes"
msgstr ""
......@@ -23652,6 +23655,9 @@ msgstr ""
msgid "Package recipe already exists"
msgstr ""
msgid "Package type"
msgstr ""
msgid "Package type must be Conan"
msgstr ""
......@@ -33562,6 +33568,9 @@ msgstr ""
msgid "There are running deployments on the environment. Please retry later."
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."
msgstr ""
......
......@@ -97,6 +97,41 @@ RSpec.describe InstanceConfiguration do
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
before do
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