-
Notifications
You must be signed in to change notification settings - Fork 27
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
CNF-14938: implement GET /O2ims_infrastructureMonitoring/v1/alarms/{alarmEventRecordId} #319
base: main
Are you sure you want to change the base?
Conversation
@pixelsoccupied: This pull request references CNF-14938 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Skipping CI for Draft Pull Request. |
@pixelsoccupied: This pull request references CNF-14938 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
73158a0
to
f5973b5
Compare
/test |
@pixelsoccupied: The
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/test all |
1 similar comment
/test all |
/cc @alegacy |
will revisit the testing since |
// TODO: update config with trace, timeouts etc. | ||
poolConfig, err := pgxpool.ParseConfig(fmt.Sprintf("postgres://%s:%s@%s:%s/%s", | ||
poolConfig, err := pgxpool.ParseConfig(fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", |
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.
We should try to ensure that sslmode gets enabled here.
` | ||
|
||
// Run query | ||
rows, _ := ar.Db.Query(ctx, query, uuid.String()) // note: err is passed on to Collect* func so we can ignore this |
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 assume the answer is yes, but are we sure that the Query
method protects us against SQL injection attacks? ... i know in this particular case it isn't possible since the UUID string would be validated for format before this point, but in other instances that may not always be the case.
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.
/lgtm |
func (ar *AlarmsRepository) GetAlarmEventRecordWithUuid(ctx context.Context, uuid uuid.UUID) ([]models.AlarmEventRecord, error) { | ||
// Build sql query | ||
query := ` | ||
SELECT alarm_event_record_id, alarm_definition_id, probable_cause_id, alarm_raised_time, |
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 think it's worth having a look at
https://github.com/doug-martin/goqu or squirrel
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.
Ah would be nice to have a type safe code. I only experimented with sqlc (similar to goqu but takes sql and coverts to typed code) but was generating too much extra code. But this seems nice it it's simply wrapping the usual sql code with a type safety - so no random syntax errors. Does this work well with pgx? I suppose the query is simply converted to a string and then pgx simply continues as usual?
Let's experiment with it a bit more but +1 type safety. @alegacy
) | ||
|
||
type AlarmsServer struct { | ||
AlarmsRepository *AlarmsRepository | ||
AlarmsRepository *repo.AlarmsRepository |
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.
you can mock this to have some basic unit tests
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.
Yeah absolutely but there's not much to test with this current PR (other than actually sql stuff) so not creating any interface for now to mock. Will update this on a follow up PR where we have stuff outside of the sql calls to test...wdyt?
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mlguerrero12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
9ce5e3c
to
f468a90
Compare
/lgtm |
This PR implements
alarms/{alarmEventRecordId}
where you query the DB for existing record using a given UUID// 200
// 404
// 400
// 500