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 helper to get runID from Custom Deployment Protection Rule Event #3476

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

pputman-clabs
Copy link

Added Helper Function with test to get the RunID from the DeploymentCallbackURL and convert it to an int64.

Copy link

google-cla bot commented Feb 12, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis changed the title Pputman/add helper function Add helper to get runID from Custom Deployment Protection Rule Event Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.02%. Comparing base (c4b2cb9) to head (3e68ecc).

Files with missing lines Patch % Lines
github/github.go 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3476      +/-   ##
==========================================
- Coverage   91.04%   91.02%   -0.02%     
==========================================
  Files         179      179              
  Lines       15551    15562      +11     
==========================================
+ Hits        14158    14166       +8     
- Misses       1221     1223       +2     
- Partials      172      173       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @pputman-clabs.

It might be nice to add a comment to the other functions that required a runID that this new helper can be used to easily extract the value from the event.

github/github.go Show resolved Hide resolved
github/github.go Outdated Show resolved Hide resolved
github/github.go Show resolved Hide resolved
github/github_test.go Outdated Show resolved Hide resolved
github/github_test.go Outdated Show resolved Hide resolved
github/github_test.go Outdated Show resolved Hide resolved
@pputman-clabs
Copy link
Author

Okay I made the requested changes, thanks for the feedback! Let me know if there's anything else programming wise you think I should change and if not I'll start adding the documentation for it to the other method docs.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Please revert changes to go.mod and go.sum, as this helper and its tests should not require any more dependencies than we already have.

@pputman-clabs
Copy link
Author

Fixed, I didn't even notice those had updated, sorry. Thanks for the feedback, I'm learning as I go here.

github/github.go Outdated Show resolved Hide resolved
github/github.go Outdated
// Helper Function to extract the workflow RunID from the *DeploymentProtectionRuleEvent.DeploymentCallBackURL.
func (e *DeploymentProtectionRuleEvent) GetRunID() (int64, error) {
match := r.FindStringSubmatch(*e.DeploymentCallbackURL)
var ErrNoMatch = errors.New("no match found")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is not idiomatic Go for two reasons:

  • there is no need to export (capitalize) it
  • it is only used once and provides no more useful information by making it a separate line.

Therefore, please revert this change.

@pputman-clabs
Copy link
Author

Made requested changes, and added a comment to the actions_workflow_runs.go methods that they can use this helper function to easily pull out the RunID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants