Commit be7d47b0 authored by David Kim's avatar David Kim

Merge branch 'fix-agent-tunnel-address-scheme' into 'master'

Use http(s) for the agent CI tunnel address

See merge request gitlab-org/gitlab!67386
parents de4ac85b f0b71e13
...@@ -41,7 +41,9 @@ module Gitlab ...@@ -41,7 +41,9 @@ module Gitlab
end end
def tunnel_url def tunnel_url
URI.join(external_url, K8S_PROXY_PATH).to_s uri = URI.join(external_url, K8S_PROXY_PATH)
uri.scheme = uri.scheme.in?(%w(grpcs wss)) ? 'https' : 'http'
uri.to_s
end end
# Return GitLab KAS internal_url # Return GitLab KAS internal_url
......
...@@ -66,8 +66,34 @@ RSpec.describe Gitlab::Kas do ...@@ -66,8 +66,34 @@ RSpec.describe Gitlab::Kas do
end end
describe '.tunnel_url' do describe '.tunnel_url' do
it 'returns gitlab_kas external_url with proxy path appended' do before do
expect(described_class.tunnel_url).to eq(Gitlab.config.gitlab_kas.external_url + '/k8s-proxy') stub_config(gitlab_kas: { external_url: external_url })
end
subject { described_class.tunnel_url }
context 'external_url uses wss://' do
let(:external_url) { 'wss://kas.gitlab.example.com' }
it { is_expected.to eq('https://kas.gitlab.example.com/k8s-proxy') }
end
context 'external_url uses ws://' do
let(:external_url) { 'ws://kas.gitlab.example.com' }
it { is_expected.to eq('http://kas.gitlab.example.com/k8s-proxy') }
end
context 'external_url uses grpcs://' do
let(:external_url) { 'grpcs://kas.gitlab.example.com' }
it { is_expected.to eq('https://kas.gitlab.example.com/k8s-proxy') }
end
context 'external_url uses grpc://' do
let(:external_url) { 'grpc://kas.gitlab.example.com' }
it { is_expected.to eq('http://kas.gitlab.example.com/k8s-proxy') }
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