Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
542eb180
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
542eb180
编写于
3月 24, 2021
作者:
L
LiHui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix: return app creator
Signed-off-by:
N
LiHui
<
andrewli@yunify.com
>
上级
8ca0c86b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
11 deletion
+22
-11
pkg/apis/application/v1alpha1/helmapplication_types.go
pkg/apis/application/v1alpha1/helmapplication_types.go
+4
-0
pkg/controller/openpitrix/helmapplication/helm_application_controller.go
...openpitrix/helmapplication/helm_application_controller.go
+17
-11
pkg/models/openpitrix/utils.go
pkg/models/openpitrix/utils.go
+1
-0
未找到文件。
pkg/apis/application/v1alpha1/helmapplication_types.go
浏览文件 @
542eb180
...
@@ -126,3 +126,7 @@ func (in *HelmApplication) State() string {
...
@@ -126,3 +126,7 @@ func (in *HelmApplication) State() string {
}
}
return
in
.
Status
.
State
return
in
.
Status
.
State
}
}
func
(
in
*
HelmApplication
)
GetCreator
()
string
{
return
getValue
(
in
.
Annotations
,
constants
.
CreatorAnnotationKey
)
}
pkg/controller/openpitrix/helmapplication/helm_application_controller.go
浏览文件 @
542eb180
...
@@ -69,7 +69,7 @@ func (r *ReconcileHelmApplication) Reconcile(request reconcile.Request) (reconci
...
@@ -69,7 +69,7 @@ func (r *ReconcileHelmApplication) Reconcile(request reconcile.Request) (reconci
if
!
sliceutil
.
HasString
(
app
.
ObjectMeta
.
Finalizers
,
appFinalizer
)
{
if
!
sliceutil
.
HasString
(
app
.
ObjectMeta
.
Finalizers
,
appFinalizer
)
{
app
.
ObjectMeta
.
Finalizers
=
append
(
app
.
ObjectMeta
.
Finalizers
,
appFinalizer
)
app
.
ObjectMeta
.
Finalizers
=
append
(
app
.
ObjectMeta
.
Finalizers
,
appFinalizer
)
if
err
:=
r
.
Update
(
rootCtx
,
app
);
err
!=
nil
{
if
err
:=
r
.
Update
(
rootCtx
,
app
);
err
!=
nil
{
return
ctrl
.
Result
{},
err
return
reconcile
.
Result
{},
err
}
}
// create app success
// create app success
appOperationTotal
.
WithLabelValues
(
"creation"
,
app
.
GetTrueName
(),
strconv
.
FormatBool
(
inAppStore
(
app
)))
.
Inc
()
appOperationTotal
.
WithLabelValues
(
"creation"
,
app
.
GetTrueName
(),
strconv
.
FormatBool
(
inAppStore
(
app
)))
.
Inc
()
...
@@ -78,7 +78,11 @@ func (r *ReconcileHelmApplication) Reconcile(request reconcile.Request) (reconci
...
@@ -78,7 +78,11 @@ func (r *ReconcileHelmApplication) Reconcile(request reconcile.Request) (reconci
if
!
inAppStore
(
app
)
{
if
!
inAppStore
(
app
)
{
if
app
.
Status
.
State
==
v1alpha1
.
StateActive
||
if
app
.
Status
.
State
==
v1alpha1
.
StateActive
||
app
.
Status
.
State
==
v1alpha1
.
StateSuspended
{
app
.
Status
.
State
==
v1alpha1
.
StateSuspended
{
return
reconcile
.
Result
{},
r
.
createAppCopyInAppStore
(
rootCtx
,
app
)
if
err
:=
r
.
createAppCopyInAppStore
(
rootCtx
,
app
);
err
!=
nil
{
klog
.
Errorf
(
"create app copy failed, error: %s"
,
err
)
return
reconcile
.
Result
{},
err
}
return
reconcile
.
Result
{},
nil
}
}
}
}
}
else
{
}
else
{
...
@@ -120,9 +124,9 @@ func (r *ReconcileHelmApplication) deleteAppCopyInAppStore(ctx context.Context,
...
@@ -120,9 +124,9 @@ func (r *ReconcileHelmApplication) deleteAppCopyInAppStore(ctx context.Context,
return
nil
return
nil
}
}
// create a application copy in app store
// create
AppCopyInAppStore create
a application copy in app store
func
(
r
*
ReconcileHelmApplication
)
createAppCopyInAppStore
(
ctx
context
.
Context
,
from
*
v1alpha1
.
HelmApplication
)
error
{
func
(
r
*
ReconcileHelmApplication
)
createAppCopyInAppStore
(
ctx
context
.
Context
,
originApp
*
v1alpha1
.
HelmApplication
)
error
{
name
:=
fmt
.
Sprintf
(
"%s%s"
,
from
.
Name
,
v1alpha1
.
HelmApplicationAppStoreSuffix
)
name
:=
fmt
.
Sprintf
(
"%s%s"
,
originApp
.
Name
,
v1alpha1
.
HelmApplicationAppStoreSuffix
)
app
:=
&
v1alpha1
.
HelmApplication
{}
app
:=
&
v1alpha1
.
HelmApplication
{}
err
:=
r
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
name
},
app
)
err
:=
r
.
Get
(
ctx
,
types
.
NamespacedName
{
Name
:
name
},
app
)
...
@@ -132,23 +136,25 @@ func (r *ReconcileHelmApplication) createAppCopyInAppStore(ctx context.Context,
...
@@ -132,23 +136,25 @@ func (r *ReconcileHelmApplication) createAppCopyInAppStore(ctx context.Context,
if
app
.
Name
==
""
{
if
app
.
Name
==
""
{
app
.
Name
=
name
app
.
Name
=
name
labels
:=
from
.
Labels
labels
:=
originApp
.
Labels
if
len
(
labels
)
==
0
{
if
len
(
labels
)
==
0
{
labels
=
make
(
map
[
string
]
string
,
3
)
labels
=
make
(
map
[
string
]
string
,
3
)
}
}
labels
[
constants
.
ChartRepoIdLabelKey
]
=
v1alpha1
.
AppStoreRepoId
labels
[
constants
.
ChartRepoIdLabelKey
]
=
v1alpha1
.
AppStoreRepoId
// assign a category to app
// assign a
default
category to app
if
labels
[
constants
.
CategoryIdLabelKey
]
==
""
{
if
labels
[
constants
.
CategoryIdLabelKey
]
==
""
{
labels
[
constants
.
CategoryIdLabelKey
]
=
v1alpha1
.
UncategorizedId
labels
[
constants
.
CategoryIdLabelKey
]
=
v1alpha1
.
UncategorizedId
}
}
labels
[
v1alpha1
.
OriginWorkspaceLabelKey
]
=
from
.
GetWorkspace
()
// record the original workspace
labels
[
v1alpha1
.
OriginWorkspaceLabelKey
]
=
originApp
.
GetWorkspace
()
// apps in store are global resource.
// apps in store are global resource.
delete
(
labels
,
constants
.
WorkspaceLabelKey
)
delete
(
labels
,
constants
.
WorkspaceLabelKey
)
app
.
Annotations
=
originApp
.
Annotations
app
.
Labels
=
labels
app
.
Labels
=
labels
app
.
Spec
=
*
from
.
Spec
.
DeepCopy
()
app
.
Spec
=
*
originApp
.
Spec
.
DeepCopy
()
err
=
r
.
Create
(
context
.
TODO
(),
app
)
err
=
r
.
Create
(
context
.
TODO
(),
app
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -158,7 +164,7 @@ func (r *ReconcileHelmApplication) createAppCopyInAppStore(ctx context.Context,
...
@@ -158,7 +164,7 @@ func (r *ReconcileHelmApplication) createAppCopyInAppStore(ctx context.Context,
if
app
.
Status
.
State
==
""
{
if
app
.
Status
.
State
==
""
{
// update status if needed
// update status if needed
return
updateHelmApplicationStatus
(
r
.
Client
,
from
.
Name
,
true
)
return
updateHelmApplicationStatus
(
r
.
Client
,
originApp
.
Name
,
true
)
}
}
return
nil
return
nil
...
...
pkg/models/openpitrix/utils.go
浏览文件 @
542eb180
...
@@ -331,6 +331,7 @@ func convertApp(app *v1alpha1.HelmApplication, versions []*v1alpha1.HelmApplicat
...
@@ -331,6 +331,7 @@ func convertApp(app *v1alpha1.HelmApplication, versions []*v1alpha1.HelmApplicat
out
.
Isv
=
app
.
GetWorkspace
()
out
.
Isv
=
app
.
GetWorkspace
()
out
.
ClusterTotal
=
&
rlsCount
out
.
ClusterTotal
=
&
rlsCount
out
.
Owner
=
app
.
GetCreator
()
return
out
return
out
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录