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

feat: implement actions waiter #407

Merged
merged 7 commits into from May 3, 2024
Merged

feat: implement actions waiter #407

merged 7 commits into from May 3, 2024

Conversation

jooola
Copy link
Member

@jooola jooola commented Apr 18, 2024

Implement a simpler and more versatile waiting functions for actions.

Most use cases when waiting for actions is to return early if an action fails. If all actions must be waited until completion, the users should use the WaitForFunc function.

If the final actions objects are needed, the users should use the WaitForFunc function to store the final actions using the handleUpdate callback.

This deprecates the ActionClient.WatchOverallProgress and ActionClient.WatchProgress methods.

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 92.10526% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 80.69%. Comparing base (172d137) to head (7bb1a7b).

Files Patch % Lines
hcloud/action_waiter.go 87.50% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #407      +/-   ##
==========================================
+ Coverage   80.43%   80.69%   +0.25%     
==========================================
  Files          33       34       +1     
  Lines        5756     5770      +14     
==========================================
+ Hits         4630     4656      +26     
+ Misses        718      708      -10     
+ Partials      408      406       -2     

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

go.mod Outdated Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
@jooola jooola force-pushed the new-action-waiter branch 4 times, most recently from 704af1e to 1c3c707 Compare April 30, 2024 10:03
@jooola jooola marked this pull request as ready for review April 30, 2024 10:03
@jooola jooola requested a review from a team as a code owner April 30, 2024 10:03
@jooola jooola requested review from apricote and phm07 April 30, 2024 10:04
Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Looking mostly good, I really like the new Interface. This matches what we need in most integrations very well.

Did you already test this code in CLI or some other tool? Would be nice if we had some real life (or e2e) test usage before releasing.

hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter.go Show resolved Hide resolved
hcloud/action_waiter.go Outdated Show resolved Hide resolved
hcloud/action_waiter_test.go Outdated Show resolved Hide resolved
hcloud/action_waiter_test.go Outdated Show resolved Hide resolved
hcloud/action_waiter_test.go Outdated Show resolved Hide resolved
@jooola
Copy link
Member Author

jooola commented Apr 30, 2024

I fixed the few comments.

I didn't use this branch in another project, I'll try it out.

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Great work @jooola! Looking forward to replace all of our home-grown implementations with this one!

@jooola jooola merged commit 1e3fa70 into main May 3, 2024
4 checks passed
@jooola jooola deleted the new-action-waiter branch May 3, 2024 16:41
@jooola jooola added the backport release-1.x Open PR against release-1.x with these changes after the PR is merged. label May 6, 2024
Copy link
Contributor

github-actions bot commented May 6, 2024

The backport to release-1.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release-1.x release-1.x
# Navigate to the new working tree
cd .worktrees/backport-release-1.x
# Create a new branch
git switch --create backport-407-to-release-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1e3fa7033d8a1cea1c0a9007a6255798979f0771
# Push it to GitHub
git push --set-upstream origin backport-407-to-release-1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release-1.x

Then, create a pull request where the base branch is release-1.x and the compare/head branch is backport-407-to-release-1.x.

jooola added a commit that referenced this pull request May 6, 2024
Implement a simpler and more versatile waiting functions for actions.

Most use cases when waiting for actions is to return early if an action
fails. If all actions must be waited until completion, the users should
use the `WaitForFunc` function.

If the final actions objects are needed, the users should use the
`WaitForFunc` function to store the final actions using the
`handleUpdate` callback.

This deprecates the `ActionClient.WatchOverallProgress` and
`ActionClient.WatchProgress` methods.

(cherry picked from commit 1e3fa70)
jooola added a commit that referenced this pull request May 6, 2024
Implement a simpler and more versatile waiting functions for actions.

Most use cases when waiting for actions is to return early if an action
fails. If all actions must be waited until completion, the users should
use the `WaitForFunc` function.

If the final actions objects are needed, the users should use the
`WaitForFunc` function to store the final actions using the
`handleUpdate` callback.

This deprecates the `ActionClient.WatchOverallProgress` and
`ActionClient.WatchProgress` methods.

(cherry picked from commit 1e3fa70)

BEGIN_COMMIT_OVERRIDE
feat: implement actions waiter
END_COMMIT_OVERRIDE
jooola pushed a commit that referenced this pull request May 6, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.8.0](v2.7.2...v2.8.0)
(2024-05-06)


### Features

* **error:** show internal correlation id in error messages
([#411](#411))
([6c96d19](6c96d19))
* implement actions waiter
([#407](#407))
([1e3fa70](1e3fa70))
* require Go >= 1.21
([#424](#424))
([d4f4000](d4f4000))


### Bug Fixes

* improve error message format with correlation id
([#430](#430))
([013477f](013477f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-1.x Open PR against release-1.x with these changes after the PR is merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants