mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-05 08:57:24 +00:00
Fix(workflow): set workload name in configmap if the name is not specified (#2119)
* Fix(workflow): set workload name in configmap if the name is not specified * fix ut
This commit is contained in:
@@ -100,6 +100,9 @@ func (h *AppHandler) createResourcesConfigMap(ctx context.Context,
|
||||
|
||||
// SprintComponentManifest formats and returns the resulting string.
|
||||
func SprintComponentManifest(cm *types.ComponentManifest) string {
|
||||
if cm.StandardWorkload.GetName() == "" {
|
||||
cm.StandardWorkload.SetName(cm.Name)
|
||||
}
|
||||
cl := map[string]interface{}{
|
||||
ManifestKeyWorkload: string(util.MustJSONMarshal(cm.StandardWorkload)),
|
||||
}
|
||||
|
||||
@@ -357,5 +357,5 @@ spec:
|
||||
}
|
||||
`
|
||||
|
||||
testConfigMapComponentValue = `{"test-component":"{\"Scopes\":[],\"StandardWorkload\":\"{\\\"apiVersion\\\":\\\"apps/v1\\\",\\\"kind\\\":\\\"Deployment\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"labels\\\":{\\\"app.oam.dev/appRevision\\\":\\\"test-wf-policy-v1\\\",\\\"app.oam.dev/component\\\":\\\"test-component\\\",\\\"app.oam.dev/name\\\":\\\"test-wf-policy\\\",\\\"workload.oam.dev/type\\\":\\\"worker\\\"}},\\\"spec\\\":{\\\"selector\\\":{\\\"matchLabels\\\":{\\\"app.oam.dev/component\\\":\\\"test-component\\\"}},\\\"template\\\":{\\\"metadata\\\":{\\\"labels\\\":{\\\"app.oam.dev/component\\\":\\\"test-component\\\"}},\\\"spec\\\":{\\\"containers\\\":[{\\\"command\\\":[\\\"sleep\\\",\\\"1000\\\"],\\\"image\\\":\\\"busybox\\\",\\\"name\\\":\\\"test-component\\\"}]}}}}\",\"Traits\":[]}"}`
|
||||
testConfigMapComponentValue = `{"test-component":"{\"Scopes\":[],\"StandardWorkload\":\"{\\\"apiVersion\\\":\\\"apps/v1\\\",\\\"kind\\\":\\\"Deployment\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"labels\\\":{\\\"app.oam.dev/appRevision\\\":\\\"test-wf-policy-v1\\\",\\\"app.oam.dev/component\\\":\\\"test-component\\\",\\\"app.oam.dev/name\\\":\\\"test-wf-policy\\\",\\\"workload.oam.dev/type\\\":\\\"worker\\\"},\\\"name\\\":\\\"test-component\\\"},\\\"spec\\\":{\\\"selector\\\":{\\\"matchLabels\\\":{\\\"app.oam.dev/component\\\":\\\"test-component\\\"}},\\\"template\\\":{\\\"metadata\\\":{\\\"labels\\\":{\\\"app.oam.dev/component\\\":\\\"test-component\\\"}},\\\"spec\\\":{\\\"containers\\\":[{\\\"command\\\":[\\\"sleep\\\",\\\"1000\\\"],\\\"image\\\":\\\"busybox\\\",\\\"name\\\":\\\"test-component\\\"}]}}}}\",\"Traits\":[]}"}`
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user