Skip to content

Commit

Permalink
Fix non-oss cluster version validation malformed version string error (
Browse files Browse the repository at this point in the history
  • Loading branch information
kke authored and jakolehm committed Jan 29, 2019
1 parent 8a26743 commit bee825f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion non-oss/pharos_pro/phases/validate_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Phases
class ValidateVersion < Pharos::Phase
# @param cluster_version [String]
def validate_version(cluster_version)
raise "Downgrade not supported" if Gem::Version.new(cluster_version) > pharos_version
raise "Downgrade not supported" if Gem::Version.new(cluster_version.gsub(/\+.*/, '')) > pharos_version

logger.info { "Valid cluster version detected: #{cluster_version}" }
end
Expand Down
5 changes: 5 additions & 0 deletions non-oss/spec/pharos_pro/phases/validate_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
expect{subject.validate_version('2.0.0')}.not_to raise_error
end

it 'allows upgrade from oss to non-oss' do
stub_const('Pharos::VERSION', '2.0.1-alpha.1')
expect{subject.validate_version('2.0.1-alpha.1+oss')}.not_to raise_error
end

it 'does not allow downgrade on development releases' do
stub_const('Pharos::VERSION', '2.0.0-alpha.1')
expect{subject.validate_version('2.0.0-alpha.2')}.to raise_error(RuntimeError, "Downgrade not supported")
Expand Down

0 comments on commit bee825f

Please sign in to comment.