Check if SSH port is != 22 when building ssh_path_prefix

parent a54853e0
......@@ -35,7 +35,7 @@ module Gitlab
end
def self.primary_ssh_path_prefix
self.cache_value(:geo_primary_ssh_path_prefix) { self.enabled? && self.primary_node && "git@#{self.primary_node.host}:" }
self.cache_value(:geo_primary_ssh_path_prefix) { self.enabled? && self.primary_node && build_primary_ssh_path_prefix }
end
def self.geo_node?(host:, port:)
......@@ -80,5 +80,19 @@ module Gitlab
# urlsafe_base64 may return a string of size * 4/3
SecureRandom.urlsafe_base64(size)[0, size]
end
def self.build_primary_ssh_path_prefix
primary_host = "#{Gitlab.config.gitlab_shell.ssh_user}@#{self.primary_node.host}"
if Gitlab.config.gitlab_shell.ssh_port != 22
"ssh://#{primary_host}:#{Gitlab.config.gitlab_shell.ssh_port}/"
else
if self.primary_node.host.include? ':'
"[#{primary_host}]:"
else
"#{primary_host}:"
end
end
end
end
end
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