-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[public-api] Refactor to use connect handlers #13692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9ff7a33
to
0fedcab
Compare
started the job as gitpod-build-mp-public-api-use-connect-instead-of-grpc.3 because the annotations in the pull request description changed |
6755ce7
to
d7b5c50
Compare
0fedcab
to
aa389ea
Compare
22a3a8d
to
e3ceb72
Compare
requireErrorStatusCode(t, codes.Unimplemented, err) | ||
} | ||
|
||
func TestPublicAPIServer_WorkspaceServiceHandler(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff shows wierd. This test is removed as it's already tested in TestPublicAPIServer_v1_WorkspaceService
require.Equalf(t, expected, st.Code(), "expected: %s but got: %s", expected.String(), st.String()) | ||
func requireErrorStatusCode(t *testing.T, expected connect.Code, err error) { | ||
t.Helper() | ||
if expected == 0 && err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connect doesn't define the default Error Code value as OK, so we have to do this extra check..
36a19ad
to
2eed6c9
Compare
@@ -51,7 +51,7 @@ func newPublicAPIConn() (*grpc.ClientConn, error) { | |||
opts := []grpc.DialOption{ | |||
// attach token to requests to auth | |||
grpc.WithUnaryInterceptor(func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { | |||
withAuth := metadata.AppendToOutgoingContext(ctx, "authorization", publicApiCmdOpts.token) | |||
withAuth := metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+publicApiCmdOpts.token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not correctly adding the Bearer prefix, and we weren't also correctly checking for it server side.
2eed6c9
to
66b1831
Compare
Closing as werft got into an inconcistent state. Replacement PR is here |
Description
In this PR, we 1-1 map the old implementation in gRPC to the new implementation with Connect. Changes are deliberately not made to streamline the tests and simplify to keep the PR cleaner.
In general, the changes are the following (see docs)
connect.NewRequest
orconnect.NewResponse
This PR also changes default routing of
api.<domain>
requests to the HTTP server, this has the following effect:Related Issue(s)
How to test
Unit tests
To make subsequent steps readily runnable, export the token in your shell:
Validate we can reach the new APIs over cURL:
We're doing a list call, and we don't have workspaces so an empty list response is expected.
Validate we can reach the APIs using a gRPC client
Again, we're not getting any workspaces back because we've not started any but the important part is we're not getting an error.
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide