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

NETOBSERV-1201: Make empty CR work out of the box #398

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

jotak
Copy link
Member

@jotak jotak commented Jul 19, 2023

Fixing a couple of default values that weren't working as expected:

  • metav1.Duration fields need to be pointers so their default is actually used
  • deploymentModel shouldn't be required as it default to DIRECT
  • Agent type default wasn't working due to missing omitempty
  • Add a test to make sure empty spec works

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jul 19, 2023

@jotak: This pull request references NETOBSERV-1201 which is a valid jira issue.

In response to this:

Fixing a couple of default values that weren't working as expected:

  • metav1.Duration fields need to be pointers so their default is actually used
  • deploymentModel shouldn't be required as it default to DIRECT
  • Agent type default wasn't working due to missing omitempty
  • Add a test to make sure empty spec works

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -68,3 +70,10 @@ func MaxLabelLength(in string) string {
}
return in[:maxLabelLength]
}

func UnstructuredDuration(in *metav1.Duration) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add ut coverage for this api, I have one for u :)

func TestUnstructuredDuration(t *testing.T) {

  t.Run("nil input", func(t *testing.T) {
    var d *metav1.Duration
    got := UnstructuredDuration(d)
    want := ""
    
    if got != want {
      t.Errorf("got %q, want %q", got, want) 
    }
  })

  t.Run("valid input", func(t *testing.T) {
    d := &metav1.Duration{Duration: time.Minute}
    want := "1m0s"
    
    got := UnstructuredDuration(d)
    
    if got != want {
      t.Errorf("got %q, want %q", got, want)
    }
  })

}

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks! done

Copy link
Contributor

@msherif1234 msherif1234 left a comment

Choose a reason for hiding this comment

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

/LGTM
just suggested adding UT coverage and u need to fix rebase issues

Fixing a couple of default values that weren't working as expected:
- metav1.Duration fields need to be pointers so their default is
  actually used
- deploymentModel shouldn't be required as it default to DIRECT
- Agent type default wasn't working due to missing omitempty
- Add a test to make sure empty spec works
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #398 (2a01824) into main (0d6ebe8) will increase coverage by 0.02%.
The diff coverage is 55.55%.

@@            Coverage Diff             @@
##             main     #398      +/-   ##
==========================================
+ Coverage   53.67%   53.69%   +0.02%     
==========================================
  Files          44       44              
  Lines        5559     5596      +37     
==========================================
+ Hits         2984     3005      +21     
- Misses       2359     2375      +16     
  Partials      216      216              
Flag Coverage Δ
unittests 53.69% <55.55%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
api/v1alpha1/zz_generated.conversion.go 0.25% <0.00%> (-0.01%) ⬇️
api/v1beta1/flowcollector_types.go 100.00% <ø> (ø)
api/v1beta1/zz_generated.deepcopy.go 55.36% <100.00%> (+1.58%) ⬆️
controllers/consoleplugin/consoleplugin_objects.go 95.42% <100.00%> (ø)
controllers/flowlogspipeline/flp_common_objects.go 81.76% <100.00%> (ø)
pkg/helper/helpers.go 100.00% <100.00%> (ø)

@msherif1234
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 20, 2023
@jotak
Copy link
Member Author

jotak commented Jul 20, 2023

Merging for dequeuing - I don't think specific tests are needed here, apart from usual regression tests
/approve

@openshift-ci
Copy link

openshift-ci bot commented Jul 20, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 1a1eb18 into netobserv:main Jul 20, 2023
9 checks passed
@msherif1234
Copy link
Contributor

/ok-to-test

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.

None yet

4 participants