-
Notifications
You must be signed in to change notification settings - Fork 55
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
[OSE-166] Scaffolding for /v1/presentations/submissions #171
[OSE-166] Scaffolding for /v1/presentations/submissions #171
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #171 +/- ##
==========================================
+ Coverage 26.37% 26.52% +0.15%
==========================================
Files 21 21
Lines 1623 1640 +17
==========================================
+ Hits 428 435 +7
- Misses 1123 1133 +10
Partials 72 72 ☔ View full report in Codecov by Sentry. |
pkg/server/router/submission.go
Outdated
} | ||
|
||
type CreateSubmissionRequest struct { | ||
PresentationJwt keyaccess.JWT `json:"presentationJwt" validate:"required"` |
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.
nit: PresentationJWT
question: this better as SubmissionJWT
?
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.
Used SubmissionJWT
pkg/server/router/submission.go
Outdated
// @Failure 500 {string} string "Internal server error" | ||
// @Router /v1/presentations/submissions [put] | ||
func (sr SubmissionRouter) CreateSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
resp := Operation{} |
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.
var resp Operation
https://github.com/uber-go/guide/blob/master/style.md#use-var-for-zero-value-structs
note - don't think our README points to this style doc even though it should. may need to add it
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.
Done. Heavy +1 to adding it as well.
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.
ty - feel free to add to the README
pkg/server/router/submission.go
Outdated
// @Failure 400 {string} string "Bad request" | ||
// @Router /v1/presentations/submission/{id} [get] | ||
func (sr SubmissionRouter) GetSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
resp := GetSubmissionResponse{} |
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.
resp := GetSubmissionResponse{} | |
var resp GetSubmissionResponse |
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.
Done
pkg/server/router/submission.go
Outdated
// @Failure 500 {string} string "Internal server error" | ||
// @Router /v1/presentations/submissions [get] | ||
func (sr SubmissionRouter) ReviewSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
return framework.Respond(ctx, w, ReviewSubmissionResponse{}, http.StatusOK) |
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.
is there value in putting ReviewSubmissionResponse{}
over 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.
I don't think so. That said, this will change when the implementation is done.
pkg/server/server.go
Outdated
return s.PresentationAPI(service) | ||
case svcframework.Submission: | ||
return s.SubmissionAPI(service) |
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.
I had a working assumption that the PresentationAPI
was going to be including the SubmissionAPI
similar to how the ApplicationAPI
is under the ManifestAPI
. They should be the same service because they are a part of the same spec/group of functionality IMO
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.
Done. Grouped everything under the same API.
pkg/server/server.go
Outdated
|
||
return | ||
} | ||
func (s *SSIServer) SubmissionAPI(service svcframework.Service) (err error) { |
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.
along with above - would like to see this a part of the PresentationAPI
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.
Done.
pkg/service/submission/service.go
Outdated
submissionStorage, err := submissionstorage.NewSubmissionStorage(s) | ||
if err != nil { | ||
errMsg := "could not instantiate storage for the submission service" | ||
return nil, util.LoggingErrorMsg(err, errMsg) |
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.
could include the errMsg inline here
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.
Done.
pkg/service/submission/service.go
Outdated
|
||
if !request.IsValid() { | ||
errMsg := fmt.Sprintf("invalid create presentation submission request: %+v", request) | ||
return nil, util.LoggingNewError(errMsg) |
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.
could use LoggingNewErrorf
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.
Done.
pkg/service/submission/service.go
Outdated
storedSubmission, err := s.storage.GetSubmission(request.ID) | ||
if err != nil { | ||
err := errors.Wrapf(err, "error getting presentation submission: %s", request.ID) | ||
return nil, util.LoggingError(err) |
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.
could use LoggingNewErrorf
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.
Done.
pkg/service/submission/service.go
Outdated
} | ||
if storedSubmission == nil { | ||
err := fmt.Errorf("presentation submission with id<%s> could not be found", request.ID) | ||
return nil, util.LoggingError(err) |
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.
could use LoggingErrorf
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.
Used LoggingNewErrorf
namespace = "presentation_submission" | ||
) | ||
|
||
type BoltSubmissionStorage struct { |
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.
think this should be merged into the presentation storage
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.
Done.
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.
see comments
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.
@decentralgabe PTAL
pkg/server/router/submission.go
Outdated
// @Failure 500 {string} string "Internal server error" | ||
// @Router /v1/presentations/submissions [put] | ||
func (sr SubmissionRouter) CreateSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
resp := Operation{} |
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.
Done. Heavy +1 to adding it as well.
pkg/server/router/submission.go
Outdated
// @Failure 400 {string} string "Bad request" | ||
// @Router /v1/presentations/submission/{id} [get] | ||
func (sr SubmissionRouter) GetSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
resp := GetSubmissionResponse{} |
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.
Done
pkg/server/router/submission.go
Outdated
// @Failure 500 {string} string "Internal server error" | ||
// @Router /v1/presentations/submissions [get] | ||
func (sr SubmissionRouter) ReviewSubmission(ctx context.Context, w http.ResponseWriter, r *http.Request) error { | ||
return framework.Respond(ctx, w, ReviewSubmissionResponse{}, http.StatusOK) |
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.
I don't think so. That said, this will change when the implementation is done.
pkg/server/server.go
Outdated
return s.PresentationAPI(service) | ||
case svcframework.Submission: | ||
return s.SubmissionAPI(service) |
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.
Done. Grouped everything under the same API.
pkg/server/server.go
Outdated
|
||
return | ||
} | ||
func (s *SSIServer) SubmissionAPI(service svcframework.Service) (err error) { |
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.
Done.
pkg/service/submission/service.go
Outdated
|
||
if !request.IsValid() { | ||
errMsg := fmt.Sprintf("invalid create presentation submission request: %+v", request) | ||
return nil, util.LoggingNewError(errMsg) |
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.
Done.
pkg/service/submission/service.go
Outdated
storedSubmission, err := s.storage.GetSubmission(request.ID) | ||
if err != nil { | ||
err := errors.Wrapf(err, "error getting presentation submission: %s", request.ID) | ||
return nil, util.LoggingError(err) |
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.
Done.
pkg/service/submission/service.go
Outdated
} | ||
if storedSubmission == nil { | ||
err := fmt.Errorf("presentation submission with id<%s> could not be found", request.ID) | ||
return nil, util.LoggingError(err) |
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.
Used LoggingNewErrorf
namespace = "presentation_submission" | ||
) | ||
|
||
type BoltSubmissionStorage struct { |
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.
Done.
pkg/server/router/submission.go
Outdated
} | ||
|
||
type CreateSubmissionRequest struct { | ||
PresentationJwt keyaccess.JWT `json:"presentationJwt" validate:"required"` |
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.
Used SubmissionJWT
* The simplest scaffolding possible * rename Co-authored-by: Gabe <gcohen@squareup.com>
} | ||
|
||
type ListSubmissionRequest struct { | ||
Filter string `json:"filter"` |
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.
where's the right place to put doc on how the filter syntax works?
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.
Added below.
pkg/server/router/presentation.go
Outdated
|
||
// ListSubmissions godoc | ||
// @Summary List Submissions | ||
// @Description List existing submissions according to a filtering query. |
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.
maybe here with a link to the filter syntax we use
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.
Added here. Will likely expand on this once I do the implementation.
pkg/service/presentation/service.go
Outdated
presentationStorage, err := presentationstorage.NewPresentationStorage(s) | ||
if err != nil { | ||
errMsg := "could not instantiate storage for the presentation definition service" | ||
return nil, util.LoggingErrorMsg(err, errMsg) | ||
return nil, util.LoggingErrorMsg(err, "could not instantiate storage for the presentation definition service") |
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.
presentation service
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.
done.
if err != nil { | ||
errMsg := fmt.Sprintf("could not store submission definition: %s", id) | ||
logrus.WithError(err).Error(errMsg) | ||
return errors.Wrapf(err, errMsg) |
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.
nit: could use the util.Logging...
whatever as it combines the error creation, logging, and error return here and the rest of this file. but NBD
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.
Done.
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.
small comments, approving
This adds the routing for Create, Get, List, and Review endpoints for submissions. None of the business logic nor tests were added. Only simple routing, request types, and response types.