Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
dc8ccbb6
Commit
dc8ccbb6
authored
Jul 25, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of Helm and ApplicationData
parent
628ff2cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
32 deletions
+49
-32
app/models/clusters/applications/helm.rb
app/models/clusters/applications/helm.rb
+29
-21
app/models/clusters/concerns/application_data.rb
app/models/clusters/concerns/application_data.rb
+18
-9
spec/models/clusters/applications/helm_spec.rb
spec/models/clusters/applications/helm_spec.rb
+2
-2
No files found.
app/models/clusters/applications/helm.rb
View file @
dc8ccbb6
...
...
@@ -17,20 +17,7 @@ module Clusters
before_create
:create_keys_and_certs
def
create_keys_and_certs
ca_cert
=
Gitlab
::
Kubernetes
::
Helm
::
Certificate
.
generate_root
self
.
ca_key
=
ca_cert
.
key_string
self
.
ca_cert
=
ca_cert
.
cert_string
end
def
ca_cert_obj
return
unless
has_ssl?
Gitlab
::
Kubernetes
::
Helm
::
Certificate
.
from_strings
(
ca_key
,
ca_cert
)
end
def
issue_cert
def
issue_client_cert
ca_cert_obj
.
issue
end
...
...
@@ -41,21 +28,42 @@ module Clusters
end
def
install_command
tiller_cert
=
ca_cert_obj
.
issue
(
expires_in:
Gitlab
::
Kubernetes
::
Helm
::
Certificate
::
INFINITE_EXPIRY
)
Gitlab
::
Kubernetes
::
Helm
::
InitCommand
.
new
(
name:
name
,
files:
{
'ca.pem'
:
ca_cert
,
'cert.pem'
:
tiller_cert
.
cert_string
,
'key.pem'
:
tiller_cert
.
key_string
}
files:
files
)
end
def
has_ssl?
ca_key
.
present?
&&
ca_cert
.
present?
end
private
def
files
{
'ca.pem'
:
ca_cert
,
'cert.pem'
:
tiller_cert
.
cert_string
,
'key.pem'
:
tiller_cert
.
key_string
}
end
def
create_keys_and_certs
ca_cert
=
Gitlab
::
Kubernetes
::
Helm
::
Certificate
.
generate_root
self
.
ca_key
=
ca_cert
.
key_string
self
.
ca_cert
=
ca_cert
.
cert_string
end
def
tiller_cert
@tiller_cert
||=
ca_cert_obj
.
issue
(
expires_in:
Gitlab
::
Kubernetes
::
Helm
::
Certificate
::
INFINITE_EXPIRY
)
end
def
ca_cert_obj
return
unless
has_ssl?
Gitlab
::
Kubernetes
::
Helm
::
Certificate
.
from_strings
(
ca_key
,
ca_cert
)
end
end
end
end
app/models/clusters/concerns/application_data.rb
View file @
dc8ccbb6
...
...
@@ -15,15 +15,8 @@ module Clusters
def
files
@files
||=
begin
files
=
{
'values.yaml'
:
values
}
if
cluster
.
application_helm
.
has_ssl?
ca_cert
=
cluster
.
application_helm
.
ca_cert
helm_cert
=
cluster
.
application_helm
.
issue_cert
files
.
merge!
({
'ca.pem'
:
ca_cert
,
'cert.pem'
:
helm_cert
.
cert_string
,
'key.pem'
:
helm_cert
.
key_string
})
end
files
.
merge!
(
certificate_files
)
if
cluster
.
application_helm
.
has_ssl?
files
end
...
...
@@ -31,6 +24,22 @@ module Clusters
private
def
certificate_files
{
'ca.pem'
:
ca_cert
,
'cert.pem'
:
helm_cert
.
cert_string
,
'key.pem'
:
helm_cert
.
key_string
}
end
def
ca_cert
cluster
.
application_helm
.
ca_cert
end
def
helm_cert
@helm_cert
||=
cluster
.
application_helm
.
issue_client_cert
end
def
chart_values_file
"
#{
Rails
.
root
}
/vendor/
#{
name
}
/values.yaml"
end
...
...
spec/models/clusters/applications/helm_spec.rb
View file @
dc8ccbb6
...
...
@@ -15,9 +15,9 @@ describe Clusters::Applications::Helm do
it
{
is_expected
.
to
contain_exactly
(
installed_cluster
)
}
end
describe
'#issue_cert'
do
describe
'#issue_c
lient_c
ert'
do
let
(
:application
)
{
create
(
:clusters_applications_helm
)
}
subject
{
application
.
issue_cert
}
subject
{
application
.
issue_c
lient_c
ert
}
it
'returns a new cert'
do
is_expected
.
to
be_kind_of
(
Gitlab
::
Kubernetes
::
Helm
::
Certificate
)
...
...
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