Skip to content
Snippets Groups Projects
Commit f4e8b31b authored by DJ Mountney's avatar DJ Mountney
Browse files

WIP Add an version bump task for the OpenShift template in Omnibus

Added a new to_docker to Version for outputting our Docker tag syntax
Added a new to_i to Version for an integer representation of the version in order to be able to sort through versions
Update the openshift-template.json file in omnibus

TODO:
Add and commit modified file
Tests
parent 2202f57e
No related branches found
No related tags found
1 merge request!120Omnibus-repo release openshift template
Loading
Loading
@@ -5,6 +5,8 @@ require 'time'
module Release
class OmnibusGitLabRelease < BaseRelease
class VersionFileDoesNotExistError < StandardError; end
class TemplateFileDoesNotExistError < StandardError; end
class VersionStringNotFoundError < StandardError; end
class SecurityReleaseInProgressError < StandardError; end
 
# Number of minutes we will be able to reuse the same security repository.
Loading
Loading
@@ -56,6 +58,9 @@ module Release
def before_execute_hook
prepare_security_release if security_release?
 
bump_container_template_versions(stable_branch)
bump_container_template_versions('master')
super
end
 
Loading
Loading
@@ -137,5 +142,44 @@ module Release
 
File.read(gitlab_file_path).strip
end
def bump_container_template_versions(branch)
return if version.ee? || version.rc?
repository.ensure_branch_exists(branch)
openshift_filename = 'docker/openshift-template.json'
openshift_version = Version.new(version_from_container_template(openshift_filename))
unless openshift_version.valid?
raise VersionStringNotFoundError.new(openshift_filename)
end
# Only bump the version if newer that what is already in the template
if version.to_i > openshift_version.to_i
bump_version_in_openshift_template(openshift_filename)
end
end
def version_from_container_template(file_name)
file_path = File.join(repository.path, file_name)
unless File.exist?(file_path)
raise TemplateFileDoesNotExistError.new(file_path)
end
File.open(file_path) { |f| f.read.match(%r{gitlab/gitlab-ce:(\d+\.\d+\.\d+-ce\.\d+)})[1] }
end
def bump_version_in_openshift_template(file_name)
file_path = File.join(repository.path, file_name)
unless File.exist?(file_path)
raise TemplateFileDoesNotExistError.new(file_path)
end
File.open(file_path, 'r+') do |file|
content = file.read
content.gsub!(%r{gitlab/gitlab-ce:\d+\.\d+\.\d+-ce\.\d+}, "gitlab/gitlab-ce:#{version.to_docker}")
content.gsub!(/gitlab-\d+\.\d+\.\d+/, "gitlab-#{version.to_patch}")
file.puts content
end
end
end
end
Loading
Loading
@@ -138,6 +138,10 @@ class Version < String
str << '.0'
end
 
def to_docker(ee: false)
to_omnibus(ee).tr('+', '-')
end
def to_patch
"#{major}.#{minor}.#{patch}"
end
Loading
Loading
@@ -146,6 +150,11 @@ class Version < String
"#{to_patch}-rc#{number}"
end
 
def to_i
raise ArgumentError unless valid?
Integer(to_patch.gsub(/\D/, ''))
end
def valid?
self =~ self.class::VERSION_REGEX
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment