summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-07-11 16:14:28 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-07-11 16:14:28 +0000
commitc7c630f142a23505b4adce449c0a176dec142384 (patch)
tree68025fd231a6f436bff5cf9d8f18c120660831be /lib
parent7bebf9833df83afdb4a83ea5a9c73e9e22225c6e (diff)
parentca692fbcc1b639ea599b5d0fdf80e90e7a6aa5bf (diff)
downloadgitlab-ce-c7c630f142a23505b4adce449c0a176dec142384.tar.gz
Merge branch 'fix-no-method-error-on-nil' into 'master'
Fix an exception seen using the online terminal See merge request gitlab-org/gitlab-ce!18299
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/kubernetes.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb
index da43bd0af4b..15c5ece2350 100644
--- a/lib/gitlab/kubernetes.rb
+++ b/lib/gitlab/kubernetes.rb
@@ -1,6 +1,10 @@
module Gitlab
# Helper methods to do with Kubernetes network services & resources
module Kubernetes
+ def self.build_header_hash
+ Hash.new { |h, k| h[k] = [] }
+ end
+
# This is the comand that is run to start a terminal session. Kubernetes
# expects `command=foo&command=bar, not `command[]=foo&command[]=bar`
EXEC_COMMAND = URI.encode_www_form(
@@ -37,13 +41,14 @@ module Gitlab
selectors: { pod: pod_name, container: container["name"] },
url: container_exec_url(api_url, namespace, pod_name, container["name"]),
subprotocols: ['channel.k8s.io'],
- headers: Hash.new { |h, k| h[k] = [] },
+ headers: ::Gitlab::Kubernetes.build_header_hash,
created_at: created_at
}
end
end
def add_terminal_auth(terminal, token:, max_session_time:, ca_pem: nil)
+ terminal[:headers] ||= ::Gitlab::Kubernetes.build_header_hash
terminal[:headers]['Authorization'] << "Bearer #{token}"
terminal[:max_session_time] = max_session_time
terminal[:ca_pem] = ca_pem if ca_pem.present?