diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 8df293664ce..be3e6a05e1e 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -50,7 +50,7 @@ module Clusters validates :name, cluster_name: true validates :cluster_type, presence: true - validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true, require_valid_tld: true } + validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true } validate :restrict_modification, on: :update validate :no_groups, unless: :group_type? diff --git a/changelogs/unreleased/57650-remove-tld-validation-from-cluster.yml b/changelogs/unreleased/57650-remove-tld-validation-from-cluster.yml new file mode 100644 index 00000000000..683b007a8a1 --- /dev/null +++ b/changelogs/unreleased/57650-remove-tld-validation-from-cluster.yml @@ -0,0 +1,5 @@ +--- +title: Fixes incorrect TLD validation errors for Kubernetes cluster domain +merge_request: 25262 +author: +type: fixed diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index 360030102e0..ef23ffaa843 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -453,7 +453,7 @@ describe Groups::ClustersController do end context 'when domain is invalid' do - let(:domain) { 'not-a-valid-domain' } + let(:domain) { 'http://not-a-valid-domain' } it 'should not update cluster attributes' do go diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 92ce2b0999a..3feed4e9718 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -265,12 +265,12 @@ describe Clusters::Cluster do it { is_expected.to be_valid } end - context 'when cluster has an invalid domain' do - let(:cluster) { build(:cluster, domain: 'not-valid-domain') } + context 'when cluster is not a valid hostname' do + let(:cluster) { build(:cluster, domain: 'http://not.a.valid.hostname') } it 'should add an error on domain' do expect(subject).not_to be_valid - expect(subject.errors[:domain].first).to eq('is not a fully qualified domain name') + expect(subject.errors[:domain].first).to eq('contains invalid characters (valid characters: [a-z0-9\\-])') end end