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

Move NP generate to v1beta1 #83

Merged
merged 2 commits into from
Jan 3, 2024
Merged

Move NP generate to v1beta1 #83

merged 2 commits into from
Jan 3, 2024

Conversation

dwertent
Copy link

@dwertent dwertent commented Jan 3, 2024

Type

enhancement, tests


Description

This PR focuses on moving the Network Policy generation to the v1beta1 version. The main changes include:

  • Making certain fields optional in various structs by adding omitempty to their JSON tags. These fields include PoliciesRef in GeneratedNetworkPolicy, Relevant in VulnerabilityCounters, and WorkloadVulnerabilitiesObj in VulnerabilitiesComponents.
  • Updating the import paths for softwarecomposition and networkpolicy in several files to point to the v1beta1 version.
  • Adjusting the test cases in networkpolicy_test.go and generatednetworkpolicy_test.go to reflect the updated import paths.

PR changes walkthrough

Relevant files                                                                                                                                 
Enhancement
4 files
network_types.go                                                                                       
    pkg/apis/softwarecomposition/v1beta1/network_types.go

    Made the PoliciesRef field in the GeneratedNetworkPolicy
    struct optional by adding omitempty to its JSON tag.

+1/-1
networkpolicy.go                                                                                       
    pkg/apis/softwarecomposition/v1beta1/networkpolicy/networkpolicy.go

    Updated the import path for softwarecomposition to point
    to the v1beta1 version.

+1/-1
types.go                                                                                                       
    pkg/apis/softwarecomposition/v1beta1/types.go

    Made the Relevant field in the VulnerabilityCounters
    struct and the WorkloadVulnerabilitiesObj field in the
    VulnerabilitiesComponents struct optional by adding
    omitempty to their JSON tags.

+2/-2
generatednetworkpolicy.go                                                                     
    pkg/registry/file/generatednetworkpolicy.go

    Updated the import paths for softwarecomposition and
    networkpolicy to point to the v1beta1 version.

+2/-2
Tests
2 files
networkpolicy_test.go                                                                             
    pkg/apis/softwarecomposition/v1beta1/networkpolicy/networkpolicy_test.go

    Updated the import path for softwarecomposition in the
    test file to point to the v1beta1 version.

+1/-1
generatednetworkpolicy_test.go                                                           
    pkg/registry/file/generatednetworkpolicy_test.go

    Updated the import path for softwarecomposition in the
    test file to point to the v1beta1 version. Also, made
    changes in the test cases to reflect the updated import
    paths.

+24/-6

User description

Sorry, we do not accept changes directly against this repository. Please see
CONTRIBUTING.md for information on where and how to contribute instead.

David Wertenteil added 2 commits January 3, 2024 09:03
Signed-off-by: David Wertenteil <[email protected]>
Signed-off-by: David Wertenteil <[email protected]>
@codiumai-pr-agent-free codiumai-pr-agent-free bot added enhancement New feature or request Tests labels Jan 3, 2024
Copy link

PR Description updated to latest commit (f704a3a)

Copy link

PR Analysis

  • 🎯 Main theme: Moving Network Policy generation to v1beta1
  • 📝 PR summary: This PR focuses on updating the Network Policy generation to use the v1beta1 version. It includes changes to make certain fields optional in various structs, updating import paths to point to the v1beta1 version, and adjusting test cases to reflect these changes.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: Yes
  • ⏱️ Estimated effort to review [1-5]: 2, because the changes are mostly related to version updates and making certain fields optional, which are straightforward to review.
  • 🔒 Security concerns: No security concerns found

PR Feedback

💡 General suggestions: The PR seems to be well-structured and follows good practices. The changes are clear and the updates to the tests are appropriate. However, it would be beneficial to include more context or reasoning behind why certain fields are now optional.

🤖 Code feedback:
relevant filepkg/apis/softwarecomposition/v1beta1/network_types.go
suggestion      

Consider adding a comment explaining why PoliciesRef is now optional. This would provide more context to other developers and maintainers. [medium]

relevant linePoliciesRef []PolicyRef json:"policyRef,omitempty"

relevant filepkg/apis/softwarecomposition/v1beta1/types.go
suggestion      

Similar to the previous suggestion, it would be helpful to add a comment explaining why Relevant and WorkloadVulnerabilitiesObj are now optional. [medium]

relevant lineRelevant int json:"relevant,omitempty"

relevant filepkg/registry/file/generatednetworkpolicy_test.go
suggestion      

It might be beneficial to add more test cases to cover the new optional fields when they are not provided. This would ensure that the code behaves as expected in these scenarios. [important]

relevant lineobjPtr: &softwarecomposition.GeneratedNetworkPolicy{},

✨ Usage tips:

To invoke the PR-Agent, add a comment using one of the following commands:

  • /review: Request a review of your Pull Request.
  • /describe: Update the PR title and description based on the contents of the PR.
  • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
  • /ask <QUESTION>: Ask a question about the PR.
  • /update_changelog: Update the changelog based on the PR's contents.
  • /add_docs 💎: Generate docstring for new components introduced in the PR.
  • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
  • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

See the tools guide for more details.
To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

Copy link

github-actions bot commented Jan 3, 2024

Summary:

  • License scan: failure
  • Credentials scan: success
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: success

@dwertent dwertent merged commit cbfa885 into main Jan 3, 2024
6 checks passed
@matthyx matthyx deleted the no-generate branch October 1, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request release Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant