Commit dbb313c2 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Encode certificate-authority-data in base64

parent e7acc881
...@@ -113,7 +113,7 @@ module Gitlab ...@@ -113,7 +113,7 @@ module Gitlab
def kubeconfig_embed_ca_pem(config, ca_pem) def kubeconfig_embed_ca_pem(config, ca_pem)
cluster = config.dig(:clusters, 0, :cluster) cluster = config.dig(:clusters, 0, :cluster)
cluster[:'certificate-authority-data'] = ca_pem cluster[:'certificate-authority-data'] = Base64.encode64(ca_pem)
end end
end end
end end
...@@ -4,7 +4,7 @@ clusters: ...@@ -4,7 +4,7 @@ clusters:
- name: gitlab-deploy - name: gitlab-deploy
cluster: cluster:
server: https://kube.domain.com server: https://kube.domain.com
certificate-authority-data: PEM certificate-authority-data: "UEVN\n"
contexts: contexts:
- name: gitlab-deploy - name: gitlab-deploy
context: context:
......
...@@ -202,10 +202,19 @@ describe KubernetesService, models: true, caching: true do ...@@ -202,10 +202,19 @@ describe KubernetesService, models: true, caching: true do
describe '#predefined_variables' do describe '#predefined_variables' do
let(:kubeconfig) do let(:kubeconfig) do
File.read(expand_fixture_path('config/kubeconfig.yml')) config =
.gsub('TOKEN', 'token') YAML.load(File.read(expand_fixture_path('config/kubeconfig.yml')))
.gsub('PEM', 'CA PEM DATA')
.gsub('NAMESPACE', namespace) config.dig('users', 0, 'user')['token'] =
'token'
config.dig('clusters', 0, 'cluster')['certificate-authority-data'] =
Base64.encode64('CA PEM DATA')
config.dig('contexts', 0, 'context')['namespace'] =
namespace
YAML.dump(config)
end end
before do before do
......
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