Commit 4e8d6507 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'zj-environment-creation-regex-fix' into 'master'

Replace invalid chars while seeding environments

Closes #30855

See merge request !12267
parents 6a3da45a 5eb940da
......@@ -33,7 +33,7 @@ class Gitlab::Seeder::Environments
create_deployment!(
merge_request.source_project,
"review/#{merge_request.source_branch}",
"review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]/, '')}",
merge_request.source_branch,
merge_request.diff_head_sha
)
......
......@@ -43,7 +43,7 @@ module Gitlab
end
def environment_name_regex_message
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces"
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces"
end
def kubernetes_namespace_regex
......
......@@ -20,6 +20,18 @@ describe Gitlab::Regex, lib: true do
it { is_expected.to match('foo@bar') }
end
describe '.environment_slug_regex' do
subject { described_class.environment_name_regex }
it { is_expected.to match('foo') }
it { is_expected.to match('foo-1') }
it { is_expected.to match('FOO') }
it { is_expected.to match('foo/1') }
it { is_expected.to match('foo.1') }
it { is_expected.not_to match('9&foo') }
it { is_expected.not_to match('foo-^') }
end
describe '.environment_slug_regex' do
subject { described_class.environment_slug_regex }
......
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