-
Notifications
You must be signed in to change notification settings - Fork 41
feat: add grpc gateway #23
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
63e44c2
saving working code
krtkvrm 98b00ac
saving work
krtkvrm b513e30
resume: add endpoints & setup nr
krtkvrm e0cdfd4
fix: remove reference to local directory for salt
krtkvrm cc4f11e
fix: go.sum
krtkvrm e77c9c7
fix: use go mod to install dependencies
krtkvrm 98a2f97
fix: update grpc implementations
krtkvrm 7b6447b
fix: use buf instead of building proto in repo
krtkvrm 7f8c895
remove: admin command
krtkvrm 3a69317
remove: admin command code
krtkvrm 34c4220
remove: buf config files
krtkvrm aad9ce6
fix: make install to use go mod download instead of tidy
krtkvrm 33cfaf3
fix: use error status instead of panic for unimplemented methods
krtkvrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,10 @@ GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2) | |
| .PHONY: build check fmt lint test test-race vet test-cover-html help install proto | ||
| .DEFAULT_GOAL := build | ||
|
|
||
| install: | ||
| @echo "Clean up imports..." | ||
| @go mod tidy -v | ||
|
|
||
| build: ## build all | ||
| CGO_ENABLED=0 go build -o shield . | ||
|
|
||
|
|
@@ -28,13 +32,3 @@ proto: | |
| help: | ||
| @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
|
||
| install: ## install required dependencies | ||
| @echo "> installing dependencies" | ||
| go get google.golang.org/protobuf/cmd/[email protected] | ||
| go get github.com/golang/protobuf/[email protected] | ||
| go get github.com/golang/protobuf/[email protected] | ||
| go get google.golang.org/[email protected] | ||
| go get google.golang.org/grpc/cmd/[email protected] | ||
| go get github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] | ||
| go get github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] | ||
| go get github.com/bufbuild/buf/cmd/[email protected] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package handler | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/http" | ||
|
|
||
| "github.com/odpf/salt/server" | ||
| v1 "github.com/odpf/shield/api/handler/v1" | ||
| ) | ||
|
|
||
| type Deps struct { | ||
| V1 v1.Dep | ||
| } | ||
|
|
||
| func Register(ctx context.Context, s *server.MuxServer, gw *server.GRPCGateway, deps Deps) { | ||
| s.RegisterHandler("/ping", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| fmt.Fprintf(w, "pong") | ||
| })) | ||
|
|
||
| // grpc gateway api will have version endpoints | ||
| s.SetGateway("/", gw) | ||
|
|
||
| v1.RegisterV1(ctx, s, gw, deps.V1) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| func (v Dep) ListGroups(ctx context.Context, request *shieldv1.ListGroupsRequest) (*shieldv1.ListGroupsResponse, error) { | ||
| panic("implement me") | ||
krtkvrm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| func (v Dep) CreateGroup(ctx context.Context, request *shieldv1.CreateGroupRequest) (*shieldv1.CreateGroupResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) GetGroup(ctx context.Context, request *shieldv1.GetGroupRequest) (*shieldv1.GetGroupResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) ListGroupUsers(ctx context.Context, request *shieldv1.ListGroupUsersRequest) (*shieldv1.ListGroupUsersResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) UpdateGroup(ctx context.Context, request *shieldv1.UpdateGroupRequest) (*shieldv1.UpdateGroupResponse, error) { | ||
| panic("implement me") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| func (v Dep) ListOrganizations(ctx context.Context, request *shieldv1.ListOrganizationsRequest) (*shieldv1.ListOrganizationsResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) CreateOrganization(ctx context.Context, request *shieldv1.CreateOrganizationRequest) (*shieldv1.CreateOrganizationResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) GetOrganization(ctx context.Context, request *shieldv1.GetOrganizationRequest) (*shieldv1.GetOrganizationResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) UpdateOrganization(ctx context.Context, request *shieldv1.UpdateOrganizationRequest) (*shieldv1.UpdateOrganizationResponse, error) { | ||
| panic("implement me") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| func (v Dep) ListProjects(ctx context.Context, request *shieldv1.ListProjectsRequest) (*shieldv1.ListProjectsResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) CreateProject(ctx context.Context, request *shieldv1.CreateProjectRequest) (*shieldv1.CreateProjectResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) GetProject(ctx context.Context, request *shieldv1.GetProjectRequest) (*shieldv1.GetProjectResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) UpdateProject(ctx context.Context, request *shieldv1.UpdateProjectRequest) (*shieldv1.UpdateProjectResponse, error) { | ||
| panic("implement me") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| func (v Dep) ListRoles(ctx context.Context, request *shieldv1.ListRolesRequest) (*shieldv1.ListRolesResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) CreateRole(ctx context.Context, request *shieldv1.CreateRoleRequest) (*shieldv1.CreateRoleResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) GetRole(ctx context.Context, request *shieldv1.GetRoleRequest) (*shieldv1.GetRoleResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) UpdateRole(ctx context.Context, request *shieldv1.UpdateRoleRequest) (*shieldv1.UpdateRoleResponse, error) { | ||
| panic("implement me") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| func (v Dep) ListUsers(ctx context.Context, request *shieldv1.ListUsersRequest) (*shieldv1.ListUsersResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) CreateUser(ctx context.Context, request *shieldv1.CreateUserRequest) (*shieldv1.CreateUserResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) GetUser(ctx context.Context, request *shieldv1.GetUserRequest) (*shieldv1.GetUserResponse, error) { | ||
| panic("get user was called") | ||
| } | ||
|
|
||
| func (v Dep) GetCurrentUser(ctx context.Context, request *shieldv1.GetCurrentUserRequest) (*shieldv1.GetCurrentUserResponse, error) { | ||
| panic("get CURRENT user was called") | ||
| } | ||
|
|
||
| func (v Dep) UpdateUser(ctx context.Context, request *shieldv1.UpdateUserRequest) (*shieldv1.UpdateUserResponse, error) { | ||
| panic("implement me") | ||
| } | ||
|
|
||
| func (v Dep) UpdateCurrentUser(ctx context.Context, request *shieldv1.UpdateCurrentUserRequest) (*shieldv1.UpdateCurrentUserResponse, error) { | ||
| panic("implement me") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/odpf/salt/server" | ||
|
|
||
| shieldv1 "go.buf.build/odpf/gw/odpf/proton/odpf/shield/v1" | ||
| ) | ||
|
|
||
| type Dep struct { | ||
| shieldv1.UnimplementedShieldServiceServer | ||
| } | ||
|
|
||
| func RegisterV1(ctx context.Context, s *server.MuxServer, gw *server.GRPCGateway, dep Dep) { | ||
| gw.RegisterHandler(ctx, shieldv1.RegisterShieldServiceHandlerFromEndpoint) | ||
|
|
||
| s.RegisterService( | ||
| &shieldv1.ShieldService_ServiceDesc, | ||
| &dep, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| version: v1beta1 | ||
krtkvrm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| plugins: | ||
| - name: go | ||
| out: api/protos | ||
| # opt: paths=source_relative | ||
| - name: go-grpc | ||
| out: api/protos | ||
| # opt: paths=source_relative,require_unimplemented_servers=true | ||
| - name: grpc-gateway | ||
| out: api/protos | ||
| # opt: paths=source_relative | ||
| - name: validate | ||
| out: api/protos | ||
| opt: | ||
| # - paths=source_relative | ||
| - lang=go | ||
| - name: openapiv2 | ||
| out: swagger | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Generated by buf. DO NOT EDIT. | ||
| version: v1 | ||
| deps: | ||
| - remote: buf.build | ||
| owner: envoyproxy | ||
| repository: protoc-gen-validate | ||
| branch: main | ||
| commit: bb405eae115246f0b5ccf8997136e3d8 | ||
| digest: b1-BJUoAjBMVXaIMUNFJ5kdGr-be0QDwhDSTEDQpoxXzys= | ||
| create_time: 2021-08-20T15:05:15.02577Z | ||
| - remote: buf.build | ||
| owner: googleapis | ||
| repository: googleapis | ||
| branch: main | ||
| commit: e16155da3b4a49e48bd18cdcb029004d | ||
| digest: b1--CthFBW4QSXRq35NiPd7Uu9WN2xWeV9_GVRe5mbTVuI= | ||
| create_time: 2021-09-30T15:08:49.529359Z | ||
| - remote: buf.build | ||
| owner: grpc-ecosystem | ||
| repository: grpc-gateway | ||
| branch: main | ||
| commit: de24a84aed3d4d84806740946b55d947 | ||
| digest: b1-Q-mEW3P3NR5UL8gm0pr3YWFSo5DAtrBqqgvkwH2WFWw= | ||
| create_time: 2021-09-08T00:32:28.231758Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: v1 | ||
| deps: | ||
| - buf.build/googleapis/googleapis | ||
| - buf.build/grpc-ecosystem/grpc-gateway | ||
| - buf.build/envoyproxy/protoc-gen-validate | ||
| lint: | ||
| use: | ||
| - DEFAULT | ||
| breaking: | ||
| use: | ||
| - FILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.