Documentation ¶
Index ¶
- Variables
- func AuthStreamInterceptor(checker AuthChecker) grpc.StreamServerInterceptor
- func AuthUnaryInterceptor(checker AuthChecker) grpc.UnaryServerInterceptor
- func GWNullAnyUnaryInterceptor() grpc.UnaryServerInterceptor
- func Id() (string, error)
- func NewStatus(init pb.Status_State) *pb.Status
- func StatusSetError(s *pb.Status, err error)
- func StatusSetSuccess(s *pb.Status)
- func TestCookieContext(ctx context.Context, t testing.T, c pb.WaypointClient) context.Context
- func TestRunner(t testing.T, client pb.WaypointClient, r *pb.Runner) (string, func())
- func TestServer(t testing.T, impl pb.WaypointServer, opts ...TestOption) pb.WaypointClient
- func TestVersionInfoResponse() *pb.GetVersionInfoResponse
- func VersionStreamInterceptor(serverInfo *pb.VersionInfo) grpc.StreamServerInterceptor
- func VersionUnaryInterceptor(serverInfo *pb.VersionInfo) grpc.UnaryServerInterceptor
- type AuthChecker
- type TestOption
Constants ¶
This section is empty.
Variables ¶
var DefaultEffects = []string{"mutable"}
var Effects = map[string][]string{
"ListBuilds": readonly,
}
Effects is information about the effects of endpoints that are authenticated. If an endpoint is not listed, the DefaultEffect value is used.
Functions ¶
func AuthStreamInterceptor ¶
func AuthStreamInterceptor(checker AuthChecker) grpc.StreamServerInterceptor
AuthStreamInterceptor returns a gRPC unary interceptor that inspects the metadata attached to the context. A token is extract from that metadata and the given AuthChecker is invoked to guard calling the target handler. Effectively it implements authentication in front of any stream call.
func AuthUnaryInterceptor ¶
func AuthUnaryInterceptor(checker AuthChecker) grpc.UnaryServerInterceptor
AuthUnaryInterceptor returns a gRPC unary interceptor that inspects the metadata attached to the context. A token is extracted from that metadata and the given AuthChecker is invoked to guard calling the target handler. Effectively it implements authentication in front of any unary call.
func GWNullAnyUnaryInterceptor ¶
func GWNullAnyUnaryInterceptor() grpc.UnaryServerInterceptor
GWNullAnyUnaryInterceptor returns a gRPC unary interceptor that replaces all *any.Any fields in structs with null ONLY FOR grpc-gateway requests.
grpc-gateway requests are detected by the presence of any metadata that starts with the grpc-gateway prefix (HTTP headers).
func Id ¶
Id returns a unique Id that can be used for new values. This generates a ulid value but the ID itself should be an internal detail. An error will be returned if the ID could be generated.
func NewStatus ¶
func NewStatus(init pb.Status_State) *pb.Status
NewStatus returns a new Status message with the given initial state.
func StatusSetError ¶
StatusSetError sets the error state on the status and marks the completion time.
func StatusSetSuccess ¶
StatusSetSuccess sets state of the status to success and marks the completion time.
func TestCookieContext ¶
TestCookieContext returns a context with the cookie set.
func TestRunner ¶ added in v0.9.0
func TestRunner(t testing.T, client pb.WaypointClient, r *pb.Runner) (string, func())
TestRunner registers a runner and returns the ID and a function to deregister the runner. This uses t.Cleanup so that the runner will always be deregistered on test completion.
func TestServer ¶
func TestServer(t testing.T, impl pb.WaypointServer, opts ...TestOption) pb.WaypointClient
TestServer starts a server and returns a gRPC client to that server. We use t.Cleanup to ensure resources are automatically cleaned up.
func TestVersionInfoResponse ¶
func TestVersionInfoResponse() *pb.GetVersionInfoResponse
TestVersionInfoResponse generates a valid version info response for testing
func VersionStreamInterceptor ¶
func VersionStreamInterceptor(serverInfo *pb.VersionInfo) grpc.StreamServerInterceptor
VersionStreamInterceptor returns a gRPC unary interceptor that negotiates the protocol version to use and sets it in the context using protocolversion.WithContext.
func VersionUnaryInterceptor ¶
func VersionUnaryInterceptor(serverInfo *pb.VersionInfo) grpc.UnaryServerInterceptor
VersionUnaryInterceptor returns a gRPC unary interceptor that negotiates the protocol version to use and sets it in the context using protocolversion.WithContext.
Types ¶
type AuthChecker ¶
type AuthChecker interface { // Authenticate is called before each RPC to authenticate it. The implementation may // return a new context if they want to insert authentication information // into it (such as the current user). The implementation may return a nil // context and the existing context will be used. Authenticate( ctx context.Context, token, endpoint string, effects []string, ) (context.Context, error) }
AuthChecker - An interface implemented by something that wishes to authenticate the server actions.
type TestOption ¶
type TestOption func(*testConfig)
TestOption is used with TestServer to configure test behavior.
func TestWithContext ¶
func TestWithContext(ctx context.Context) TestOption
TestWithContext specifies a context to use with the test server. When this is done then the server will exit.
func TestWithRestart ¶
func TestWithRestart(ch <-chan struct{}) TestOption
TestWithRestart specifies a channel that will be sent to trigger a restart. The restart happens asynchronously. If you want to ensure the server is shutdown first, use TestWithContext, shut it down, wait for errors on the API, then restart.
func TestWithToken ¶
func TestWithToken(token string) TestOption
TestWithToken specifies a specific token to use for auth.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package gen is a reverse proxy.
|
Package gen is a reverse proxy. |
Package grpcmetadata contains functions for reading and writing waypoint specific metadata to contexts, which is transmitted by RPC calls.
|
Package grpcmetadata contains functions for reading and writing waypoint specific metadata to contexts, which is transmitted by RPC calls. |
Package hcerr contains helpers to format and sanitize errors before returning them to clients as grpc status errors.
|
Package hcerr contains helpers to format and sanitize errors before returning them to clients as grpc status errors. |
Package logbuffer provides a structure and API for efficiently reading and writing logs that may be streamed to a server.
|
Package logbuffer provides a structure and API for efficiently reading and writing logs that may be streamed to a server. |