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

refactor: split up label command into separate Fetch/GetLabels/GetIDOrName #967

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

phm07
Copy link
Contributor

@phm07 phm07 commented Jan 23, 2025

This change is intended for an upcoming resource that has labels but doesn't have numeric IDs.

@phm07 phm07 self-assigned this Jan 23, 2025
@phm07 phm07 requested a review from a team as a code owner January 23, 2025 16:56
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 81.33333% with 28 lines in your changes missing coverage. Please review.

Project coverage is 63.69%. Comparing base (48b4fc7) to head (6d4faef).

Files with missing lines Patch % Lines
internal/cmd/base/labels.go 70.58% 3 Missing and 2 partials ⚠️
internal/cmd/image/labels.go 76.92% 3 Missing ⚠️
internal/cmd/certificate/labels.go 83.33% 2 Missing ⚠️
internal/cmd/firewall/labels.go 83.33% 2 Missing ⚠️
internal/cmd/floatingip/labels.go 83.33% 2 Missing ⚠️
internal/cmd/loadbalancer/labels.go 83.33% 2 Missing ⚠️
internal/cmd/network/labels.go 83.33% 2 Missing ⚠️
internal/cmd/placementgroup/labels.go 83.33% 2 Missing ⚠️
internal/cmd/primaryip/labels.go 83.33% 2 Missing ⚠️
internal/cmd/server/labels.go 83.33% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #967      +/-   ##
==========================================
- Coverage   70.01%   63.69%   -6.32%     
==========================================
  Files         245      243       -2     
  Lines       10715    10723       +8     
==========================================
- Hits         7502     6830     -672     
- Misses       2537     3178     +641     
- Partials      676      715      +39     
Flag Coverage Δ
e2e ?
unit 63.69% <81.33%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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.

Where do you intend to use this? / What is the benefit of this refactor?

Comment on lines 23 to 26
Fetch func(s state.State, idOrName string) (any, error)
SetLabels func(s state.State, resource any, labels map[string]string) error
GetLabels func(resource any) map[string]string
GetIDOrName func(resource any) string
Copy link
Member

Choose a reason for hiding this comment

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

We could make LabelCmds generic over the resource structs to get rid of the any here

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, added that in 6d4faef. We could think about doing that for the other structs in internal/cmd/base as well.

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