Skip to content

Commit

Permalink
fix(iamcel): log correct type on mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
radhus committed Oct 20, 2023
1 parent 0bbd922 commit f76af83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions iamcel/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func NewTestFunctionImplementation(
Binary: func(callerVal, resourceVal ref.Val) ref.Val {
caller, ok := callerVal.Value().(*iamv1.Caller)
if !ok {
return types.NewErr("test: unexpected type of arg 1, expected %T but got %T", &iamv1.Caller{}, caller)
return types.NewErr("test: unexpected type of arg 1, expected %T but got %T", &iamv1.Caller{}, callerVal.Value())
}
resource, ok := resourceVal.Value().(string)
if !ok {
return types.NewErr("test: unexpected type of arg 2, expected string but got %T", resource)
return types.NewErr("test: unexpected type of arg 2, expected string but got %T", resourceVal.Value())
}
permission, ok := iampermission.ResolveMethodPermission(options, resource)
if !ok {
Expand Down
6 changes: 5 additions & 1 deletion iamcel/testall.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func NewTestAllFunctionImplementation(
Binary: func(callerVal, resourcesVal ref.Val) ref.Val {
caller, ok := callerVal.Value().(*iamv1.Caller)
if !ok {
return types.NewErr("test_all: unexpected type of arg 1, expected %T but got %T", &iamv1.Caller{}, caller)
return types.NewErr(
"test_all: unexpected type of arg 1, expected %T but got %T",
&iamv1.Caller{},
callerVal.Value(),
)
}
convertedResources, err := resourcesVal.ConvertToNative(reflect.TypeOf([]string(nil)))
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion iamcel/testany.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func NewTestAnyFunctionImplementation(
Binary: func(callerVal, resourcesVal ref.Val) ref.Val {
caller, ok := callerVal.Value().(*iamv1.Caller)
if !ok {
return types.NewErr("test_any: unexpected type of arg 1, expected %T but got %T", &iamv1.Caller{}, caller)
return types.NewErr(
"test_any: unexpected type of arg 1, expected %T but got %T",
&iamv1.Caller{},
callerVal.Value(),
)
}
convertedResources, err := resourcesVal.ConvertToNative(reflect.TypeOf([]string(nil)))
if err != nil {
Expand Down

0 comments on commit f76af83

Please sign in to comment.