func (w *ContextGraphWalker) ExitEvalTree( v dag.Vertex, output interface{}, err error) error { // Release the semaphore w.Context.parallelSem.Release() if err == nil { return nil } // Acquire the lock because anything is going to require a lock. w.errorLock.Lock() defer w.errorLock.Unlock() // Try to get a validation error out of it. If its not a validation // error, then just record the normal error. verr, ok := err.(*EvalValidateError) if !ok { return err } for _, msg := range verr.Warnings { w.ValidationWarnings = append( w.ValidationWarnings, fmt.Sprintf("%s: %s", dag.VertexName(v), msg)) } for _, e := range verr.Errors { w.ValidationErrors = append( w.ValidationErrors, errwrap.Wrapf(fmt.Sprintf("%s: {{err}}", dag.VertexName(v)), e)) } return nil }
// TODO: test func (n *EvalVariableBlock) Eval(ctx EvalContext) (interface{}, error) { // Clear out the existing mapping for k, _ := range n.Variables { delete(n.Variables, k) } // Get our configuration rc := *n.Config for k, v := range rc.Config { var vStr string if err := mapstructure.WeakDecode(v, &vStr); err != nil { return nil, errwrap.Wrapf(fmt.Sprintf( "%s: error reading value: {{err}}", k), err) } n.Variables[k] = vStr } for k, _ := range rc.Raw { if _, ok := n.Variables[k]; !ok { n.Variables[k] = config.UnknownVariableValue } } return nil, nil }