Skip to content

Commit

Permalink
Refactoring to return function.FuncError (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Mar 5, 2024
1 parent 5a20d7e commit 3e3bab5
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions internal/framework5provider/bool_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionReq
func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg bool

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/float64_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f Float64Function) Definition(ctx context.Context, req function.Definition
func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg float64

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/int64_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRe
func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg int64

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/list_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f ListFunction) Definition(ctx context.Context, req function.DefinitionReq
func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg []*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/map_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequ
func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg map[string]*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/number_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionR
func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg *big.Float

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/object_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp *
Attr2 *int64 `tfsdk:"attr2"`
}

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/set_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequ
func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg []*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/string_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR
func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework5provider/variadic_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (f VariadicFunction) Definition(ctx context.Context, req function.Definitio
func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var varg []string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...)
resp.Error = req.Arguments.Get(ctx, &varg)

resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, varg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/bool_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionReq
func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg bool

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/float64_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f Float64Function) Definition(ctx context.Context, req function.Definition
func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg float64

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/int64_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRe
func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg int64

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/list_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f ListFunction) Definition(ctx context.Context, req function.DefinitionReq
func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg []*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/map_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequ
func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg map[string]*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/number_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionR
func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg *big.Float

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/object_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp *
Attr2 *int64 `tfsdk:"attr2"`
}

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/set_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequ
func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg []*string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/string_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR
func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/framework6provider/variadic_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (f VariadicFunction) Definition(ctx context.Context, req function.Definitio
func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var varg []string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...)
resp.Error = req.Arguments.Get(ctx, &varg)

resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, varg))
}
4 changes: 2 additions & 2 deletions internal/tf6muxprovider/provider1/function_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR
func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/tf6muxprovider/provider2/function_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR
func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}
4 changes: 2 additions & 2 deletions internal/tf6to5provider/provider/function_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR
func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var arg string

resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...)
resp.Error = req.Arguments.Get(ctx, &arg)

resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...)
resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg))
}

0 comments on commit 3e3bab5

Please sign in to comment.