rb-gateway
Review Request #6831 — Created Jan. 25, 2015 and submitted
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface
- git_repository.go : The Git implementation of repository.go
- routes.go : Handles all web services and routing
- util.go : Handles configuration loading and repository lookup
- sample_config.json : Sample configuration file using .json format
- main.go : main() lives here, access logging
- auth.go : Basic Auth implementation
- session.go : Represents the current user sessionLocal use case:
1. Specify repo_name = path in config.json (see sample config)
2. Specify credentials in config.json
3. Specify the port you want the server to run on
2. After the server is started, go to ./localhost:<port>?repo=repo_name&id=sha
3. A file should download containing the requested blob.Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
The server uses Basic Auth. Currently authenticating against a single user in the config file, this may need to change. Basic Auth expects the username:password combination in the /session path, and then encrypts that information and stores it in a session. The encrypted information is stored as a PRIVATE-TOKEN (similiar to the Gitlab API), and is expected in future http requests.
Routes are available for getting file blob and checking file existance based on either the Git revision, or the Git commit id, file path pair. It currently does not support other SCM aside from Git.
Authentication:
- curl -u username:password http://localhost:8002/session returns 200 OK and the PRIVATE-TOKEN
- Set up a repository succesfully in RB using a valid user / pass combo, and saw the access log in rb-gatewayFile and File Exists
- Tested the following paths via browser, review board, and curl for HEAD and GET methods; returned expected values for valid requests:
- http://localhost:8002/file?id=<revision-sha> (returned 200 OK, and file blob if GET)
- http://localhost:8002/file?commit=<commit>&path=<path> (returned 200 OK, and file blob if GET)
Description | From | Last Updated |
---|---|---|
Can you do this? cmd := exec.Command("git", "show", id) cmd.Dir = repo.Path ... Same above. |
david | |
Can you add a default case to log an error? |
david | |
How about storing the "Repos" var as a map from name to repo? |
david | |
These should actually be the same URL (and the same handler). Inside the handler, we can switch between "get file" … |
david | |
Just a nit pick, but underlines with = and - in Markdown should be the same length as the text … |
brennie | |
Can we call this FileExists? (remove the "Get") |
david | |
It might be nice to log the URLs that are accessed and the resulting response status/payload size (kind of an … |
david | |
These two lines could be combined (if repo.GetFileExists(id) {) |
david | |
As I read through this, I'm wondering if instead of logging, we should make this function return the error (use … |
david | |
This is pretty verbose. Can we just have a single line in the log? (get rid of the =====s) |
david | |
To be honest, this comment doesn't really add anything useful (the method name is quite self-explanatory). |
david | |
Does this need to be exported? It looks like we don't use it outside of this file. That said, it … |
david | |
These cases can probably be combined (we expect either an err or a blob) |
david | |
Instead of grabbing github master, how about using "gopkg.in/libgit2/git2go.v22"? That way people building this can just do go get to … |
david | |
These two comments don't really add very much (it's pretty easy to find these functions in a relatively small codebase, … |
david | |
This doesn't need to be exported out of this file. |
david | |
This doesn't need to be exported out of this file. |
david | |
This doesn't need to be exported out of this file. |
david | |
This doesn't seem to provide any advantage over just calling json.Marshal(session) directly. |
david | |
Can you make sure that there's always a space after a colon? |
david | |
You have an "scm" field in the repositories in the config. That seems like a more reliable way of detecting … |
david |
- Change Summary:
-
Ran go fmt for better formatting
- Commit:
-
5821dfa19396e43763c093c1ad5f37b804dce016b7f1cfc2785c740afdfd8fbaf5dc50a4461fb494
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go repository.go main.go web_service.go util.go config.json Tool: Pyflakes Ignored Files: git_repository.go repository.go main.go web_service.go util.go config.json
- Change Summary:
-
Fixing issues and general improvements + git2go integration and README
- Commit:
-
b7f1cfc2785c740afdfd8fbaf5dc50a4461fb4941fea0ac5c663c5510bb3b660d57bd2165afe8d6d
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go repository.go main.go web_service.go util.go config.json README.md Tool: Pyflakes Ignored Files: git_repository.go repository.go main.go web_service.go util.go config.json README.md
- Change Summary:
-
Adding .gitignore and putting config.json there
- Commit:
-
1fea0ac5c663c5510bb3b660d57bd2165afe8d6d895fd606123a2f764cf99fef0608a88b2a17648e
-
Tool: Pyflakes Ignored Files: git_repository.go repository.go .gitignore main.go web_service.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Updated description
- Description:
-
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
~ Currently, this is a wireframe set up using Google Go (no additional frameworks).
~ Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface - git_repository.go : The Git implementation of repository.go - web_service.go : Handles all web services and routing - util.go : Handles configuration loading and repository lookup ~ - config.json : Sample configuration file using .json format ~ - sample_config.json : Sample configuration file using .json format - main.go : main() lives here Currently as a test, the web server runs on port 8888. A sample works as follows:
1. Specify repo_name = path in config.json (see file attachment) 2. After the server is started, go to ./localhost:8888?repo=repo_name&id=sha ~ 3. A file should download, however my shell exec command isn't currently working in Go - need to fix. ~ 3. A file should download containing the requested blob. ~ Link the old review request (with non-addressed issues): https://reviews.reviewboard.org/r/6825/
~ Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
- Change Summary:
-
Adding install instructions to README
- Commit:
-
895fd606123a2f764cf99fef0608a88b2a17648e7005548c2042ed91d54a26191ef8323ae5d87a4c
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Added access log and fixed David's suggestions.
- Commit:
-
7005548c2042ed91d54a26191ef8323ae5d87a4cd5a8c39ac5b11005e27e9e348fbdfbf20064422d
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
-
-
As I read through this, I'm wondering if instead of logging, we should make this function return the error (use the typical data, err pattern of returns that go uses). That way we can have a single log statement in the code that calls this method.
-
-
To be honest, this comment doesn't really add anything useful (the method name is quite self-explanatory).
-
Does this need to be exported? It looks like we don't use it outside of this file.
That said, it might be nice to change this so that LoadConfig returns this instead of storing it as a global.
- Change Summary:
-
Minor code refactoring
- Commit:
-
d5a8c39ac5b11005e27e9e348fbdfbf20064422dde4c4960b7fe2934698419c48ecf20a5c6e61958
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Slight refactoring (to fix David's issue)
- Commit:
-
de4c4960b7fe2934698419c48ecf20a5c6e61958a38f2d29d0549d467f4e967918958f8ea1707061
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Added a GetPath to web_service.go
- Commit:
-
a38f2d29d0549d467f4e967918958f8ea1707061076e4734d54e4069bd252190ea82b1a1cd4509ff
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Modified GET path to account for /info/ref that RB adds to the repository GET request
- Description:
-
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface - git_repository.go : The Git implementation of repository.go - web_service.go : Handles all web services and routing - util.go : Handles configuration loading and repository lookup - sample_config.json : Sample configuration file using .json format - main.go : main() lives here Currently as a test, the web server runs on port 8888. A sample works as follows:
1. Specify repo_name = path in config.json (see file attachment) 2. After the server is started, go to ./localhost:8888?repo=repo_name&id=sha 3. A file should download containing the requested blob. Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
+ + Update Feb 1, 2015:
+ Service now is now capable of listening for RB requests if rb-gateway is running on localhost:8888. I still need to add in a config for this. - Commit:
-
076e4734d54e4069bd252190ea82b1a1cd4509ffc00ca725f3bb9d70208020e35254d2662419b6ce
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go .gitignore main.go web_service.go util.go README.md
- Change Summary:
-
Added Basic Auth, port value to configuration, and some clean up
- Description:
-
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface - git_repository.go : The Git implementation of repository.go ~ - web_service.go : Handles all web services and routing ~ - routes.go : Handles all web services and routing - util.go : Handles configuration loading and repository lookup - sample_config.json : Sample configuration file using .json format ~ - main.go : main() lives here ~ - main.go : main() lives here, access logging + - auth.go : Basic Auth implementation + - session.go : Represents the current user session Currently as a test, the web server runs on port 8888. A sample works as follows:
1. Specify repo_name = path in config.json (see file attachment) 2. After the server is started, go to ./localhost:8888?repo=repo_name&id=sha 3. A file should download containing the requested blob. Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
Update Feb 1, 2015:
Service now is now capable of listening for RB requests if rb-gateway is running on localhost:8888. I still need to add in a config for this. + + Update Feb 5, 2015:
+ Adding Basic Auth, port configuration in config file. Currently authenticating against a single user in the config file; need to change when I have more time. Basic Auth expects the username:password combination in the /session path, and then encrypts that information and stores it in a session. The encrypted information is stored as a PRIVATE-TOKEN (similiar to the Gitlab API), and is expected in future http requests. - Testing Done:
-
+ Authentication:
+ - curl -u username:password http://localhost:8888/session returns 200 OK and the PRIVATE-TOKEN + - Set up a repository succesfully in RB using a valid user / pass combo, and saw the access log in rb-gateway - Commit:
-
c00ca725f3bb9d70208020e35254d2662419b6cee222396195689c8077f18669cca541c0a2346f63
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md
- Change Summary:
-
Getting file blob and checking file existance based on commit id, file path pairing (in addition to already supported revision id)
- Description:
-
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface - git_repository.go : The Git implementation of repository.go - routes.go : Handles all web services and routing - util.go : Handles configuration loading and repository lookup - sample_config.json : Sample configuration file using .json format - main.go : main() lives here, access logging - auth.go : Basic Auth implementation - session.go : Represents the current user session Currently as a test, the web server runs on port 8888. A sample works as follows:
1. Specify repo_name = path in config.json (see file attachment) 2. After the server is started, go to ./localhost:8888?repo=repo_name&id=sha 3. A file should download containing the requested blob. Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
Update Feb 1, 2015:
Service now is now capable of listening for RB requests if rb-gateway is running on localhost:8888. I still need to add in a config for this. Update Feb 5, 2015:
Adding Basic Auth, port configuration in config file. Currently authenticating against a single user in the config file; need to change when I have more time. Basic Auth expects the username:password combination in the /session path, and then encrypts that information and stores it in a session. The encrypted information is stored as a PRIVATE-TOKEN (similiar to the Gitlab API), and is expected in future http requests. + + Update Feb 12, 2015:
+ Added routes for getting file blob and checking file existance based on commit id, file path pair. - Testing Done:
-
Authentication:
- curl -u username:password http://localhost:8888/session returns 200 OK and the PRIVATE-TOKEN - Set up a repository succesfully in RB using a valid user / pass combo, and saw the access log in rb-gateway + + File and File Exists
+ - Tested the following paths via browser, review board, and curl for HEAD and GET methods; returned expected values for valid requests: + - http://localhost:8002/file?id=<revision-sha> (returned 200 OK, and file blob if GET) + - http://localhost:8002/file?commit=<commit>&path=<path> (returned 200 OK, and file blob if GET) - Commit:
-
e222396195689c8077f18669cca541c0a2346f637d018e4c6f3c01148649a7b3a5b187a3f5458ad7
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md
- Change Summary:
-
Updated description / testing done a bit / removed WIP
- Summary:
-
[WIP] rb-gatewayrb-gateway
- Description:
-
This is the beginnings of the rb-gateway project. It is meant to extend existing ReviewBoard functionalities to provide better support for repositories.
Currently, this is a wireframe set up using Google Go, and the git2go library for better Git support.
Structure is as followed:
- repository.go : Base repository structure and interface - git_repository.go : The Git implementation of repository.go - routes.go : Handles all web services and routing - util.go : Handles configuration loading and repository lookup - sample_config.json : Sample configuration file using .json format - main.go : main() lives here, access logging - auth.go : Basic Auth implementation - session.go : Represents the current user session ~ Currently as a test, the web server runs on port 8888. A sample works as follows:
~ 1. Specify repo_name = path in config.json (see file attachment) ~ 2. After the server is started, go to ./localhost:8888?repo=repo_name&id=sha ~ Local use case:
~ 1. Specify repo_name = path in config.json (see sample config) ~ 2. Specify credentials in config.json + 3. Specify the port you want the server to run on + 2. After the server is started, go to ./localhost:<port>?repo=repo_name&id=sha 3. A file should download containing the requested blob. Link the old review request before pointing to rb-gateway: https://reviews.reviewboard.org/r/6825/
~ Update Feb 1, 2015:
~ The server uses Basic Auth. Currently authenticating against a single user in the config file, this may need to change. Basic Auth expects the username:password combination in the /session path, and then encrypts that information and stores it in a session. The encrypted information is stored as a PRIVATE-TOKEN (similiar to the Gitlab API), and is expected in future http requests.
- Service now is now capable of listening for RB requests if rb-gateway is running on localhost:8888. I still need to add in a config for this. ~ Update Feb 5, 2015:
~ Routes are available for getting file blob and checking file existance based on either the Git revision, or the Git commit id, file path pair. It currently does not support other SCM aside from Git.
- Adding Basic Auth, port configuration in config file. Currently authenticating against a single user in the config file; need to change when I have more time. Basic Auth expects the username:password combination in the /session path, and then encrypts that information and stores it in a session. The encrypted information is stored as a PRIVATE-TOKEN (similiar to the Gitlab API), and is expected in future http requests. - - Update Feb 12, 2015:
- Added routes for getting file blob and checking file existance based on commit id, file path pair. - Testing Done:
-
Authentication:
~ - curl -u username:password http://localhost:8888/session returns 200 OK and the PRIVATE-TOKEN ~ - curl -u username:password http://localhost:8002/session returns 200 OK and the PRIVATE-TOKEN - Set up a repository succesfully in RB using a valid user / pass combo, and saw the access log in rb-gateway File and File Exists
- Tested the following paths via browser, review board, and curl for HEAD and GET methods; returned expected values for valid requests: - http://localhost:8002/file?id=<revision-sha> (returned 200 OK, and file blob if GET) - http://localhost:8002/file?commit=<commit>&path=<path> (returned 200 OK, and file blob if GET)
-
This is looking really solid!
Can you go through the comments for things and make sure that they follow these conventions: http://blog.golang.org/godoc-documenting-go-code ?
-
Instead of grabbing github master, how about using "gopkg.in/libgit2/git2go.v22"? That way people building this can just do
go get
to grab the dependency rather than the complicated git/make/etc steps. -
These two comments don't really add very much (it's pretty easy to find these functions in a relatively small codebase, and other than that they just repeat the function name)
-
-
-
-
- Change Summary:
-
Changes to comments and naming conventions, to be more Go-ish.
- Commit:
-
7d018e4c6f3c01148649a7b3a5b187a3f5458ad77d26f59cfda219a1ebf9da452745b59e396b4c23
-
Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md
- Change Summary:
-
Minor changes to sample_config.json (Added space afer colon)
- Commit:
-
7d26f59cfda219a1ebf9da452745b59e396b4c23f7516d8d983a8a1bb2a1d29b1267e601c926d5be
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md
- Change Summary:
-
Added SCM types back to sample_config.json
- Commit:
-
f7516d8d983a8a1bb2a1d29b1267e601c926d5beba391abc49d62a59fb02a8174cc1ed2f97d6781e
-
Tool: Pyflakes Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md Tool: PEP8 Style Checker Ignored Files: git_repository.go sample_config.json repository.go auth.go .gitignore main.go session.go routes.go util.go README.md