Skip to content

Commit

Permalink
lang: funcs: facts: Add CallableFunc implementation for fact
Browse files Browse the repository at this point in the history
Add an initial implementation for this wrapper function.
  • Loading branch information
purpleidea committed Dec 6, 2023
1 parent 02add7a commit 64fd35b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lang/funcs/facts/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ func (obj *FactFunc) Init(init *interfaces.Init) error {
func (obj *FactFunc) Stream(ctx context.Context) error {
return obj.Fact.Stream(ctx)
}

// Call means this function implements the CallableFunc interface and can be
// called statically if we want to do it speculatively or from a resource.
func (obj *FactFunc) Call(args []types.Value) (types.Value, error) {
if i, j := len(args), 0; i != j {
return nil, fmt.Errorf("arg length doesn't match, got %d, exp: %d", i, j)
}

return obj.Fact.Call()
}

0 comments on commit 64fd35b

Please sign in to comment.