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

[CECO-1860][DatadogGenericResource] Refactor handler #1634

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

Conversation

tbavelier
Copy link
Member

What does this PR do?

Slightly refactors GenericResource controller to use interfaces avoiding code duplication and improving readability+maintenance

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

Same instructions as #1534, can use config/samples/datadoghq_v1alpha1_datadoggenericresource.yaml

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@tbavelier tbavelier added this to the v1.13.0 milestone Jan 20, 2025
@tbavelier tbavelier requested a review from a team as a code owner January 20, 2025 11:34
@tbavelier tbavelier mentioned this pull request Jan 20, 2025
2 tasks
@@ -65,6 +66,9 @@ func Test_handleFinalizer(t *testing.T) {
Finalizers: []string{datadogGenericResourceFinalizer},
DeletionTimestamp: &metaNow,
},
Spec: datadoghqv1alpha1.DatadogGenericResourceSpec{
Copy link
Member Author

@tbavelier tbavelier Jan 20, 2025

Choose a reason for hiding this comment

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

This is necessary as the switch case for deletion handler now panics on unsupported/empty resource type

@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 36.17021% with 60 lines in your changes missing coverage. Please review.

Project coverage is 48.96%. Comparing base (98ae1c6) to head (8eaf543).

Files with missing lines Patch % Lines
...al/controller/datadoggenericresource/synthetics.go 0.00% 34 Missing ⚠️
...nal/controller/datadoggenericresource/notebooks.go 8.33% 22 Missing ⚠️
...nternal/controller/datadoggenericresource/utils.go 88.88% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1634      +/-   ##
==========================================
+ Coverage   48.93%   48.96%   +0.02%     
==========================================
  Files         217      217              
  Lines       20892    20880      -12     
==========================================
  Hits        10223    10223              
+ Misses      10129    10117      -12     
  Partials      540      540              
Flag Coverage Δ
unittests 48.96% <36.17%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
...nternal/controller/datadoggenericresource/utils.go 95.34% <88.88%> (+38.29%) ⬆️
...nal/controller/datadoggenericresource/notebooks.go 21.12% <8.33%> (+4.10%) ⬆️
...al/controller/datadoggenericresource/synthetics.go 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98ae1c6...8eaf543. Read the comment docs.

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

Successfully merging this pull request may close these issues.

2 participants