Commit c4e9c384 authored by Mathieu Parent's avatar Mathieu Parent
parent 23603d56
......@@ -47,6 +47,7 @@ class Packages::Package < ApplicationRecord
validate :package_already_taken, if: :npm?
validates :name, format: { with: Gitlab::Regex.conan_recipe_component_regex }, if: :conan?
validates :name, format: { with: Gitlab::Regex.generic_package_name_regex }, if: :generic?
validates :name, format: { with: Gitlab::Regex.helm_package_regex }, if: :helm?
validates :name, format: { with: Gitlab::Regex.npm_package_name_regex }, if: :npm?
validates :name, format: { with: Gitlab::Regex.nuget_package_name_regex }, if: :nuget?
validates :name, format: { with: Gitlab::Regex.debian_package_name_regex }, if: :debian_package?
......@@ -56,6 +57,7 @@ class Packages::Package < ApplicationRecord
validates :version, format: { with: Gitlab::Regex.maven_version_regex }, if: -> { version? && maven? }
validates :version, format: { with: Gitlab::Regex.pypi_version_regex }, if: :pypi?
validates :version, format: { with: Gitlab::Regex.prefixed_semver_regex }, if: :golang?
validates :version, format: { with: Gitlab::Regex.prefixed_semver_regex }, if: :helm?
validates :version, format: { with: Gitlab::Regex.semver_regex }, if: -> { composer_tag_version? || npm? }
validates :version,
......@@ -70,7 +72,7 @@ class Packages::Package < ApplicationRecord
enum package_type: { maven: 1, npm: 2, conan: 3, nuget: 4, pypi: 5,
composer: 6, generic: 7, golang: 8, debian: 9,
rubygems: 10 }
rubygems: 10, helm: 11 }
enum status: { default: 0, hidden: 1, processing: 2, error: 3 }
......
# frozen_string_literal: true
class AddHelmMaxFileSizeToPlanLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :plan_limits, :helm_max_file_size, :bigint, default: 5.megabyte, null: false
end
end
3f9e229fc13075c2a2d42931b163c8069089458d66bc565609b393e07460f25d
\ No newline at end of file
......@@ -16015,7 +16015,8 @@ CREATE TABLE plan_limits (
pull_mirror_interval_seconds integer DEFAULT 300 NOT NULL,
daily_invites integer DEFAULT 0 NOT NULL,
rubygems_max_file_size bigint DEFAULT '3221225472'::bigint NOT NULL,
terraform_module_max_file_size bigint DEFAULT 1073741824 NOT NULL
terraform_module_max_file_size bigint DEFAULT 1073741824 NOT NULL,
helm_max_file_size bigint DEFAULT 5242880 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq
......@@ -13930,6 +13930,7 @@ Values for sorting package.
| <a id="packagetypeenumdebian"></a>`DEBIAN` | Packages from the Debian package manager. |
| <a id="packagetypeenumgeneric"></a>`GENERIC` | Packages from the Generic package manager. |
| <a id="packagetypeenumgolang"></a>`GOLANG` | Packages from the Golang package manager. |
| <a id="packagetypeenumhelm"></a>`HELM` | Packages from the Helm package manager. |
| <a id="packagetypeenummaven"></a>`MAVEN` | Packages from the Maven package manager. |
| <a id="packagetypeenumnpm"></a>`NPM` | Packages from the npm package manager. |
| <a id="packagetypeenumnuget"></a>`NUGET` | Packages from the Nuget package manager. |
......
......@@ -94,6 +94,12 @@ FactoryBot.define do
end
end
factory :helm_package do
sequence(:name) { |n| "package-#{n}" }
sequence(:version) { |n| "v1.0.#{n}" }
package_type { :helm }
end
factory :npm_package do
sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"}
version { '1.0.0' }
......
......@@ -4,6 +4,6 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['PackageTypeEnum'] do
it 'exposes all package types' do
expect(described_class.values.keys).to contain_exactly(*%w[MAVEN NPM CONAN NUGET PYPI COMPOSER GENERIC GOLANG DEBIAN RUBYGEMS])
expect(described_class.values.keys).to contain_exactly(*%w[MAVEN NPM CONAN NUGET PYPI COMPOSER GENERIC GOLANG DEBIAN RUBYGEMS HELM])
end
end
......@@ -173,6 +173,15 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.not_to allow_value('!!().for(:name)().for(:name)').for(:name) }
end
context 'helm package' do
subject { build(:helm_package) }
it { is_expected.to allow_value('prometheus').for(:name) }
it { is_expected.to allow_value('rook-ceph').for(:name) }
it { is_expected.not_to allow_value('a+b').for(:name) }
it { is_expected.not_to allow_value('Hé').for(:name) }
end
context 'nuget package' do
subject { build_stubbed(:nuget_package) }
......@@ -376,6 +385,15 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.not_to allow_value(nil).for(:version) }
end
context 'helm package' do
subject { build_stubbed(:helm_package) }
it { is_expected.not_to allow_value(nil).for(:version) }
it { is_expected.not_to allow_value('').for(:version) }
it { is_expected.to allow_value('v1.2.3').for(:version) }
it { is_expected.not_to allow_value('1.2.3').for(:version) }
end
it_behaves_like 'validating version to be SemVer compliant for', :npm_package
context 'nuget package' do
......
......@@ -203,7 +203,8 @@ RSpec.shared_examples 'filters on each package_type' do |is_project: false|
let_it_be(:package7) { create(:generic_package, project: project) }
let_it_be(:package8) { create(:golang_package, project: project) }
let_it_be(:package9) { create(:debian_package, project: project) }
let_it_be(:package9) { create(:rubygems_package, project: project) }
let_it_be(:package10) { create(:rubygems_package, project: project) }
let_it_be(:package11) { create(:helm_package, project: project) }
Packages::Package.package_types.keys.each do |package_type|
context "for package type #{package_type}" do
......
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