go vet fixes
This commit is contained in:
@@ -3,17 +3,16 @@ package commands
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cortezaproject/corteza-server/compose/service"
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/pkg/cli"
|
||||
"github.com/cortezaproject/corteza-server/pkg/deinterfacer"
|
||||
"github.com/cortezaproject/corteza-server/pkg/errors"
|
||||
"github.com/cortezaproject/corteza-server/pkg/handle"
|
||||
"github.com/cortezaproject/corteza-server/pkg/rbac"
|
||||
"github.com/cortezaproject/corteza-server/pkg/settings"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
sysExporter "github.com/cortezaproject/corteza-server/system/exporter"
|
||||
sysService "github.com/cortezaproject/corteza-server/system/service"
|
||||
sysTypes "github.com/cortezaproject/corteza-server/system/types"
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/cortezaproject/corteza-server/compose/importer"
|
||||
"github.com/cortezaproject/corteza-server/compose/service"
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/pkg/cli"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
"github.com/cortezaproject/corteza-server/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -490,8 +490,6 @@ func (ctrl Record) Exec(ctx context.Context, r *request.RecordExec) (interface{}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown procedure")
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ctrl *Record) TriggerScript(ctx context.Context, r *request.RecordTriggerScript) (interface{}, error) {
|
||||
|
||||
@@ -29,7 +29,7 @@ func ImportSession() *importSession {
|
||||
}
|
||||
}
|
||||
|
||||
func (svc importSession) indexOf(userID, sessionID uint64) int {
|
||||
func (svc *importSession) indexOf(userID, sessionID uint64) int {
|
||||
for i, r := range svc.records {
|
||||
if r.SessionID == sessionID && r.UserID == userID {
|
||||
return i
|
||||
|
||||
@@ -195,7 +195,7 @@ func (svc notification) procEmailAttachments(ctx context.Context, message *gomai
|
||||
|
||||
for _, url := range aa {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
go func(url string) {
|
||||
defer wg.Done()
|
||||
_ = svc.recordAction(
|
||||
ctx,
|
||||
@@ -203,7 +203,7 @@ func (svc notification) procEmailAttachments(ctx context.Context, message *gomai
|
||||
NotificationActionAttachmentDownload,
|
||||
get(url),
|
||||
)
|
||||
}()
|
||||
}(url)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
@@ -49,7 +49,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (Session) New(ctx context.Context, config *Config, conn *websocket.Conn) *Session {
|
||||
func (*Session) New(ctx context.Context, config *Config, conn *websocket.Conn) *Session {
|
||||
|
||||
s := &Session{
|
||||
conn: conn,
|
||||
@@ -69,7 +69,7 @@ func (Session) New(ctx context.Context, config *Config, conn *websocket.Conn) *S
|
||||
return s
|
||||
}
|
||||
|
||||
func (sess Session) log(fields ...zapcore.Field) *zap.Logger {
|
||||
func (sess *Session) log(fields ...zapcore.Field) *zap.Logger {
|
||||
return sess.logger.With(fields...)
|
||||
}
|
||||
|
||||
|
||||
@@ -587,8 +587,6 @@ func (svc *service) processIterator(script *Script) (ptr uintptr, err error) {
|
||||
default:
|
||||
return 0, fmt.Errorf("incompatible event type (%s) for iterator", i.EventType)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Creates handler function for eventbus subsystem
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ func (e *Error) Apply(ffn ...mfn) *Error {
|
||||
}
|
||||
|
||||
// Is provided Is() method for equality checking with errors.Is
|
||||
func (e Error) Is(target error) bool {
|
||||
func (e *Error) Is(target error) bool {
|
||||
t, ok := target.(*Error)
|
||||
if !ok {
|
||||
return false
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func ExampleSimpleErrorAsText() {
|
||||
func Example_writeHttpPlain() {
|
||||
writeHttpPlain(os.Stdout, fmt.Errorf("dummy error"))
|
||||
|
||||
// Output:
|
||||
@@ -13,14 +13,14 @@ func ExampleSimpleErrorAsText() {
|
||||
// --------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
func ExampleSimpleErrorAsJson() {
|
||||
func Example_writeHttpJSON() {
|
||||
writeHttpJSON(os.Stdout, fmt.Errorf("dummy error"), true)
|
||||
|
||||
// Output:
|
||||
// {"error":{"message":"dummy error"}}
|
||||
}
|
||||
|
||||
func ExampleErrorAsText() {
|
||||
func Example_writeHttpPlain_2() {
|
||||
err := New(0, "dummy error", Meta("a", "b"), Meta(&Error{}, "nope"))
|
||||
err.stack = nil // will not test the stack as file path & line numbers might change
|
||||
writeHttpPlain(os.Stdout, err)
|
||||
@@ -31,7 +31,7 @@ func ExampleErrorAsText() {
|
||||
// --------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
func ExampleErrorAsJson() {
|
||||
func Example_writeHttpJSON_2() {
|
||||
err := New(0, "dummy error", Meta("a", "b"), Meta(&Error{}, "nope"))
|
||||
err.stack = nil // will not test the stack as file path & line numbers might change
|
||||
writeHttpJSON(os.Stdout, err, false)
|
||||
|
||||
@@ -81,7 +81,7 @@ func (rr results) String() string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (rr results) WriteTo(w io.Writer) {
|
||||
func (rr results) WriteTo(w io.Writer) (int64, error) {
|
||||
var (
|
||||
p = func(f string, aa ...interface{}) {
|
||||
_, _ = fmt.Fprintf(w, f, aa...)
|
||||
@@ -103,6 +103,8 @@ func (rr results) WriteTo(w io.Writer) {
|
||||
|
||||
p("\n")
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (r *result) IsHealthy() bool {
|
||||
|
||||
@@ -18,6 +18,4 @@ func fieldToColumnTypeCaster(field rdbms.ModuleFieldTypeDetector, ident string)
|
||||
default:
|
||||
return fmt.Sprintf("rv_%s.value ", ident), nil
|
||||
}
|
||||
|
||||
return ident, nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,4 @@ func fieldToColumnTypeCaster(field rdbms.ModuleFieldTypeDetector, ident string)
|
||||
default:
|
||||
return fmt.Sprintf("rv_%s.value ", ident), nil
|
||||
}
|
||||
|
||||
return ident, nil
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
func TestBuilder(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
cfg = &Config{}
|
||||
)
|
||||
|
||||
upsert, err := UpsertBuilder("tbl", store.Payload{"c1": "v1", "c2": "v2"}, "c1")
|
||||
upsert, err := UpsertBuilder(cfg, "tbl", store.Payload{"c1": "v1", "c2": "v2"}, "c1")
|
||||
req.NoError(err)
|
||||
sql, args, err := upsert.ToSql()
|
||||
req.NoError(err)
|
||||
|
||||
@@ -187,7 +187,7 @@ func (s Store) tryToConnect(ctx context.Context, db *sqlx.DB) error {
|
||||
return err
|
||||
case <-time.After(to):
|
||||
// Wait before next try
|
||||
return fmt.Errorf("timedout after %ds", to.Seconds())
|
||||
return fmt.Errorf("timedout after %.2fs", to.Seconds())
|
||||
case <-ctx.Done():
|
||||
return fmt.Errorf("connection cancelled")
|
||||
}
|
||||
|
||||
@@ -16,6 +16,4 @@ func fieldToColumnTypeCaster(field rdbms.ModuleFieldTypeDetector, ident string)
|
||||
default:
|
||||
return fmt.Sprintf("rv_%s.value ", ident), nil
|
||||
}
|
||||
|
||||
return ident, nil
|
||||
}
|
||||
|
||||
@@ -1023,7 +1023,7 @@ func (svc auth) autoPromote(ctx context.Context, u *types.User) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return store.CreateRoleMember(ctx, svc.store, &types.RoleMember{roleID, u.ID})
|
||||
return store.CreateRoleMember(ctx, svc.store, &types.RoleMember{RoleID: roleID, UserID: u.ID})
|
||||
}()
|
||||
|
||||
return svc.recordAction(ctx, aam, AuthActionAutoPromote, err)
|
||||
|
||||
@@ -2,7 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"github.com/cortezaproject/corteza-server/pkg/errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
@@ -216,7 +216,7 @@ func Test_sink_handleRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
got, err := svc.handleRequest(req)
|
||||
if !errors.Is(err, tt.wantErr) {
|
||||
if tt.wantErr != nil && err != nil && !errors.Is(err, tt.wantErr) {
|
||||
t.Errorf("handleRequest()\n"+
|
||||
" error: %v\n"+
|
||||
"wantErr: %v", err, tt.wantErr)
|
||||
|
||||
@@ -133,9 +133,9 @@ func TestRecordExecOrganize(t *testing.T) {
|
||||
t.Logf("moving 'a' to position '6'")
|
||||
// Move a to the middle
|
||||
h.apiSendRecordExec(module.NamespaceID, module.ID, "organize", request.ProcedureArgs{
|
||||
{"recordID", rr["a"]},
|
||||
{"positionField", "position"},
|
||||
{"position", "6"}}).
|
||||
{Name: "recordID", Value: rr["a"]},
|
||||
{Name: "positionField", Value: "position"},
|
||||
{Name: "position", Value: "6"}}).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
@@ -150,9 +150,9 @@ func TestRecordExecOrganize(t *testing.T) {
|
||||
t.Logf("moving 'i' to position '0'")
|
||||
// Move i to the beginning
|
||||
h.apiSendRecordExec(module.NamespaceID, module.ID, "organize", request.ProcedureArgs{
|
||||
{"recordID", rr["i"]},
|
||||
{"positionField", "position"},
|
||||
{"position", "0"}}).
|
||||
{Name: "recordID", Value: rr["i"]},
|
||||
{Name: "positionField", Value: "position"},
|
||||
{Name: "position", Value: "0"}}).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
@@ -167,10 +167,10 @@ func TestRecordExecOrganize(t *testing.T) {
|
||||
t.Logf("moving 'b' to position '5'")
|
||||
// Move b to the 5th place
|
||||
h.apiSendRecordExec(module.NamespaceID, module.ID, "organize", request.ProcedureArgs{
|
||||
{"recordID", rr["b"]},
|
||||
{"filter", "category = 'CAT1'"},
|
||||
{"positionField", "position"},
|
||||
{"position", "5"}}).
|
||||
{Name: "recordID", Value: rr["b"]},
|
||||
{Name: "filter", Value: "category = 'CAT1'"},
|
||||
{Name: "positionField", Value: "position"},
|
||||
{Name: "position", Value: "5"}}).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
@@ -185,9 +185,9 @@ func TestRecordExecOrganize(t *testing.T) {
|
||||
t.Logf("moving 'b' to category CAT2")
|
||||
// This will keep order of letters but move b to category-2
|
||||
h.apiSendRecordExec(module.NamespaceID, module.ID, "organize", request.ProcedureArgs{
|
||||
{"recordID", rr["b"]},
|
||||
{"groupField", "category"},
|
||||
{"group", "CAT2"}}).
|
||||
{Name: "recordID", Value: rr["b"]},
|
||||
{Name: "groupField", Value: "category"},
|
||||
{Name: "group", Value: "CAT2"}}).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
Reference in New Issue
Block a user