mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 10:00:06 +00:00
Fix: Enhance workflow context generation (#6925)
* Feat: Enhance workflow context generation to include application labels and annotations Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Add application labels and annotations to workflow context generation Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: add comments Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> --------- Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com>
This commit is contained in:
committed by
GitHub
parent
af1ce628d1
commit
8aabc9f789
@@ -508,6 +508,7 @@ func getComponentResources(ctx context.Context, manifest *types.ComponentManifes
|
||||
return workload, traits, nil
|
||||
}
|
||||
|
||||
// generateContextDataFromApp builds the process context for workflow (non-component) execution.
|
||||
func generateContextDataFromApp(app *v1beta1.Application, appRev string) velaprocess.ContextData {
|
||||
data := velaprocess.ContextData{
|
||||
Namespace: app.Namespace,
|
||||
@@ -519,5 +520,12 @@ func generateContextDataFromApp(app *v1beta1.Application, appRev string) velapro
|
||||
data.WorkflowName = app.Annotations[oam.AnnotationWorkflowName]
|
||||
data.PublishVersion = app.Annotations[oam.AnnotationPublishVersion]
|
||||
}
|
||||
// pass labels and annotations to workflow context
|
||||
if len(app.Labels) > 0 {
|
||||
data.AppLabels = app.Labels
|
||||
}
|
||||
if len(app.Annotations) > 0 {
|
||||
data.AppAnnotations = app.Annotations
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -289,4 +289,31 @@ var _ = Describe("Test Application workflow generator", func() {
|
||||
_, _, err = handler.GenerateApplicationSteps(logCtx, app, appParser, af)
|
||||
Expect(err).NotTo(BeNil())
|
||||
})
|
||||
|
||||
It("Test workflow context contains app labels and annotations", func() {
|
||||
app := &oamcore.Application{
|
||||
TypeMeta: metav1.TypeMeta{Kind: "Application", APIVersion: "core.oam.dev/v1beta1"},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "app-with-meta",
|
||||
Namespace: namespaceName,
|
||||
Labels: map[string]string{"team": "platform", "env": "prod"},
|
||||
Annotations: map[string]string{"description": "meta test", "owner": "sre"},
|
||||
},
|
||||
Spec: oamcore.ApplicationSpec{Components: []common.ApplicationComponent{}},
|
||||
}
|
||||
ctxData := generateContextDataFromApp(app, "apprev-with-meta")
|
||||
Expect(ctxData.AppLabels).To(Equal(app.Labels))
|
||||
Expect(ctxData.AppAnnotations).To(Equal(app.Annotations))
|
||||
})
|
||||
|
||||
It("Test workflow context empty labels annotations", func() {
|
||||
app := &oamcore.Application{
|
||||
TypeMeta: metav1.TypeMeta{Kind: "Application", APIVersion: "core.oam.dev/v1beta1"},
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "app-without-meta", Namespace: namespaceName},
|
||||
Spec: oamcore.ApplicationSpec{Components: []common.ApplicationComponent{}},
|
||||
}
|
||||
ctxData := generateContextDataFromApp(app, "apprev-without-meta")
|
||||
Expect(ctxData.AppLabels).To(BeNil())
|
||||
Expect(ctxData.AppAnnotations).To(BeNil())
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user