From 40c6128b398f62188e794fe97b4cb545b482e3da Mon Sep 17 00:00:00 2001 From: Alessio Caiazza Date: Mon, 2 Oct 2017 18:55:07 +0200 Subject: [PATCH] Fix broken certificate-authority-data with kubectl >= 1.8.0 --- changelogs/unreleased/fix-kubectl-180.yml | 5 +++++ lib/gitlab/kubernetes.rb | 2 +- spec/fixtures/config/kubeconfig.yml | 2 +- spec/models/project_services/kubernetes_service_spec.rb | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/fix-kubectl-180.yml diff --git a/changelogs/unreleased/fix-kubectl-180.yml b/changelogs/unreleased/fix-kubectl-180.yml new file mode 100644 index 00000000000..beb71cecd57 --- /dev/null +++ b/changelogs/unreleased/fix-kubectl-180.yml @@ -0,0 +1,5 @@ +--- +title: 'Kubernetes integration: ensure v1.8.0 compatibility' +merge_request: 14635 +author: +type: fixed diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb index cdbdfa10d0e..da43bd0af4b 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'] = Base64.encode64(ca_pem) + cluster[:'certificate-authority-data'] = Base64.strict_encode64(ca_pem) end end end diff --git a/spec/fixtures/config/kubeconfig.yml b/spec/fixtures/config/kubeconfig.yml index c4e8e573c32..5152dae0104 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: "UEVN\n" + certificate-authority-data: "UEVN" 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 537cdadd528..2298dcab55f 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -208,7 +208,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do config.dig('users', 0, 'user')['token'] = 'token' config.dig('contexts', 0, 'context')['namespace'] = namespace config.dig('clusters', 0, 'cluster')['certificate-authority-data'] = - Base64.encode64('CA PEM DATA') + Base64.strict_encode64('CA PEM DATA') YAML.dump(config) end