summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-07-06 19:38:41 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-07-06 19:38:41 +0800
commitdbb313c26f79e5bebf197af8eba24411fced51bb (patch)
tree3b1e489f44eca92fda81083ca8c64bacbdd02cae
parente7acc88156116bbfc20d13b5d897492cc415ee38 (diff)
downloadgitlab-ce-dbb313c26f79e5bebf197af8eba24411fced51bb.tar.gz
Encode certificate-authority-data in base64
-rw-r--r--lib/gitlab/kubernetes.rb2
-rw-r--r--spec/fixtures/config/kubeconfig.yml2
-rw-r--r--spec/models/project_services/kubernetes_service_spec.rb17
3 files changed, 15 insertions, 6 deletions
diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb
index 88bae87211a..cdbdfa10d0e 100644
--- a/lib/gitlab/kubernetes.rb
+++ b/lib/gitlab/kubernetes.rb
@@ -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
diff --git a/spec/fixtures/config/kubeconfig.yml b/spec/fixtures/config/kubeconfig.yml
index 4fa52818fee..c4e8e573c32 100644
--- a/spec/fixtures/config/kubeconfig.yml
+++ b/spec/fixtures/config/kubeconfig.yml
@@ -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:
diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb
index 7ec2ea5ba95..5ba523a478a 100644
--- a/spec/models/project_services/kubernetes_service_spec.rb
+++ b/spec/models/project_services/kubernetes_service_spec.rb
@@ -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