SplitWorkflowYAMLFile is a helper to split a body into multiple workflow objects
(ctx context.Context, body []byte, strict bool)
| 120 | |
| 121 | // SplitWorkflowYAMLFile is a helper to split a body into multiple workflow objects |
| 122 | func SplitWorkflowYAMLFile(ctx context.Context, body []byte, strict bool) ([]wfv1.Workflow, error) { |
| 123 | log := logging.RequireLoggerFromContext(ctx) |
| 124 | manifests := make([]wfv1.Workflow, 0) |
| 125 | for _, res := range ParseObjects(ctx, body, strict) { |
| 126 | obj, err := res.Object, res.Err |
| 127 | v, ok := obj.(*wfv1.Workflow) |
| 128 | if !ok { |
| 129 | log.WithField("name", obj.GetName()).Warn(ctx, "Object is not of kind Workflow. Ignoring...") |
| 130 | continue |
| 131 | } |
| 132 | if err != nil { // only returns parsing errors for workflow types |
| 133 | return nil, err |
| 134 | } |
| 135 | manifests = append(manifests, *v) |
| 136 | } |
| 137 | return manifests, nil |
| 138 | } |
| 139 | |
| 140 | // SplitWorkflowTemplateYAMLFile is a helper to split a body into multiple workflow template objects |
| 141 | func SplitWorkflowTemplateYAMLFile(ctx context.Context, body []byte, strict bool) ([]wfv1.WorkflowTemplate, error) { |