mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
Feat: Allow gating with components dependsOn field (#6854)
* Fix: Add workflow dynamically when user doesn't define workflow steps but adds dependsOn in the component Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Reetika Malhotra <rmalhotra@guidewire.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * fix: modify ApplyComponentWorkflowStepGenerator Generate function Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Reetika Malhotra <rmalhotra@guidewire.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Feat: Add test cases for the component level dependsOn feature Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Reetika Malhotra <rmalhotra@guidewire.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * <type>: <description> <jira number> [optional body] [optional footer] Signed-off-by: Reetika Malhotra <rmalhotra@guidewire.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Refactor component dependency tests and improve failure handling Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Update environment context handling in application tests and adjust repository name check in setup script Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Chore: Remove .sh file Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Update component dependency test cases and adjust timeout for application status check Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Clean up environment setup in component dependency tests Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: Update component dependency images to use latest version and adjust test cases Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: uncomment tests Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> * Fix: update failing database image to empty string to simulate pull failure Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> --------- Signed-off-by: Chaitanyareddy0702 <chaitanyareddy0702@gmail.com> Signed-off-by: Reetika Malhotra <rmalhotra@guidewire.com> Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com> Co-authored-by: Reetika Malhotra <rmalhotra@guidewire.com> Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8b7950cf61
commit
af1fb9a0fd
@@ -94,7 +94,11 @@ func (s Service) RenderServiceToApplicationComponent(tm template.Manager, servic
|
||||
traits = append(traits, trait)
|
||||
continue
|
||||
}
|
||||
workloadKeys[k] = v
|
||||
if k != "dependsOn" {
|
||||
workloadKeys[k] = v
|
||||
} else {
|
||||
comp.DependsOn = toStringSlice(v)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle workloadKeys to settings
|
||||
@@ -115,6 +119,26 @@ func (s Service) RenderServiceToApplicationComponent(tm template.Manager, servic
|
||||
return comp, nil
|
||||
}
|
||||
|
||||
// toStringSlice converts an interface{} or string to a []string
|
||||
func toStringSlice(v interface{}) []string {
|
||||
switch val := v.(type) {
|
||||
case string:
|
||||
return []string{val}
|
||||
case []string:
|
||||
return val
|
||||
case []interface{}:
|
||||
var result []string
|
||||
for _, item := range val {
|
||||
if s, ok := item.(string); ok {
|
||||
result = append(result, s)
|
||||
}
|
||||
}
|
||||
return result
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetServices will get all services defined in AppFile
|
||||
func (af *AppFile) GetServices() map[string]Service {
|
||||
return af.Services
|
||||
|
||||
Reference in New Issue
Block a user