Commit 0d56ebfc authored by David Fernandez's avatar David Fernandez

Merge branch 'helm_longer_channel' into 'master'

Allow longer Helm channel names

See merge request gitlab-org/gitlab!71806
parents 63ed3a22 7e575169
...@@ -12,7 +12,7 @@ module Packages ...@@ -12,7 +12,7 @@ module Packages
validates :channel, validates :channel,
presence: true, presence: true,
length: { maximum: 63 }, length: { maximum: 255 },
format: { with: Gitlab::Regex.helm_channel_regex } format: { with: Gitlab::Regex.helm_channel_regex }
validates :metadata, validates :metadata,
......
# frozen_string_literal: true
class ChangeHelmChannelLength < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_text_limit :packages_helm_file_metadata, :channel, 255, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length_v2')
remove_text_limit :packages_helm_file_metadata, :channel, constraint_name: check_constraint_name(:packages_helm_file_metadata, :channel, 'max_length')
end
def down
# no-op: Danger of failing if there are records with length(channel) > 63
end
end
1e29e4712d81aacf1178996c2dd9e82593be5a2311273800d91640d8eccd38ed
\ No newline at end of file
...@@ -17064,7 +17064,7 @@ CREATE TABLE packages_helm_file_metadata ( ...@@ -17064,7 +17064,7 @@ CREATE TABLE packages_helm_file_metadata (
package_file_id bigint NOT NULL, package_file_id bigint NOT NULL,
channel text NOT NULL, channel text NOT NULL,
metadata jsonb, metadata jsonb,
CONSTRAINT check_c34067922d CHECK ((char_length(channel) <= 63)) CONSTRAINT check_06e8d100af CHECK ((char_length(channel) <= 255))
); );
CREATE TABLE packages_maven_metadata ( CREATE TABLE packages_maven_metadata (
...@@ -131,7 +131,7 @@ module Gitlab ...@@ -131,7 +131,7 @@ module Gitlab
end end
def helm_channel_regex def helm_channel_regex
@helm_channel_regex ||= %r{\A([a-zA-Z0-9](\.|-|_)?){1,63}(?<!\.|-|_)\z}.freeze @helm_channel_regex ||= %r{\A([a-zA-Z0-9](\.|-|_)?){1,255}(?<!\.|-|_)\z}.freeze
end end
def helm_package_regex def helm_package_regex
......
...@@ -657,6 +657,7 @@ RSpec.describe Gitlab::Regex do ...@@ -657,6 +657,7 @@ RSpec.describe Gitlab::Regex do
it { is_expected.to match('my_repo42') } it { is_expected.to match('my_repo42') }
it { is_expected.to match('1.2.3') } it { is_expected.to match('1.2.3') }
it { is_expected.to match('v1.2.3-beta-12') } it { is_expected.to match('v1.2.3-beta-12') }
it { is_expected.to match('renovate_https-github.com-operator-framework-operator-lifecycle-manager.git-0.x') }
# Do not allow empty # Do not allow empty
it { is_expected.not_to match('') } it { is_expected.not_to match('') }
......
...@@ -31,8 +31,8 @@ RSpec.describe Packages::Helm::FileMetadatum, type: :model do ...@@ -31,8 +31,8 @@ RSpec.describe Packages::Helm::FileMetadatum, type: :model do
it 'validates #channel', :aggregate_failures do it 'validates #channel', :aggregate_failures do
is_expected.to validate_presence_of(:channel) is_expected.to validate_presence_of(:channel)
is_expected.to allow_value('a' * 63).for(:channel) is_expected.to allow_value('a' * 255).for(:channel)
is_expected.not_to allow_value('a' * 64).for(:channel) is_expected.not_to allow_value('a' * 256).for(:channel)
is_expected.to allow_value('release').for(:channel) is_expected.to allow_value('release').for(:channel)
is_expected.to allow_value('my-repo').for(:channel) is_expected.to allow_value('my-repo').for(:channel)
......
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