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