Skip to content

Commit

Permalink
Add isError flag to response values
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Conner <[email protected]>
  • Loading branch information
knrc committed Apr 26, 2024
1 parent 3c53da9 commit 69588db
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions k8s/evals.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,19 @@ func (lve *lazyVariableEval) evalExpression(env *cel.Env, activation interpreter
type lazyEvalMap map[string]*lazyVariableEval

type EvalVariable struct {
Name string `json:"name"`
Value any `json:"value"`
Cost *uint64 `json:"cost,omitempty"`
Error *string `json:"error,omitempty"`
Name string `json:"name"`
Value any `json:"value"`
Cost *uint64 `json:"cost,omitempty"`
IsError bool `json:"isError"`
Error *string `json:"error,omitempty"`
}

type EvalResult struct {
Name *string `json:"name,omitempty"`
Result any `json:"result,omitempty"`
Cost *uint64 `json:"cost,omitempty"`
Error *string `json:"error,omitempty"`
IsError bool `json:"isError"`
Message any `json:"message,omitempty"`
}

Expand Down Expand Up @@ -152,10 +154,11 @@ func generateEvalVariables(names []string, lazyEvals lazyEvalMap) []*EvalVariabl
if varLazyEval, ok := lazyEvals[name]; ok && varLazyEval.val != nil {
value, err := getResults(&varLazyEval.val.val)
variables = append(variables, &EvalVariable{
Name: varLazyEval.name,
Value: value,
Cost: getCost(varLazyEval.val.details),
Error: err,
Name: varLazyEval.name,
Value: value,
Cost: getCost(varLazyEval.val.details),
Error: err,
IsError: err != nil,
})
}
}
Expand All @@ -181,6 +184,7 @@ func generateEvalResults(responses evalResponses) []*EvalResult {
Result: value,
Cost: getCost(eval.details),
Error: err,
IsError: err != nil,
Message: message,
})
}
Expand Down

0 comments on commit 69588db

Please sign in to comment.