3
0

Remove pkg/minions and IsNil

Replaced with IsNil fn from modern-go/reflect2
This commit is contained in:
Denis Arh
2022-05-18 12:34:28 +02:00
parent aedab82a47
commit 73266da547
3 changed files with 4 additions and 22 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"strconv"
"github.com/cortezaproject/corteza-server/compose/types"
"github.com/cortezaproject/corteza-server/pkg/minions"
systemTypes "github.com/cortezaproject/corteza-server/system/types"
"github.com/modern-go/reflect2"
"github.com/spf13/cast"
)
@@ -238,7 +238,7 @@ func (r *ComposeModuleField) Resource() interface{} {
// ComposeModuleFieldExtractUserFieldRoles is a helper to extract roles
// from the given filer options.
func ComposeModuleFieldExtractUserFieldRoles(i interface{}) []string {
if minions.IsNil(i) {
if reflect2.IsNil(i) {
return nil
}
-18
View File
@@ -1,18 +0,0 @@
package minions
import "reflect"
// IsNil checks if the given interface is truly nil
//
// Due to how interfaces are handled under-the-hood, a simple i == nil may
// not always be ok.
func IsNil(i interface{}) bool {
if i == nil {
return true
}
switch reflect.TypeOf(i).Kind() {
case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
return reflect.ValueOf(i).IsNil()
}
return false
}
+2 -2
View File
@@ -9,10 +9,10 @@ import (
"github.com/cortezaproject/corteza-server/pkg/expr"
"github.com/cortezaproject/corteza-server/pkg/filter"
"github.com/cortezaproject/corteza-server/pkg/label"
"github.com/cortezaproject/corteza-server/pkg/minions"
rep "github.com/cortezaproject/corteza-server/pkg/report"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
"github.com/modern-go/reflect2"
"github.com/spf13/cast"
)
@@ -475,7 +475,7 @@ func (svc *report) enhance(ctx context.Context, ff []*rep.Frame) (_ []*rep.Frame
for _, r := range f.Rows {
for _, ci := range userCols {
col := r[ci]
if minions.IsNil(col) {
if reflect2.IsNil(col) {
continue
}
switch col.Type() {