Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
dc8ccbb6
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc8ccbb6
编写于
7月 25, 2018
作者:
D
Dylan Griffith
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor refactoring of Helm and ApplicationData
上级
628ff2cf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
32 deletion
+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
未找到文件。
app/models/clusters/applications/helm.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录