diff --git a/api/client/client_test.go b/api/client/client_test.go index 76181279b1e1a..5ed38a0e7f94f 100644 --- a/api/client/client_test.go +++ b/api/client/client_test.go @@ -29,7 +29,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -37,6 +36,7 @@ import ( "github.com/gravitational/teleport/api/client/proto" "github.com/gravitational/teleport/api/defaults" "github.com/gravitational/teleport/api/metadata" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" ) diff --git a/api/client/proxy/client_test.go b/api/client/proxy/client_test.go index 6a1671aaf8f37..264991cdb8c54 100644 --- a/api/client/proxy/client_test.go +++ b/api/client/proxy/client_test.go @@ -30,7 +30,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" @@ -44,6 +43,7 @@ import ( "github.com/gravitational/teleport/api/client" "github.com/gravitational/teleport/api/client/proto" transportv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/transport/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/utils/grpc/stream" ) diff --git a/api/client/proxy/transport/transportv1/client_test.go b/api/client/proxy/transport/transportv1/client_test.go index ce1579c9ce7cd..6cc7d8b835ba4 100644 --- a/api/client/proxy/transport/transportv1/client_test.go +++ b/api/client/proxy/transport/transportv1/client_test.go @@ -29,7 +29,6 @@ import ( "time" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh/agent" "google.golang.org/grpc" @@ -37,6 +36,7 @@ import ( "google.golang.org/grpc/test/bufconn" transportv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/transport/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/utils/grpc/interceptors" streamutils "github.com/gravitational/teleport/api/utils/grpc/stream" ) diff --git a/api/client/secreport/crud.go b/api/client/secreport/crud.go index 0126be6be2fdc..e876f29fd3612 100644 --- a/api/client/secreport/crud.go +++ b/api/client/secreport/crud.go @@ -20,9 +20,9 @@ import ( "context" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/secreports/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types/secreports" v1 "github.com/gravitational/teleport/api/types/secreports/convert/v1" ) diff --git a/api/client/secreport/secreport.go b/api/client/secreport/secreport.go index 075c89bb5b14f..9c1eba1c51439 100644 --- a/api/client/secreport/secreport.go +++ b/api/client/secreport/secreport.go @@ -20,9 +20,9 @@ import ( "context" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/secreports/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types/secreports" v1 "github.com/gravitational/teleport/api/types/secreports/convert/v1" ) diff --git a/api/trail/trail.go b/api/trail/trail.go new file mode 100644 index 0000000000000..941eaaf8034d5 --- /dev/null +++ b/api/trail/trail.go @@ -0,0 +1,287 @@ +/* +Copyright 2016 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package trail integrates trace errors with GRPC +// +// Example server that sends the GRPC error and attaches metadata: +// +// func (s *server) Echo(ctx context.Context, message *gw.StringMessage) (*gw.StringMessage, error) { +// trace.SetDebug(true) // to tell trace to start attaching metadata +// // Send sends metadata via grpc header and converts error to GRPC compatible one +// return nil, trail.Send(ctx, trace.AccessDenied("missing authorization")) +// } +// +// Example client reading error and trace debug info: +// +// var header metadata.MD +// r, err := c.Echo(context.Background(), &gw.StringMessage{Value: message}, grpc.Header(&header)) +// if err != nil { +// // FromGRPC reads error, converts it back to trace error and attaches debug metadata +// // like stack trace of the error origin back to the error +// err = trail.FromGRPC(err, header) +// +// // this line will log original trace of the error +// log.Errorf("error saying echo: %v", trace.DebugReport(err)) +// return +// } +package trail + +import ( + "encoding/base64" + "encoding/json" + "io" + "os" + "runtime" + + "github.com/gravitational/trace" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// DebugReportMetadata is a key in metadata holding debug information +// about the error - stack traces and original error +const debugReportMetadata = "trace-debug-report" + +// ToGRPC converts error to GRPC-compatible error +func ToGRPC(originalErr error) error { + if originalErr == nil { + return nil + } + + // Avoid modifying top-level gRPC errors. + if _, ok := status.FromError(originalErr); ok { + return originalErr + } + + code := codes.Unknown + returnOriginal := false + traverseErr(originalErr, func(err error) (ok bool) { + if err == io.EOF { + // Keep legacy semantics and return the original error. + returnOriginal = true + return true + } + + if s, ok := status.FromError(err); ok { + code = s.Code() + return true + } + + // Duplicate check from trace.IsNotFound. + if os.IsNotExist(err) { + code = codes.NotFound + return true + } + + ok = true // Assume match + switch err.(type) { + case *trace.AccessDeniedError: + code = codes.PermissionDenied + case *trace.AlreadyExistsError: + code = codes.AlreadyExists + case *trace.BadParameterError: + code = codes.InvalidArgument + case *trace.CompareFailedError: + code = codes.FailedPrecondition + case *trace.ConnectionProblemError: + code = codes.Unavailable + case *trace.LimitExceededError: + code = codes.ResourceExhausted + case *trace.NotFoundError: + code = codes.NotFound + case *trace.NotImplementedError: + code = codes.Unimplemented + case *trace.OAuth2Error: + code = codes.InvalidArgument + // *trace.RetryError not mapped. + // *trace.TrustError not mapped. + default: + ok = false + } + return ok + }) + if returnOriginal { + return originalErr + } + + return status.Error(code, trace.UserMessage(originalErr)) +} + +// FromGRPC converts error from GRPC error back to trace.Error +// Debug information will be retrieved from the metadata if specified in args +func FromGRPC(err error, args ...interface{}) error { + if err == nil { + return nil + } + + statusErr := status.Convert(err) + code := statusErr.Code() + message := statusErr.Message() + + var e error + switch code { + case codes.OK: + return nil + case codes.NotFound: + e = &trace.NotFoundError{Message: message} + case codes.AlreadyExists: + e = &trace.AlreadyExistsError{Message: message} + case codes.PermissionDenied: + e = &trace.AccessDeniedError{Message: message} + case codes.FailedPrecondition: + e = &trace.CompareFailedError{Message: message} + case codes.InvalidArgument: + e = &trace.BadParameterError{Message: message} + case codes.ResourceExhausted: + e = &trace.LimitExceededError{Message: message} + case codes.Unavailable: + e = &trace.ConnectionProblemError{Message: message} + case codes.Unimplemented: + e = &trace.NotImplementedError{Message: message} + default: + e = err + } + if len(args) != 0 { + if meta, ok := args[0].(metadata.MD); ok { + e = decodeDebugInfo(e, meta) + // We return here because if it's a trace.Error then + // frames was already extracted from metadata so + // there's no need to capture frames once again. + if _, ok := e.(trace.Error); ok { + return e + } + } + } + traces := captureTraces(1) + return &trace.TraceErr{Err: e, Traces: traces} +} + +// setDebugInfo adds debug metadata about error (traces, original error) +// to request metadata as encoded property +func setDebugInfo(err error, meta metadata.MD) { + if _, ok := err.(*trace.TraceErr); !ok { + return + } + out, err := json.Marshal(err) + if err != nil { + return + } + meta[debugReportMetadata] = []string{ + base64.StdEncoding.EncodeToString(out), + } +} + +// decodeDebugInfo decodes debug information about error +// from the metadata and returns error with enriched metadata about it +func decodeDebugInfo(err error, meta metadata.MD) error { + if len(meta) == 0 { + return err + } + encoded, ok := meta[debugReportMetadata] + if !ok || len(encoded) != 1 { + return err + } + data, decodeErr := base64.StdEncoding.DecodeString(encoded[0]) + if decodeErr != nil { + return err + } + var raw trace.RawTrace + if unmarshalErr := json.Unmarshal(data, &raw); unmarshalErr != nil { + return err + } + if len(raw.Traces) != 0 && len(raw.Err) != 0 { + return &trace.TraceErr{Traces: raw.Traces, Err: err, Message: raw.Message} + } + return err +} + +// traverseErr traverses the err error chain until fn returns true. +// Traversal stops on nil errors, fn(nil) is never called. +// Returns true if fn matched, false otherwise. +func traverseErr(err error, fn func(error) (ok bool)) (ok bool) { + if err == nil { + return false + } + + if fn(err) { + return true + } + + switch err := err.(type) { + case interface{ Unwrap() error }: + return traverseErr(err.Unwrap(), fn) + + case interface{ Unwrap() []error }: + for _, err2 := range err.Unwrap() { + if traverseErr(err2, fn) { + return true + } + } + } + + return false +} + +// FrameCursor stores the position in a call stack +type frameCursor struct { + // Current specifies the current stack frame. + // if omitted, rest contains the complete stack + Current *runtime.Frame + // Rest specifies the rest of stack frames to explore + Rest *runtime.Frames + // N specifies the total number of stack frames + N int +} + +// CaptureTraces gets the current stack trace with some deep frames skipped +func captureTraces(skip int) trace.Traces { + var buf [32]uintptr + // +2 means that we also skip `CaptureTraces` and `runtime.Callers` frames. + n := runtime.Callers(skip+2, buf[:]) + pcs := buf[:n] + frames := runtime.CallersFrames(pcs) + cursor := frameCursor{ + Rest: frames, + N: n, + } + return getTracesFromCursor(cursor) +} + +// GetTracesFromCursor gets the current stack trace from a given cursor +func getTracesFromCursor(cursor frameCursor) trace.Traces { + traces := make(trace.Traces, 0, cursor.N) + if cursor.Current != nil { + traces = append(traces, frameToTrace(*cursor.Current)) + } + for i := 0; i < cursor.N; i++ { + frame, more := cursor.Rest.Next() + traces = append(traces, frameToTrace(frame)) + if !more { + break + } + } + return traces +} + +func frameToTrace(frame runtime.Frame) trace.Trace { + return trace.Trace{ + Func: frame.Function, + Path: frame.File, + Line: frame.Line, + } +} diff --git a/api/trail/trail_test.go b/api/trail/trail_test.go new file mode 100644 index 0000000000000..9078881273902 --- /dev/null +++ b/api/trail/trail_test.go @@ -0,0 +1,189 @@ +/* +Copyright 2016 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package trail + +import ( + "errors" + "fmt" + "io" + "os" + "strings" + "testing" + + "github.com/gravitational/trace" + "github.com/stretchr/testify/assert" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// TestConversion makes sure we convert all trace supported errors +// to and back from GRPC codes +func TestConversion(t *testing.T) { + tests := []struct { + name string + err error + fn func(error) bool + }{ + { + name: "io.EOF", + err: io.EOF, + fn: func(err error) bool { return errors.Is(err, io.EOF) }, + }, + { + name: "os.ErrNotExist", + err: os.ErrNotExist, + fn: trace.IsNotFound, + }, + { + name: "AccessDenied", + err: trace.AccessDenied("access denied"), + fn: trace.IsAccessDenied, + }, + { + name: "AlreadyExists", + err: trace.AlreadyExists("already exists"), + fn: trace.IsAlreadyExists, + }, + { + name: "BadParameter", + err: trace.BadParameter("bad parameter"), + fn: trace.IsBadParameter, + }, + { + name: "CompareFailed", + err: trace.CompareFailed("compare failed"), + fn: trace.IsCompareFailed, + }, + { + name: "ConnectionProblem", + err: trace.ConnectionProblem(nil, "problem"), + fn: trace.IsConnectionProblem, + }, + { + name: "LimitExceeded", + err: trace.LimitExceeded("exceeded"), + fn: trace.IsLimitExceeded, + }, + { + name: "NotFound", + err: trace.NotFound("not found"), + fn: trace.IsNotFound, + }, + { + name: "NotImplemented", + err: trace.NotImplemented("not implemented"), + fn: trace.IsNotImplemented, + }, + { + name: "Aggregated BadParameter", + err: trace.NewAggregate(trace.BadParameter("bad parameter")), + fn: trace.IsBadParameter, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + grpcError := ToGRPC(test.err) + assert.Equal(t, test.err.Error(), status.Convert(grpcError).Message(), "Error message mismatch") + + out := FromGRPC(grpcError) + assert.True(t, test.fn(out), "Predicate failed") + assert.Regexp(t, ".*trail_test.go.*", line(trace.DebugReport(out))) + assert.NotRegexp(t, ".*trail.go.*", line(trace.DebugReport(out))) + }) + } +} + +// TestNil makes sure conversions of nil to and from GRPC are no-op +func TestNil(t *testing.T) { + out := FromGRPC(ToGRPC(nil)) + assert.Nil(t, out) +} + +// TestFromEOF makes sure that non-grpc error such as io.EOF is preserved well. +func TestFromEOF(t *testing.T) { + out := FromGRPC(trace.Wrap(io.EOF)) + assert.True(t, trace.IsEOF(out)) +} + +// TestTraces makes sure we pass traces via metadata and can decode it back +func TestTraces(t *testing.T) { + err := trace.BadParameter("param") + meta := metadata.New(nil) + setDebugInfo(err, meta) + err2 := FromGRPC(ToGRPC(err), meta) + assert.Regexp(t, ".*trail_test.go.*", line(trace.DebugReport(err))) + assert.Regexp(t, ".*trail_test.go.*", line(trace.DebugReport(err2))) +} + +func line(s string) string { + return strings.ReplaceAll(s, "\n", "") +} + +func TestToGRPCKeepCode(t *testing.T) { + err := status.Errorf(codes.PermissionDenied, "denied") + err = ToGRPC(err) + if code := status.Code(err); code != codes.PermissionDenied { + t.Errorf("after ToGRPC, got error code %v, want %v, error: %v", code, codes.PermissionDenied, err) + } + err = FromGRPC(err) + if !trace.IsAccessDenied(err) { + t.Errorf("after FromGRPC, trace.IsAccessDenied is false, want true, error: %v", err) + } +} + +func TestToGRPC_statusError(t *testing.T) { + err1 := status.Errorf(codes.NotFound, "not found") + err2 := fmt.Errorf("go wrap: %w", trace.Wrap(err1)) + + tests := []struct { + name string + err error + want error + }{ + { + name: "unwrapped status", + err: err1, + want: err1, // Exact same error. + }, + { + name: "wrapped status", + err: err2, + want: status.Errorf(codes.NotFound, err2.Error()), + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + err := ToGRPC(test.err) + + got, ok := status.FromError(err) + if !ok { + t.Fatalf("Failed to convert `got` to a status.Status: %#v", err) + } + want, ok := status.FromError(test.want) + if !ok { + t.Fatalf("Failed to convert `want` to a status.Status: %#v", err) + } + + if got.Code() != want.Code() || got.Message() != want.Message() { + t.Errorf("ToGRPC = %#v, want %#v", got, test.want) + } + }) + } +} diff --git a/api/utils/grpc/interceptors/errors.go b/api/utils/grpc/interceptors/errors.go index 3b9e834b60c18..7b57ceaabb26d 100644 --- a/api/utils/grpc/interceptors/errors.go +++ b/api/utils/grpc/interceptors/errors.go @@ -20,8 +20,9 @@ import ( "io" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/grpc" + + "github.com/gravitational/teleport/api/trail" ) // grpcServerStreamWrapper wraps around the embedded grpc.ServerStream diff --git a/api/utils/grpc/interceptors/mfa.go b/api/utils/grpc/interceptors/mfa.go index e8dae8e45e1f7..1ee839e0b4e41 100644 --- a/api/utils/grpc/interceptors/mfa.go +++ b/api/utils/grpc/interceptors/mfa.go @@ -21,10 +21,10 @@ import ( "strings" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/grpc" "github.com/gravitational/teleport/api/mfa" + "github.com/gravitational/teleport/api/trail" ) // WithMFAUnaryInterceptor intercepts a GRPC client unary call to add MFA credentials diff --git a/integration/integration_test.go b/integration/integration_test.go index 4e2c4bed4974e..adf9028771df9 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -51,7 +51,6 @@ import ( "github.com/google/uuid" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/pkg/sftp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -72,6 +71,7 @@ import ( tracessh "github.com/gravitational/teleport/api/observability/tracing/ssh" "github.com/gravitational/teleport/api/profile" apihelpers "github.com/gravitational/teleport/api/testhelpers" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" apievents "github.com/gravitational/teleport/api/types/events" apiutils "github.com/gravitational/teleport/api/utils" diff --git a/integrations/lib/errors.go b/integrations/lib/errors.go index d9228774fd77e..a93fe6a82711a 100644 --- a/integrations/lib/errors.go +++ b/integrations/lib/errors.go @@ -24,9 +24,10 @@ import ( "io" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/gravitational/teleport/api/trail" ) // TODO: remove this when trail.FromGRPC will understand additional error codes diff --git a/integrations/operator/controllers/resources/testlib/login_rule_controller_tests.go b/integrations/operator/controllers/resources/testlib/login_rule_controller_tests.go index 5bb8fc4544665..743e059faf922 100644 --- a/integrations/operator/controllers/resources/testlib/login_rule_controller_tests.go +++ b/integrations/operator/controllers/resources/testlib/login_rule_controller_tests.go @@ -25,12 +25,12 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kclient "sigs.k8s.io/controller-runtime/pkg/client" "github.com/gravitational/teleport/api/client" loginrulepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/loginrule/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/wrappers" resourcesv1 "github.com/gravitational/teleport/integrations/operator/apis/resources/v1" diff --git a/lib/auth/grpcserver.go b/lib/auth/grpcserver.go index 4b1cdaef21422..5e803857b5e5f 100644 --- a/lib/auth/grpcserver.go +++ b/lib/auth/grpcserver.go @@ -33,7 +33,6 @@ import ( "github.com/coreos/go-semver/semver" "github.com/google/uuid" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/prometheus/client_golang/prometheus" collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1" "google.golang.org/grpc" @@ -79,6 +78,7 @@ import ( userpreferencesv1pb "github.com/gravitational/teleport/api/gen/proto/go/userpreferences/v1" "github.com/gravitational/teleport/api/internalutils/stream" "github.com/gravitational/teleport/api/metadata" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/api/types/installers" diff --git a/lib/auth/grpcserver_test.go b/lib/auth/grpcserver_test.go index 60ed4193c30ae..f688432716339 100644 --- a/lib/auth/grpcserver_test.go +++ b/lib/auth/grpcserver_test.go @@ -37,7 +37,6 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/jonboulle/clockwork" "github.com/pquerna/otp" "github.com/pquerna/otp/totp" @@ -60,6 +59,7 @@ import ( "github.com/gravitational/teleport/api/metadata" "github.com/gravitational/teleport/api/mfa" "github.com/gravitational/teleport/api/observability/tracing" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/installers" "github.com/gravitational/teleport/api/utils" diff --git a/lib/auth/presence/presencev1/service_test.go b/lib/auth/presence/presencev1/service_test.go index 2b673b6517a53..47259dbead053 100644 --- a/lib/auth/presence/presencev1/service_test.go +++ b/lib/auth/presence/presencev1/service_test.go @@ -30,7 +30,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/jonboulle/clockwork" "github.com/stretchr/testify/require" "google.golang.org/protobuf/testing/protocmp" @@ -38,6 +37,7 @@ import ( "github.com/gravitational/teleport" presencev1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/presence/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/utils" "github.com/gravitational/teleport/lib/auth" diff --git a/lib/backend/firestore/firestorebk.go b/lib/backend/firestore/firestorebk.go index 71aaaf2c22076..4de5dc98f8ac0 100644 --- a/lib/backend/firestore/firestorebk.go +++ b/lib/backend/firestore/firestorebk.go @@ -33,7 +33,6 @@ import ( apiv1 "cloud.google.com/go/firestore/apiv1/admin" "cloud.google.com/go/firestore/apiv1/admin/adminpb" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/jonboulle/clockwork" "google.golang.org/api/option" "google.golang.org/grpc" @@ -42,6 +41,7 @@ import ( "google.golang.org/grpc/status" "github.com/gravitational/teleport" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" apiutils "github.com/gravitational/teleport/api/utils" "github.com/gravitational/teleport/api/utils/retryutils" diff --git a/lib/cloud/gcp/vm.go b/lib/cloud/gcp/vm.go index 9ebc40b7d88cc..eb1d1a8820249 100644 --- a/lib/cloud/gcp/vm.go +++ b/lib/cloud/gcp/vm.go @@ -37,13 +37,13 @@ import ( "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" "github.com/googleapis/gax-go/v2/apierror" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "golang.org/x/crypto/ssh" "google.golang.org/api/googleapi" "google.golang.org/api/iterator" "google.golang.org/api/option" "github.com/gravitational/teleport/api/internalutils/stream" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/utils/sshutils" gcpimds "github.com/gravitational/teleport/lib/cloud/imds/gcp" diff --git a/lib/devicetrust/enroll/enroll.go b/lib/devicetrust/enroll/enroll.go index bdf3cea00c1b4..764197487b950 100644 --- a/lib/devicetrust/enroll/enroll.go +++ b/lib/devicetrust/enroll/enroll.go @@ -25,9 +25,9 @@ import ( "log/slog" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/lib/devicetrust" "github.com/gravitational/teleport/lib/devicetrust/native" ) diff --git a/lib/kube/grpc/grpc.go b/lib/kube/grpc/grpc.go index bbd982cd12da0..7e59db205b80e 100644 --- a/lib/kube/grpc/grpc.go +++ b/lib/kube/grpc/grpc.go @@ -25,13 +25,13 @@ import ( "slices" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/defaults" proto "github.com/gravitational/teleport/api/gen/proto/go/teleport/kube/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/lib/authz" diff --git a/lib/proxy/peer/quic/client.go b/lib/proxy/peer/quic/client.go index 49c4146759f4b..b230f111c253a 100644 --- a/lib/proxy/peer/quic/client.go +++ b/lib/proxy/peer/quic/client.go @@ -29,12 +29,12 @@ import ( "time" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/quic-go/quic-go" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" apiutils "github.com/gravitational/teleport/api/utils" quicpeeringv1a "github.com/gravitational/teleport/gen/proto/go/teleport/quicpeering/v1alpha" diff --git a/lib/proxy/peer/quic/server.go b/lib/proxy/peer/quic/server.go index 5aa5bb8afd765..2931837907b72 100644 --- a/lib/proxy/peer/quic/server.go +++ b/lib/proxy/peer/quic/server.go @@ -29,13 +29,13 @@ import ( "github.com/google/uuid" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/quic-go/quic-go" "golang.org/x/sync/errgroup" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "github.com/gravitational/teleport" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" quicpeeringv1a "github.com/gravitational/teleport/gen/proto/go/teleport/quicpeering/v1alpha" peerdial "github.com/gravitational/teleport/lib/proxy/peer/dial" diff --git a/lib/srv/db/common/errors.go b/lib/srv/db/common/errors.go index 7b8456f5e5b35..565b66bba053f 100644 --- a/lib/srv/db/common/errors.go +++ b/lib/srv/db/common/errors.go @@ -29,12 +29,12 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/go-mysql-org/go-mysql/mysql" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" "google.golang.org/api/googleapi" "google.golang.org/grpc/status" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" awslib "github.com/gravitational/teleport/lib/cloud/aws" azurelib "github.com/gravitational/teleport/lib/cloud/azure" diff --git a/lib/teleterm/apiserver/middleware.go b/lib/teleterm/apiserver/middleware.go index 520b97bb76565..53bf1e6ecd8af 100644 --- a/lib/teleterm/apiserver/middleware.go +++ b/lib/teleterm/apiserver/middleware.go @@ -22,8 +22,9 @@ import ( "context" "log/slog" - "github.com/gravitational/trace/trail" "google.golang.org/grpc" + + "github.com/gravitational/teleport/api/trail" ) // withErrorHandling is gRPC middleware that maps internal errors to proper gRPC error codes diff --git a/lib/teleterm/daemon/mfaprompt.go b/lib/teleterm/daemon/mfaprompt.go index adeda73e1518b..d229a6ab793ac 100644 --- a/lib/teleterm/daemon/mfaprompt.go +++ b/lib/teleterm/daemon/mfaprompt.go @@ -24,12 +24,12 @@ import ( "sync" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/gravitational/teleport/api/client/proto" "github.com/gravitational/teleport/api/mfa" + "github.com/gravitational/teleport/api/trail" api "github.com/gravitational/teleport/gen/proto/go/teleport/lib/teleterm/v1" wancli "github.com/gravitational/teleport/lib/auth/webauthncli" wantypes "github.com/gravitational/teleport/lib/auth/webauthntypes" diff --git a/tool/tctl/common/accessmonitoring/command.go b/tool/tctl/common/accessmonitoring/command.go index d4483c6ed91b2..b896752d0b9bb 100644 --- a/tool/tctl/common/accessmonitoring/command.go +++ b/tool/tctl/common/accessmonitoring/command.go @@ -25,10 +25,10 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "golang.org/x/exp/maps" "github.com/gravitational/teleport" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types/header" "github.com/gravitational/teleport/api/types/secreports" "github.com/gravitational/teleport/lib/asciitable" diff --git a/tool/tctl/common/devices.go b/tool/tctl/common/devices.go index 3924c4a798b32..e2e0dd494290b 100644 --- a/tool/tctl/common/devices.go +++ b/tool/tctl/common/devices.go @@ -28,10 +28,10 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/google/uuid" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/protobuf/types/known/timestamppb" devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/lib/asciitable" "github.com/gravitational/teleport/lib/auth/authclient" diff --git a/tool/tctl/common/notification_command.go b/tool/tctl/common/notification_command.go index 9703ae65f6065..27c4517db19db 100644 --- a/tool/tctl/common/notification_command.go +++ b/tool/tctl/common/notification_command.go @@ -28,7 +28,6 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/protobuf/types/known/timestamppb" "github.com/gravitational/teleport" @@ -36,6 +35,7 @@ import ( headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1" notificationspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/notifications/v1" "github.com/gravitational/teleport/api/mfa" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/lib/asciitable" "github.com/gravitational/teleport/lib/auth/authclient" diff --git a/tool/tctl/common/resource_command.go b/tool/tctl/common/resource_command.go index 7ea28fc994402..14d08bd97121b 100644 --- a/tool/tctl/common/resource_command.go +++ b/tool/tctl/common/resource_command.go @@ -34,7 +34,6 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/crewjam/saml/samlsp" "github.com/gravitational/trace" - "github.com/gravitational/trace/trail" "google.golang.org/protobuf/encoding/protojson" kyaml "k8s.io/apimachinery/pkg/util/yaml" @@ -58,6 +57,7 @@ import ( workloadidentityv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/workloadidentity/v1" "github.com/gravitational/teleport/api/internalutils/stream" "github.com/gravitational/teleport/api/mfa" + "github.com/gravitational/teleport/api/trail" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/accesslist" "github.com/gravitational/teleport/api/types/discoveryconfig"