Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gpt
large_projects
gitlabhq1
Commits
ca692fbc
Unverified
Commit
ca692fbc
authored
7 years ago
by
Nick Thomas
Browse files
Options
Download
Email Patches
Plain Diff
Fix an exception seen using the online terminal
parent
3edda4c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
lib/gitlab/kubernetes.rb
lib/gitlab/kubernetes.rb
+6
-1
spec/lib/gitlab/kubernetes_spec.rb
spec/lib/gitlab/kubernetes_spec.rb
+15
-0
No files found.
lib/gitlab/kubernetes.rb
View file @
ca692fbc
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?
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/kubernetes_spec.rb
View file @
ca692fbc
...
...
@@ -70,4 +70,19 @@ describe Gitlab::Kubernetes do
it
{
is_expected
.
to
eq
(
YAML
.
load_file
(
path
))
}
end
end
describe
'#add_terminal_auth'
do
it
'adds authentication parameters to a hash'
do
terminal
=
{
original:
'value'
}
add_terminal_auth
(
terminal
,
token:
'foo'
,
max_session_time:
0
,
ca_pem:
'bar'
)
expect
(
terminal
).
to
eq
(
original:
'value'
,
headers:
{
'Authorization'
=>
[
'Bearer foo'
]
},
max_session_time:
0
,
ca_pem:
'bar'
)
end
end
end
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment