Skip to content
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

Add Pagerduty trigger example in go #201

Merged

Conversation

codegold79
Copy link
Contributor

Summary

This PR adds a Go version of the PagerDuty trigger. Currently, there exists a version in Python.

Pull Request Checklist

🚨 Please review the guidelines for contributing to this repository.

  • Please ensure that you are making a pull request against the Development branch
  • Please use the WIP keyword in the title of your PR if you are not ready for review
  • Please ensure that you have opened a Github Issue if you are resolving/fixing a problem
  • Please ensure that you have signed all commits and that you have squashed all relevant commmits related to your change
  • Please make sure that you have tested your change locally by successfully building and deploying the VMware Event Broker Appliance and/or building and deploying VMware Event Router
  • Please include any relevant screenshots and/or output as part of your testing
  • Please include any documentation updates that is applicable for your changes

Change Type

What types of changes does your code introduce to the VMware Event Broker Appliance?

Please check the type of change your PR introduces:

  • Bugfix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation changes
  • Other (please describe):

Resolved Issues

List of Issues closed or resolved by this PR. Add multiple Closes keyword followed by the issue number (e.g. Closes #ISSUE-NUMBER)

  • Closes #ISSUE-NUMBER

Testing Verification

  • Short summary of testing (e.g. successfully built and deployed VMware Event Broker Appliance)
  • Please include any relevant screenshots and/or output as part of the testing

Screen Shot 2020-09-15 at 3 41 55 PM
Screen Shot 2020-09-15 at 3 45 29 PM

Additional Information

  • Any other details you wish to include or mention

If you have any questions/comments, feel free to reach out to team on Slack #vcenter-event-broker-appliance

Thank you from the VEBA Team! 🥳

@codegold79 codegold79 added documentation Improvements or additions to documentation enhancement New feature or request dco-required labels Sep 16, 2020
martindekov
martindekov previously approved these changes Sep 17, 2020
Copy link
Contributor

@martindekov martindekov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Frankie, I will approve just in case and you can refer the comments afterwards.

examples/go/pagerduty-trigger/handler/handler.go Outdated Show resolved Hide resolved
examples/go/pagerduty-trigger/handler/handler.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@embano1 embano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx Frankie, great contribution!

docs/site/examples.md Outdated Show resolved Hide resolved
examples/go/pagerduty-trigger/stack.yml Outdated Show resolved Hide resolved
examples/go/pagerduty-trigger/handler/types.go Outdated Show resolved Hide resolved
examples/go/pagerduty-trigger/handler/go.sum Show resolved Hide resolved
examples/go/pagerduty-trigger/handler/handler.go Outdated Show resolved Hide resolved
examples/go/pagerduty-trigger/handler/handler.go Outdated Show resolved Hide resolved
@embano1
Copy link
Collaborator

embano1 commented Sep 18, 2020

Once all comments are resolved, please sign and squash the commits.

Signed-off-by: codegold79 <fgold@vmware.com>
@codegold79
Copy link
Contributor Author

@embano1 I made the changes and put all the commits into one. I realized that I did that a little early as you haven't had a chance to re-review. Sorry about that. Hopefully, this function example is short/simple enough that looking through the code again won't be too much of a hassle.

embano1
embano1 previously approved these changes Sep 23, 2020
Copy link
Collaborator

@embano1 embano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor things, but we can keep note of them in PR and change if required in a separate PR.

return []byte{}, fmt.Errorf("read http response body: %w", err)
}

if res.StatusCode < 200 || res.StatusCode >= 300 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3xx does not necessarily have to be an error condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll change that to not include 3xx.

}

func pdSendRequest(ctx context.Context, path string, pdp pdPayload) ([]byte, error) {
clt := &http.Client{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best practice to create the client with some same timeouts.

Copy link
Contributor Author

@codegold79 codegold79 Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definite yes to that suggestion. I'll add a timeout.

@embano1 embano1 changed the title Pagerduty trigger example in go Add Pagerduty trigger example in go Sep 23, 2020
@codegold79 codegold79 requested a review from embano1 September 23, 2020 22:14
Signed-off-by: codegold79 <fgold@vmware.com>
@codegold79 codegold79 force-pushed the pagerduty-trigger-example-in-go branch from 2cc6196 to 1ff3a7e Compare September 23, 2020 22:16

reqBody, err := json.Marshal(pdp)
if err != nil {
return []byte{}, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These returns could be simplified with return nil, err

Copy link
Collaborator

@embano1 embano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment (nit) which can be fixed in a future PR.

@embano1 embano1 merged commit 88b878c into vmware-samples:development Sep 24, 2020
rapuli pushed a commit to rapuli/vcenter-event-broker-appliance that referenced this pull request Oct 30, 2020
* Add go-pagerduty-trigger handle function example using Go

Signed-off-by: codegold79 <fgold@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants