in packages/cli/internal/pkg/cli/context_destroy.go [51:81]
func (o *destroyContextOpts) Validate(contexts []string) error {
o.contexts = append(o.contexts, contexts...)
if (!o.destroyAll && len(o.contexts) == 0) || (o.destroyAll && len(o.contexts) > 0) {
return fmt.Errorf("either an 'all' flag or a list of contexts must be provided, but not both")
}
err := o.validateContexts()
if err != nil {
return err
}
wfsManager := o.wfsManager()
for _, ctx := range o.contexts {
workflows, err := wfsManager.StatusWorkflowByContext(ctx, workflowMaxAllowedInstance)
if err != nil {
return err
}
for _, wf := range workflows {
if wf.IsInstanceRunning() {
if !o.destroyForce {
return fmt.Errorf("context '%s' contains running workflows. "+
"Please stop all workflows before destroying context", ctx)
} else {
wfsManager.StopWorkflowInstance(wf.Id)
}
}
}
}
return nil
}