chore(ci): update go-tools
parent
11aae144b2
commit
19fe098888
|
@ -120,12 +120,12 @@ jobs:
|
|||
- run: make vet
|
||||
- run: make checkfmt
|
||||
- run: make checktidy
|
||||
- run: GOTRACEBACK=all GO111MODULE=on gotestsum --format standard-verbose --junitfile /tmp/test-results/gotestsum.xml -- -race -count=1 ./...
|
||||
# TODO add these checks to the Makefile
|
||||
# - run: go get -v -t -d ./...
|
||||
- run: GO111MODULE=on go mod vendor # staticcheck looks in vendor for dependencies.
|
||||
- run: GO111MODULE=on go install honnef.co/go/tools/cmd/staticcheck # Install staticcheck from the version we specify in go.mod.
|
||||
- run: staticcheck ./...
|
||||
- run: GOTRACEBACK=all GO111MODULE=on gotestsum --format standard-verbose --junitfile /tmp/test-results/gotestsum.xml -- -race -count=1 ./...
|
||||
# TODO add these checks to the Makefile
|
||||
# - run: go get -v -t -d ./...
|
||||
|
||||
- save_cache:
|
||||
name: Saving GOCACHE
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/influxdata/flux"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
platcontext "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/kit/tracing"
|
||||
"github.com/influxdata/influxdb/query"
|
||||
|
@ -16,8 +15,8 @@ import (
|
|||
|
||||
type authError struct {
|
||||
error
|
||||
perm platform.Permission
|
||||
auth platform.Authorizer
|
||||
perm influxdb.Permission
|
||||
auth influxdb.Authorizer
|
||||
}
|
||||
|
||||
func (ae *authError) AuthzError() error {
|
||||
|
@ -37,14 +36,14 @@ var (
|
|||
)
|
||||
|
||||
type taskServiceValidator struct {
|
||||
platform.TaskService
|
||||
influxdb.TaskService
|
||||
preAuth query.PreAuthorizer
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// TaskService wraps ts and checks appropriate permissions before calling requested methods on ts.
|
||||
// Authorization failures are logged to the logger.
|
||||
func NewTaskService(logger *zap.Logger, ts platform.TaskService, bs platform.BucketService) platform.TaskService {
|
||||
func NewTaskService(logger *zap.Logger, ts influxdb.TaskService, bs influxdb.BucketService) influxdb.TaskService {
|
||||
return &taskServiceValidator{
|
||||
TaskService: ts,
|
||||
preAuth: query.NewPreAuthorizer(bs),
|
||||
|
@ -52,7 +51,7 @@ func NewTaskService(logger *zap.Logger, ts platform.TaskService, bs platform.Buc
|
|||
}
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) FindTaskByID(ctx context.Context, id platform.ID) (*platform.Task, error) {
|
||||
func (ts *taskServiceValidator) FindTaskByID(ctx context.Context, id influxdb.ID) (*influxdb.Task, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -62,7 +61,7 @@ func (ts *taskServiceValidator) FindTaskByID(ctx context.Context, id platform.ID
|
|||
return nil, err
|
||||
}
|
||||
|
||||
perm, err := platform.NewPermissionAtID(id, platform.ReadAction, platform.TasksResourceType, task.OrganizationID)
|
||||
perm, err := influxdb.NewPermissionAtID(id, influxdb.ReadAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ func (ts *taskServiceValidator) FindTaskByID(ctx context.Context, id platform.ID
|
|||
return task, nil
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) FindTasks(ctx context.Context, filter platform.TaskFilter) ([]*platform.Task, int, error) {
|
||||
func (ts *taskServiceValidator) FindTasks(ctx context.Context, filter influxdb.TaskFilter) ([]*influxdb.Task, int, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -95,9 +94,9 @@ func (ts *taskServiceValidator) FindTasks(ctx context.Context, filter platform.T
|
|||
}
|
||||
|
||||
// Then, filter down to what the user is allowed to see.
|
||||
tasks := make([]*platform.Task, 0, len(unauthenticatedTasks))
|
||||
tasks := make([]*influxdb.Task, 0, len(unauthenticatedTasks))
|
||||
for _, t := range unauthenticatedTasks {
|
||||
perm, err := platform.NewPermissionAtID(t.ID, platform.ReadAction, platform.TasksResourceType, t.OrganizationID)
|
||||
perm, err := influxdb.NewPermissionAtID(t.ID, influxdb.ReadAction, influxdb.TasksResourceType, t.OrganizationID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ func (ts *taskServiceValidator) FindTasks(ctx context.Context, filter platform.T
|
|||
return tasks, len(tasks), nil
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) CreateTask(ctx context.Context, t platform.TaskCreate) (*platform.Task, error) {
|
||||
func (ts *taskServiceValidator) CreateTask(ctx context.Context, t influxdb.TaskCreate) (*influxdb.Task, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -126,7 +125,7 @@ func (ts *taskServiceValidator) CreateTask(ctx context.Context, t platform.TaskC
|
|||
return nil, influxdb.ErrInvalidTaskType
|
||||
}
|
||||
|
||||
p, err := platform.NewPermission(platform.WriteAction, platform.TasksResourceType, t.OrganizationID)
|
||||
p, err := influxdb.NewPermission(influxdb.WriteAction, influxdb.TasksResourceType, t.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -143,7 +142,7 @@ func (ts *taskServiceValidator) CreateTask(ctx context.Context, t platform.TaskC
|
|||
return ts.TaskService.CreateTask(ctx, t)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) UpdateTask(ctx context.Context, id platform.ID, upd platform.TaskUpdate) (*platform.Task, error) {
|
||||
func (ts *taskServiceValidator) UpdateTask(ctx context.Context, id influxdb.ID, upd influxdb.TaskUpdate) (*influxdb.Task, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -153,7 +152,7 @@ func (ts *taskServiceValidator) UpdateTask(ctx context.Context, id platform.ID,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(id, platform.WriteAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(id, influxdb.WriteAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -173,7 +172,7 @@ func (ts *taskServiceValidator) UpdateTask(ctx context.Context, id platform.ID,
|
|||
return ts.TaskService.UpdateTask(ctx, id, upd)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) DeleteTask(ctx context.Context, id platform.ID) error {
|
||||
func (ts *taskServiceValidator) DeleteTask(ctx context.Context, id influxdb.ID) error {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -183,7 +182,7 @@ func (ts *taskServiceValidator) DeleteTask(ctx context.Context, id platform.ID)
|
|||
return err
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(id, platform.WriteAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(id, influxdb.WriteAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -197,7 +196,7 @@ func (ts *taskServiceValidator) DeleteTask(ctx context.Context, id platform.ID)
|
|||
return ts.TaskService.DeleteTask(ctx, id)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) FindLogs(ctx context.Context, filter platform.LogFilter) ([]*platform.Log, int, error) {
|
||||
func (ts *taskServiceValidator) FindLogs(ctx context.Context, filter influxdb.LogFilter) ([]*influxdb.Log, int, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -210,7 +209,7 @@ func (ts *taskServiceValidator) FindLogs(ctx context.Context, filter platform.Lo
|
|||
return ts.TaskService.FindLogs(ctx, filter)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) FindRuns(ctx context.Context, filter platform.RunFilter) ([]*platform.Run, int, error) {
|
||||
func (ts *taskServiceValidator) FindRuns(ctx context.Context, filter influxdb.RunFilter) ([]*influxdb.Run, int, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -220,7 +219,7 @@ func (ts *taskServiceValidator) FindRuns(ctx context.Context, filter platform.Ru
|
|||
return nil, -1, err
|
||||
}
|
||||
|
||||
perm, err := platform.NewPermissionAtID(task.ID, platform.ReadAction, platform.TasksResourceType, task.OrganizationID)
|
||||
perm, err := influxdb.NewPermissionAtID(task.ID, influxdb.ReadAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
@ -235,7 +234,7 @@ func (ts *taskServiceValidator) FindRuns(ctx context.Context, filter platform.Ru
|
|||
return ts.TaskService.FindRuns(ctx, filter)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) FindRunByID(ctx context.Context, taskID, runID platform.ID) (*platform.Run, error) {
|
||||
func (ts *taskServiceValidator) FindRunByID(ctx context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -245,7 +244,7 @@ func (ts *taskServiceValidator) FindRunByID(ctx context.Context, taskID, runID p
|
|||
return nil, err
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(taskID, platform.ReadAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(taskID, influxdb.ReadAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -259,7 +258,7 @@ func (ts *taskServiceValidator) FindRunByID(ctx context.Context, taskID, runID p
|
|||
return ts.TaskService.FindRunByID(ctx, taskID, runID)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) CancelRun(ctx context.Context, taskID, runID platform.ID) error {
|
||||
func (ts *taskServiceValidator) CancelRun(ctx context.Context, taskID, runID influxdb.ID) error {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -269,7 +268,7 @@ func (ts *taskServiceValidator) CancelRun(ctx context.Context, taskID, runID pla
|
|||
return err
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(taskID, platform.WriteAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(taskID, influxdb.WriteAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -283,7 +282,7 @@ func (ts *taskServiceValidator) CancelRun(ctx context.Context, taskID, runID pla
|
|||
return ts.TaskService.CancelRun(ctx, taskID, runID)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) RetryRun(ctx context.Context, taskID, runID platform.ID) (*platform.Run, error) {
|
||||
func (ts *taskServiceValidator) RetryRun(ctx context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -297,7 +296,7 @@ func (ts *taskServiceValidator) RetryRun(ctx context.Context, taskID, runID plat
|
|||
return nil, ErrInactiveTask
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(taskID, platform.WriteAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(taskID, influxdb.WriteAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ func (ts *taskServiceValidator) RetryRun(ctx context.Context, taskID, runID plat
|
|||
return ts.TaskService.RetryRun(ctx, taskID, runID)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) ForceRun(ctx context.Context, taskID platform.ID, scheduledFor int64) (*platform.Run, error) {
|
||||
func (ts *taskServiceValidator) ForceRun(ctx context.Context, taskID influxdb.ID, scheduledFor int64) (*influxdb.Run, error) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
|
@ -325,7 +324,7 @@ func (ts *taskServiceValidator) ForceRun(ctx context.Context, taskID platform.ID
|
|||
return nil, ErrInactiveTask
|
||||
}
|
||||
|
||||
p, err := platform.NewPermissionAtID(taskID, platform.WriteAction, platform.TasksResourceType, task.OrganizationID)
|
||||
p, err := influxdb.NewPermissionAtID(taskID, influxdb.WriteAction, influxdb.TasksResourceType, task.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -339,7 +338,7 @@ func (ts *taskServiceValidator) ForceRun(ctx context.Context, taskID platform.ID
|
|||
return ts.TaskService.ForceRun(ctx, taskID, scheduledFor)
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) validatePermission(ctx context.Context, perm platform.Permission, loggerFields ...zap.Field) error {
|
||||
func (ts *taskServiceValidator) validatePermission(ctx context.Context, perm influxdb.Permission, loggerFields ...zap.Field) error {
|
||||
auth, err := platcontext.GetAuthorizer(ctx)
|
||||
if err != nil {
|
||||
ts.logger.With(loggerFields...).Info("Failed to retrieve authorizer from context")
|
||||
|
@ -359,7 +358,7 @@ func (ts *taskServiceValidator) validatePermission(ctx context.Context, perm pla
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ts *taskServiceValidator) validateBucket(ctx context.Context, script string, orgID platform.ID, loggerFields ...zap.Field) error {
|
||||
func (ts *taskServiceValidator) validateBucket(ctx context.Context, script string, orgID influxdb.ID, loggerFields ...zap.Field) error {
|
||||
auth, err := platcontext.GetAuthorizer(ctx)
|
||||
if err != nil {
|
||||
ts.logger.With(loggerFields...).Info("Failed to retrieve authorizer from context")
|
||||
|
@ -368,10 +367,10 @@ func (ts *taskServiceValidator) validateBucket(ctx context.Context, script strin
|
|||
|
||||
ast, err := flux.Parse(script)
|
||||
if err != nil {
|
||||
return platform.NewError(
|
||||
platform.WithErrorErr(err),
|
||||
platform.WithErrorMsg("Failed to compile flux script."),
|
||||
platform.WithErrorCode(platform.EInvalid))
|
||||
return influxdb.NewError(
|
||||
influxdb.WithErrorErr(err),
|
||||
influxdb.WithErrorMsg("Failed to compile flux script."),
|
||||
influxdb.WithErrorCode(influxdb.EInvalid))
|
||||
}
|
||||
|
||||
if err := ts.preAuth.PreAuthorize(ctx, ast, auth, &orgID); err != nil {
|
||||
|
@ -382,15 +381,15 @@ func (ts *taskServiceValidator) validateBucket(ctx context.Context, script strin
|
|||
zap.String("auth_id", auth.Identifier().String()),
|
||||
)
|
||||
|
||||
// if error is already a platform error then return it
|
||||
if perr, ok := err.(*platform.Error); ok {
|
||||
// if error is already a influxdb.error then return it
|
||||
if perr, ok := err.(*influxdb.Error); ok {
|
||||
return perr
|
||||
}
|
||||
|
||||
return platform.NewError(
|
||||
platform.WithErrorErr(err),
|
||||
platform.WithErrorMsg("Failed to create task."),
|
||||
platform.WithErrorCode(platform.EUnauthorized))
|
||||
return influxdb.NewError(
|
||||
influxdb.WithErrorErr(err),
|
||||
influxdb.WithErrorMsg("Failed to create task."),
|
||||
influxdb.WithErrorCode(influxdb.EUnauthorized))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
"github.com/influxdata/influxdb/authorizer"
|
||||
pctx "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/http"
|
||||
|
@ -256,7 +255,7 @@ from(bucket:"holder") |> range(start:-5m) |> to(bucket:"holder", org:"thing")`,
|
|||
check: func(ctx context.Context, svc influxdb.TaskService) error {
|
||||
var (
|
||||
expMsg = "Failed to create task."
|
||||
expCode = platform.EUnauthorized
|
||||
expCode = influxdb.EUnauthorized
|
||||
errfmt = "expected %q, got %q"
|
||||
_, err = svc.CreateTask(ctx, influxdb.TaskCreate{
|
||||
OrganizationID: r.Org.ID,
|
||||
|
@ -275,7 +274,7 @@ from(bucket:"bad") |> range(start:-5m) |> to(bucket:"bad", org:"thing")`,
|
|||
|
||||
perr, ok := err.(*influxdb.Error)
|
||||
if !ok {
|
||||
return fmt.Errorf(errfmt, &platform.Error{}, err)
|
||||
return fmt.Errorf(errfmt, &influxdb.Error{}, err)
|
||||
}
|
||||
|
||||
if perr.Code != expCode {
|
||||
|
@ -304,7 +303,7 @@ from(bucket:"bad") |> range(start:-5m) |> to(bucket:"bad", org:"thing")`,
|
|||
var (
|
||||
expMsg = "Failed to compile flux script."
|
||||
expErr = fmt.Errorf("error calling function \"to\": missing required keyword argument \"orgID\"")
|
||||
expCode = platform.EInvalid
|
||||
expCode = influxdb.EInvalid
|
||||
errfmt = "expected %q, got %q"
|
||||
_, err = svc.CreateTask(ctx, influxdb.TaskCreate{
|
||||
OrganizationID: r.Org.ID,
|
||||
|
@ -323,7 +322,7 @@ from(bucket:"bad") |> range(start:-5m) |> to(bucket:"bad")`,
|
|||
|
||||
perr, ok := err.(*influxdb.Error)
|
||||
if !ok {
|
||||
return fmt.Errorf(errfmt, &platform.Error{}, err)
|
||||
return fmt.Errorf(errfmt, &influxdb.Error{}, err)
|
||||
}
|
||||
|
||||
if perr.Code != expCode {
|
||||
|
@ -496,7 +495,7 @@ from(bucket:"cows") |> range(start:-5m) |> to(bucket:"other_bucket", org:"other_
|
|||
|
||||
perr, ok := err.(*influxdb.Error)
|
||||
if !ok {
|
||||
return fmt.Errorf("expected platform error, got %q of type %T", err, err)
|
||||
return fmt.Errorf("expected influxdb.error, got %q of type %T", err, err)
|
||||
}
|
||||
|
||||
if perr.Code != influxdb.EUnauthorized {
|
||||
|
@ -507,9 +506,9 @@ from(bucket:"cows") |> range(start:-5m) |> to(bucket:"other_bucket", org:"other_
|
|||
return fmt.Errorf(`expected "Failed to authorize.", got %q`, perr.Msg)
|
||||
}
|
||||
|
||||
cerr, ok := errors.Cause(perr.Err).(*platform.Error)
|
||||
cerr, ok := errors.Cause(perr.Err).(*influxdb.Error)
|
||||
if !ok {
|
||||
return fmt.Errorf("expected platform error, got %q of type %T", perr.Err, perr.Err)
|
||||
return fmt.Errorf("expected influxdb.error, got %q of type %T", perr.Err, perr.Err)
|
||||
}
|
||||
|
||||
if cerr.Code != influxdb.ENotFound {
|
||||
|
|
10
go.mod
10
go.mod
|
@ -88,20 +88,20 @@ require (
|
|||
github.com/yudai/pp v2.0.1+incompatible // indirect
|
||||
go.uber.org/multierr v1.1.0
|
||||
go.uber.org/zap v1.9.1
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
|
||||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
|
||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac
|
||||
google.golang.org/api v0.0.0-20181021000519-a2651947f503
|
||||
google.golang.org/grpc v1.19.1
|
||||
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0 // indirect
|
||||
gopkg.in/ini.v1 v1.42.0 // indirect
|
||||
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5
|
||||
gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect
|
||||
honnef.co/go/tools v0.0.0-20190319011948-d116c56a00f3
|
||||
honnef.co/go/tools v0.0.0-20190812140558-8bd8df698242 // indirect
|
||||
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect
|
||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
|
||||
)
|
||||
|
|
18
go.sum
18
go.sum
|
@ -145,6 +145,7 @@ github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4r
|
|||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
|
||||
|
@ -340,6 +341,7 @@ github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 h1:Cto4X6SVMWRPB
|
|||
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE=
|
||||
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||
|
@ -416,6 +418,8 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72
|
|||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20181112044915-a3060d491354 h1:6UAgZ8309zQ9+1iWkHzfszFguqzOdHGyGkd1HmhJ+UE=
|
||||
golang.org/x/exp v0.0.0-20181112044915-a3060d491354/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@ -423,6 +427,7 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/
|
|||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
@ -443,6 +448,8 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -457,6 +464,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv
|
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e h1:nFYrTHrdrAOpShe27kaFHjsqYSEQ0KWqdWLu3xuZJts=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU=
|
||||
|
@ -473,8 +482,8 @@ golang.org/x/tools v0.0.0-20181221154417-3ad2d988d5e2 h1:M7NLB69gFpUH4s6SJLwXiVs
|
|||
golang.org/x/tools v0.0.0-20181221154417-3ad2d988d5e2/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89 h1:iWXXYN3edZ3Nd/7I6Rt1sXrWVmhF9bgVtlEJ7BbH124=
|
||||
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca h1:PupagGYwj8+I4ubCxcmcBRk3VlUWtTg5huQpZR9flmE=
|
||||
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
|
||||
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6 h1:4WsZyVtkthqrHTbDCJfiTs8IWNYE4uvsSDgaV6xpp+o=
|
||||
|
@ -503,6 +512,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
|
|||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0 h1:oxOEwvhxLMpWpN+0pb2r9TWrM0DCFBHxbuIlS27tmFg=
|
||||
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
|
||||
|
@ -534,8 +544,8 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20181108184350-ae8f1f9103cc h1:VdiEcF0DrrUbDdrLBceS0h7LE60ebD5yRYLLXi0ezIs=
|
||||
honnef.co/go/tools v0.0.0-20181108184350-ae8f1f9103cc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190319011948-d116c56a00f3 h1:XNmJXNdEHJ6ib8002TXvjYr8cjxBc0mmMoPsNQO4nsM=
|
||||
honnef.co/go/tools v0.0.0-20190319011948-d116c56a00f3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190812140558-8bd8df698242 h1:o4vydRJR8cV2rSlUkfP0aRbr0sOMX+iAdUTFbQV4goo=
|
||||
honnef.co/go/tools v0.0.0-20190812140558-8bd8df698242/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 h1:L0cnkNl4TfAXzvdrqsYEmxOHOCv2p5I3taaReO8BWFs=
|
||||
labix.org/v2/mgo v0.0.0-20140701140051-000000000287/go.mod h1:Lg7AYkt1uXJoR9oeSZ3W/8IXLdvOfIITgZnommstyz4=
|
||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/influxdata/flux/iocounter"
|
||||
"github.com/influxdata/flux/parser"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
pcontext "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/http/metric"
|
||||
"github.com/influxdata/influxdb/kit/check"
|
||||
|
@ -38,11 +37,11 @@ const (
|
|||
// FluxBackend is all services and associated parameters required to construct
|
||||
// the FluxHandler.
|
||||
type FluxBackend struct {
|
||||
platform.HTTPErrorHandler
|
||||
influxdb.HTTPErrorHandler
|
||||
Logger *zap.Logger
|
||||
QueryEventRecorder metric.EventRecorder
|
||||
|
||||
OrganizationService platform.OrganizationService
|
||||
OrganizationService influxdb.OrganizationService
|
||||
ProxyQueryService query.ProxyQueryService
|
||||
}
|
||||
|
||||
|
@ -66,11 +65,11 @@ type HTTPDialect interface {
|
|||
// FluxHandler implements handling flux queries.
|
||||
type FluxHandler struct {
|
||||
*httprouter.Router
|
||||
platform.HTTPErrorHandler
|
||||
influxdb.HTTPErrorHandler
|
||||
Logger *zap.Logger
|
||||
|
||||
Now func() time.Time
|
||||
OrganizationService platform.OrganizationService
|
||||
OrganizationService influxdb.OrganizationService
|
||||
ProxyQueryService query.ProxyQueryService
|
||||
|
||||
EventRecorder metric.EventRecorder
|
||||
|
@ -108,7 +107,7 @@ func (h *FluxHandler) handleQuery(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// TODO(desa): I really don't like how we're recording the usage metrics here
|
||||
// Ideally this will be moved when we solve https://github.com/influxdata/influxdb/issues/13403
|
||||
var orgID platform.ID
|
||||
var orgID influxdb.ID
|
||||
var requestBytes int
|
||||
sw := newStatusResponseWriter(w)
|
||||
w = sw
|
||||
|
@ -135,7 +134,7 @@ func (h *FluxHandler) handleQuery(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
req, n, err := decodeProxyQueryRequest(ctx, r, a, h.OrganizationService)
|
||||
if err != nil && err != platform.ErrAuthorizerNotSupported {
|
||||
if err != nil && err != influxdb.ErrAuthorizerNotSupported {
|
||||
err := &influxdb.Error{
|
||||
Code: influxdb.EInvalid,
|
||||
Msg: "failed to decode request body",
|
||||
|
@ -195,8 +194,8 @@ func (h *FluxHandler) postFluxAST(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&request)
|
||||
if err != nil {
|
||||
h.HandleHTTPError(ctx, &platform.Error{
|
||||
Code: platform.EInvalid,
|
||||
h.HandleHTTPError(ctx, &influxdb.Error{
|
||||
Code: influxdb.EInvalid,
|
||||
Msg: "invalid json",
|
||||
Err: err,
|
||||
}, w)
|
||||
|
@ -206,8 +205,8 @@ func (h *FluxHandler) postFluxAST(w http.ResponseWriter, r *http.Request) {
|
|||
pkg := parser.ParseSource(request.Query)
|
||||
if ast.Check(pkg) > 0 {
|
||||
err := ast.GetError(pkg)
|
||||
h.HandleHTTPError(ctx, &platform.Error{
|
||||
Code: platform.EInvalid,
|
||||
h.HandleHTTPError(ctx, &influxdb.Error{
|
||||
Code: influxdb.EInvalid,
|
||||
Msg: "invalid AST",
|
||||
Err: err,
|
||||
}, w)
|
||||
|
@ -233,8 +232,8 @@ func (h *FluxHandler) postQueryAnalyze(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var req QueryRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
h.HandleHTTPError(ctx, &platform.Error{
|
||||
Code: platform.EInvalid,
|
||||
h.HandleHTTPError(ctx, &influxdb.Error{
|
||||
Code: influxdb.EInvalid,
|
||||
Msg: "invalid json",
|
||||
Err: err,
|
||||
}, w)
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/influxdata/flux/csv"
|
||||
"github.com/influxdata/flux/lang"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
icontext "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/http/metric"
|
||||
"github.com/influxdata/influxdb/inmem"
|
||||
|
@ -130,7 +129,7 @@ func TestFluxService_Query(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFluxQueryService_Query(t *testing.T) {
|
||||
var orgID platform.ID
|
||||
var orgID influxdb.ID
|
||||
orgID.DecodeFromString("aaaaaaaaaaaaaaaa")
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -438,17 +437,17 @@ func TestFluxService_Query_gzip(t *testing.T) {
|
|||
// orgService is just to mock out orgs by returning
|
||||
// the same org every time.
|
||||
orgService := &influxmock.OrganizationService{
|
||||
FindOrganizationByIDF: func(ctx context.Context, id platform.ID) (*platform.Organization, error) {
|
||||
return &platform.Organization{
|
||||
FindOrganizationByIDF: func(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error) {
|
||||
return &influxdb.Organization{
|
||||
ID: id,
|
||||
Name: id.String(),
|
||||
}, nil
|
||||
},
|
||||
|
||||
FindOrganizationF: func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
|
||||
return &platform.Organization{
|
||||
ID: platform.ID(1),
|
||||
Name: platform.ID(1).String(),
|
||||
FindOrganizationF: func(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error) {
|
||||
return &influxdb.Organization{
|
||||
ID: influxdb.ID(1),
|
||||
Name: influxdb.ID(1).String(),
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
@ -467,11 +466,11 @@ func TestFluxService_Query_gzip(t *testing.T) {
|
|||
|
||||
// authService is yet more test setup that returns an operator auth for any token.
|
||||
authService := &influxmock.AuthorizationService{
|
||||
FindAuthorizationByTokenFn: func(ctx context.Context, token string) (*platform.Authorization, error) {
|
||||
return &platform.Authorization{
|
||||
ID: platform.ID(1),
|
||||
OrgID: platform.ID(1),
|
||||
Permissions: platform.OperPermissions(),
|
||||
FindAuthorizationByTokenFn: func(ctx context.Context, token string) (*influxdb.Authorization, error) {
|
||||
return &influxdb.Authorization{
|
||||
ID: influxdb.ID(1),
|
||||
OrgID: influxdb.ID(1),
|
||||
Permissions: influxdb.OperPermissions(),
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
@ -569,17 +568,17 @@ func benchmarkQuery(b *testing.B, disableCompression bool) {
|
|||
// orgService is just to mock out orgs by returning
|
||||
// the same org every time.
|
||||
orgService := &influxmock.OrganizationService{
|
||||
FindOrganizationByIDF: func(ctx context.Context, id platform.ID) (*platform.Organization, error) {
|
||||
return &platform.Organization{
|
||||
FindOrganizationByIDF: func(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error) {
|
||||
return &influxdb.Organization{
|
||||
ID: id,
|
||||
Name: id.String(),
|
||||
}, nil
|
||||
},
|
||||
|
||||
FindOrganizationF: func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
|
||||
return &platform.Organization{
|
||||
ID: platform.ID(1),
|
||||
Name: platform.ID(1).String(),
|
||||
FindOrganizationF: func(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error) {
|
||||
return &influxdb.Organization{
|
||||
ID: influxdb.ID(1),
|
||||
Name: influxdb.ID(1).String(),
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
@ -598,11 +597,11 @@ func benchmarkQuery(b *testing.B, disableCompression bool) {
|
|||
|
||||
// authService is yet more test setup that returns an operator auth for any token.
|
||||
authService := &influxmock.AuthorizationService{
|
||||
FindAuthorizationByTokenFn: func(ctx context.Context, token string) (*platform.Authorization, error) {
|
||||
return &platform.Authorization{
|
||||
ID: platform.ID(1),
|
||||
OrgID: platform.ID(1),
|
||||
Permissions: platform.OperPermissions(),
|
||||
FindAuthorizationByTokenFn: func(ctx context.Context, token string) (*influxdb.Authorization, error) {
|
||||
return &influxdb.Authorization{
|
||||
ID: influxdb.ID(1),
|
||||
OrgID: influxdb.ID(1),
|
||||
Permissions: influxdb.OperPermissions(),
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
43
id_test.go
43
id_test.go
|
@ -8,7 +8,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
platformtesting "github.com/influxdata/influxdb/testing"
|
||||
)
|
||||
|
||||
|
@ -16,7 +15,7 @@ func TestIDFromString(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
id string
|
||||
want platform.ID
|
||||
want influxdb.ID
|
||||
wantErr bool
|
||||
err string
|
||||
}{
|
||||
|
@ -24,7 +23,7 @@ func TestIDFromString(t *testing.T) {
|
|||
name: "Should be able to decode an all zeros ID",
|
||||
id: "0000000000000000",
|
||||
wantErr: true,
|
||||
err: platform.ErrInvalidID.Error(),
|
||||
err: influxdb.ErrInvalidID.Error(),
|
||||
},
|
||||
{
|
||||
name: "Should be able to decode an all f ID",
|
||||
|
@ -40,24 +39,24 @@ func TestIDFromString(t *testing.T) {
|
|||
name: "Should not be able to decode a non hex ID",
|
||||
id: "gggggggggggggggg",
|
||||
wantErr: true,
|
||||
err: platform.ErrInvalidID.Error(),
|
||||
err: influxdb.ErrInvalidID.Error(),
|
||||
},
|
||||
{
|
||||
name: "Should not be able to decode inputs with length less than 16 bytes",
|
||||
id: "abc",
|
||||
wantErr: true,
|
||||
err: platform.ErrInvalidIDLength.Error(),
|
||||
err: influxdb.ErrInvalidIDLength.Error(),
|
||||
},
|
||||
{
|
||||
name: "Should not be able to decode inputs with length greater than 16 bytes",
|
||||
id: "abcdabcdabcdabcd0",
|
||||
wantErr: true,
|
||||
err: platform.ErrInvalidIDLength.Error(),
|
||||
err: influxdb.ErrInvalidIDLength.Error(),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := platform.IDFromString(tt.id)
|
||||
got, err := influxdb.IDFromString(tt.id)
|
||||
|
||||
// Check negative test cases
|
||||
if (err != nil) && tt.wantErr {
|
||||
|
@ -76,7 +75,7 @@ func TestIDFromString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeFromString(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
err := id.DecodeFromString("020f755c3c082000")
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
|
@ -95,7 +94,7 @@ func TestDecodeFromString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEncode(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
if _, err := id.Encode(); err == nil {
|
||||
t.Errorf("encoding an invalid ID should not be possible")
|
||||
}
|
||||
|
@ -115,15 +114,15 @@ func TestEncode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeFromAllZeros(t *testing.T) {
|
||||
var id platform.ID
|
||||
err := id.Decode(make([]byte, platform.IDLength))
|
||||
var id influxdb.ID
|
||||
err := id.Decode(make([]byte, influxdb.IDLength))
|
||||
if err == nil {
|
||||
t.Errorf("expecting all zeros ID to not be a valid ID")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeFromShorterString(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
err := id.DecodeFromString("020f75")
|
||||
if err == nil {
|
||||
t.Errorf("expecting shorter inputs to error")
|
||||
|
@ -134,7 +133,7 @@ func TestDecodeFromShorterString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeFromLongerString(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
err := id.DecodeFromString("020f755c3c082000aaa")
|
||||
if err == nil {
|
||||
t.Errorf("expecting shorter inputs to error")
|
||||
|
@ -145,7 +144,7 @@ func TestDecodeFromLongerString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeFromEmptyString(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
err := id.DecodeFromString("")
|
||||
if err == nil {
|
||||
t.Errorf("expecting empty inputs to error")
|
||||
|
@ -156,14 +155,14 @@ func TestDecodeFromEmptyString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMarshalling(t *testing.T) {
|
||||
var id0 platform.ID
|
||||
var id0 influxdb.ID
|
||||
_, err := json.Marshal(id0)
|
||||
if err == nil {
|
||||
t.Errorf("expecting empty ID to not be a valid one")
|
||||
}
|
||||
|
||||
init := "ca55e77eca55e77e"
|
||||
id1, err := platform.IDFromString(init)
|
||||
id1, err := influxdb.IDFromString(init)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
}
|
||||
|
@ -173,7 +172,7 @@ func TestMarshalling(t *testing.T) {
|
|||
t.Errorf(err.Error())
|
||||
}
|
||||
|
||||
var id2 platform.ID
|
||||
var id2 influxdb.ID
|
||||
json.Unmarshal(serialized, &id2)
|
||||
|
||||
bytes1, _ := id1.Encode()
|
||||
|
@ -207,19 +206,19 @@ func TestMarshalling(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestValid(t *testing.T) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
if id.Valid() {
|
||||
t.Errorf("expecting initial ID to be invalid")
|
||||
}
|
||||
|
||||
if platform.InvalidID() != 0 {
|
||||
if influxdb.InvalidID() != 0 {
|
||||
t.Errorf("expecting invalid ID to return a zero ID, thus invalid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestID_GoString(t *testing.T) {
|
||||
type idGoStringTester struct {
|
||||
ID platform.ID
|
||||
ID influxdb.ID
|
||||
}
|
||||
var x idGoStringTester
|
||||
|
||||
|
@ -236,7 +235,7 @@ func TestID_GoString(t *testing.T) {
|
|||
}
|
||||
|
||||
func BenchmarkIDEncode(b *testing.B) {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
id.DecodeFromString("5ca1ab1eba5eba11")
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -247,7 +246,7 @@ func BenchmarkIDEncode(b *testing.B) {
|
|||
|
||||
func BenchmarkIDDecode(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
var id platform.ID
|
||||
var id influxdb.ID
|
||||
id.DecodeFromString("5ca1ab1eba5eba11")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
influxtest "github.com/influxdata/influxdb/testing"
|
||||
)
|
||||
|
||||
|
@ -46,7 +45,7 @@ func TestLabelValidate(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
m := platform.Label{
|
||||
m := influxdb.Label{
|
||||
Name: tt.fields.Name,
|
||||
OrgID: tt.fields.OrgID,
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
"github.com/influxdata/influxdb/kit/prom"
|
||||
"github.com/influxdata/influxdb/kit/tracing"
|
||||
"github.com/influxdata/influxdb/query"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
@ -107,7 +107,7 @@ func New(c Config) (*Controller, error) {
|
|||
if err := c.Validate(); err != nil {
|
||||
return nil, errors.Wrap(err, "invalid controller config")
|
||||
}
|
||||
c.MetricLabelKeys = append(c.MetricLabelKeys, orgLabel)
|
||||
c.MetricLabelKeys = append(c.MetricLabelKeys, orgLabel) //lint:ignore SA1029 this is a temporary ignore until we have time to create an appropriate type
|
||||
logger := c.Logger
|
||||
if logger == nil {
|
||||
logger = zap.NewNop()
|
||||
|
@ -145,7 +145,7 @@ func (c *Controller) Query(ctx context.Context, req *query.Request) (flux.Query,
|
|||
// Set the request on the context so platform specific Flux operations can retrieve it later.
|
||||
ctx = query.ContextWithRequest(ctx, req)
|
||||
// Set the org label value for controller metrics
|
||||
ctx = context.WithValue(ctx, orgLabel, req.OrganizationID.String())
|
||||
ctx = context.WithValue(ctx, orgLabel, req.OrganizationID.String()) //lint:ignore SA1029 this is a temporary ignore until we have time to create an appropriate type
|
||||
q, err := c.query(ctx, req.Compiler)
|
||||
if err != nil {
|
||||
return q, err
|
||||
|
|
|
@ -117,7 +117,7 @@ func TestMetrics(t *testing.T) {
|
|||
}
|
||||
|
||||
// This key/value pair added to the context will appear as a label in the prometheus histogram.
|
||||
ctx := context.WithValue(context.Background(), labelKey, labelValue)
|
||||
ctx := context.WithValue(context.Background(), labelKey, labelValue) //lint:ignore SA1029 this is a temporary ignore until we have time to create an appropriate type
|
||||
rfs := influxdb.ReadFilterSource(
|
||||
execute.DatasetID(uuid.FromTime(time.Now())),
|
||||
&mockReader{},
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"github.com/influxdata/influxdb/query"
|
||||
itesting "github.com/influxdata/influxdb/query/stdlib/testing"
|
||||
|
||||
_ "github.com/influxdata/flux/stdlib" // Import the built-in functions
|
||||
_ "github.com/influxdata/influxdb/query/stdlib" // Import the stdlib
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/influxdata/flux"
|
||||
"github.com/influxdata/flux/lang"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
"github.com/influxdata/influxdb/models"
|
||||
"github.com/influxdata/influxdb/query"
|
||||
"github.com/influxdata/influxdb/storage"
|
||||
|
@ -30,7 +29,7 @@ const (
|
|||
statusTag = "status"
|
||||
|
||||
// Fixed system bucket ID for task and run logs.
|
||||
taskSystemBucketID platform.ID = 10
|
||||
taskSystemBucketID influxdb.ID = 10
|
||||
)
|
||||
|
||||
// NewAnalyticalStorage creates a new analytical store with access to the necessary systems for storing data and to act as a middleware
|
||||
|
@ -295,7 +294,7 @@ func (as *AnalyticalStorage) FindRunByID(ctx context.Context, taskID, runID infl
|
|||
}
|
||||
|
||||
if len(re.runs) == 0 {
|
||||
return nil, platform.ErrRunNotFound
|
||||
return nil, influxdb.ErrRunNotFound
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"github.com/influxdata/flux"
|
||||
"github.com/influxdata/influxdb"
|
||||
platform "github.com/influxdata/influxdb"
|
||||
icontext "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/inmem"
|
||||
"github.com/influxdata/influxdb/kit/prom"
|
||||
|
@ -64,7 +63,7 @@ func testQuerySuccess(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -100,7 +99,7 @@ func testQueryFailure(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ func testManualRun(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -184,7 +183,7 @@ func testResumingRun(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -233,7 +232,7 @@ func testWorkerLimit(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -263,7 +262,7 @@ func testLimitFunc(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -310,7 +309,7 @@ func testMetrics(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -357,7 +356,7 @@ func testMetrics(t *testing.T) {
|
|||
}
|
||||
|
||||
// manual runs metrics
|
||||
mt, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
mt, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -395,7 +394,7 @@ func testIteratorFailure(t *testing.T) {
|
|||
|
||||
script := fmt.Sprintf(fmtTestScript, t.Name())
|
||||
ctx := icontext.SetAuthorizer(context.Background(), tes.tc.Auth)
|
||||
task, err := tes.i.CreateTask(ctx, platform.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
task, err := tes.i.CreateTask(ctx, influxdb.TaskCreate{OrganizationID: tes.tc.OrgID, OwnerID: tes.tc.Auth.GetUserID(), Flux: script})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue