From 6ef6f9f205b8bed4ff0af4a353e7b04e0ff0b345 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Wed, 4 Jan 2017 21:24:58 +0100 Subject: Do not check for valid url for .gitlab-ci.yml Until this commit, GitLab would check if the URL in your .gitlab-ci.yml would be valid and adressable. However, this approach is rather limited. To begin, the URL couldn't be http://example:$PORT/my-project, as the PORT value would be interpolated after checking if the URL was valid, which its not. Also this gem will limit the amount of protocols allowed. This commit doesn't check, at all, if the URL is valid. This is now the responsablilty of the user. In my opion this is right, as the user ultimately benefits from a correct URL, but also, its impossible to cover all cases. --- lib/gitlab/ci/config/entry/environment.rb | 1 - spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 13 +++++++++++++ spec/lib/gitlab/ci/config/entry/environment_spec.rb | 17 ----------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/gitlab/ci/config/entry/environment.rb b/lib/gitlab/ci/config/entry/environment.rb index b7b4b91eb51..f7c530c7d9f 100644 --- a/lib/gitlab/ci/config/entry/environment.rb +++ b/lib/gitlab/ci/config/entry/environment.rb @@ -33,7 +33,6 @@ module Gitlab validates :url, length: { maximum: 255 }, - addressable_url: true, allow_nil: true validates :action, diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 62d68721574..f824e2e1efe 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -769,6 +769,19 @@ module Ci expect(builds.first[:environment]).to eq(environment[:name]) expect(builds.first[:options]).to include(environment: environment) end + + context 'the url has a port as variable' do + let(:environment) do + { name: 'production', + url: 'http://production.gitlab.com:$PORT' } + end + + it 'allows a variable for the port' do + expect(builds.size).to eq(1) + expect(builds.first[:environment]).to eq(environment[:name]) + expect(builds.first[:options]).to include(environment: environment) + end + end end context 'when no environment is specified' do diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb index d97806295fb..2adbed2154f 100644 --- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb @@ -196,22 +196,5 @@ describe Gitlab::Ci::Config::Entry::Environment do end end end - - context 'when invalid URL is used' do - let(:config) { { name: 'test', url: 'invalid-example.gitlab.com' } } - - describe '#valid?' do - it 'is not valid' do - expect(entry).not_to be_valid - end - end - - describe '#errors?' do - it 'contains error about invalid URL' do - expect(entry.errors) - .to include "environment url must be a valid url" - end - end - end end end -- cgit v1.2.1