kubescape / storage

Apache License 2.0
1 stars 6 forks source link

feat: WIP add control etc crds #46

Open XDRAGON2002 opened 10 months ago

XDRAGON2002 commented 10 months ago

PR Type:

Enhancement


PR Description:

This PR introduces several new Custom Resource Definitions (CRDs) and their related functionalities:

For each of these CRDs, the PR includes the necessary conversion functions for the software composition scheme. It also updates the clientset, listers, and informers to handle these new CRDs.


PR Main Files Walkthrough:

files: - `pkg/apis/softwarecomposition/v1beta1/zz_generated.conversion.go`: Added conversion functions for the new CRDs (Control, Rule, Framework, Exception). - `pkg/generated/clientset/versioned/typed/softwarecomposition/v1beta1/controlconfiguration.go`: Updated the clientset to handle the new ControlConfiguration CRD. - `pkg/generated/clientset/versioned/typed/softwarecomposition/v1beta1/framework.go`: Updated the clientset to handle the new Framework CRD. - `pkg/generated/clientset/versioned/typed/softwarecomposition/v1beta1/exception.go`: Updated the clientset to handle the new Exception CRD. - `pkg/generated/clientset/versioned/typed/softwarecomposition/v1beta1/rule.go`: Updated the clientset to handle the new Rule CRD. - `pkg/apis/softwarecomposition/v1beta1/types.go`: Added definitions for the new CRDs (Control, Rule, Framework, Exception). - `pkg/generated/informers/externalversions/softwarecomposition/v1beta1/controlconfiguration.go`: Updated the informers to handle the new ControlConfiguration CRD. - `pkg/generated/informers/externalversions/softwarecomposition/v1beta1/exception.go`: Updated the informers to handle the new Exception CRD. - `pkg/generated/informers/externalversions/softwarecomposition/v1beta1/framework.go`: Updated the informers to handle the new Framework CRD. - `pkg/generated/informers/externalversions/softwarecomposition/v1beta1/rule.go`: Updated the informers to handle the new Rule CRD.
codiumai-pr-agent[bot] commented 10 months ago

PR Analysis

How to use

To invoke the PR-Agent, add a comment using one of the following commands: /review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option. /describe: Modify the PR title and description based on the contents of the PR. /improve [--extended]: Suggest improvements to the code in the PR. Extended mode employs several calls, and provides a more thorough feedback. /ask \<QUESTION>: Pose a question about the PR. /update_changelog: Update the changelog based on the PR's contents.

To edit any configuration parameter from configuration.toml, add --config_path=new_value For example: /review --pr_reviewer.extra_instructions="focus on the file: ..." To list the possible configuration parameters, use the /config command.

XDRAGON2002 commented 10 months ago

@vladklokun as discussed, I've been working on this for the past week, right now I'm stuck a bit as I just can't seem to be able to successfully run the codegen script hack/update-codegen.sh.

The script always seems to error out/give out warnings? Not even sure what they are, every time I run it but can't seem to generate the required deepcopy methods, also why they are not present in the PR.

I've looked for solutions online but can't seem to get it working still, any help regarding this would be extremely helpful! Thanks!

vladklokun commented 10 months ago

The script always seems to error out/give out warnings? Not even sure what they are, every time I run it but can't seem to generate the required deepcopy methods, also why they are not present in the PR.

Yes, the script always generates warnings when running, even after successfully generating deep copy methods, converters and OpenAPI definitions. That’s normal.

You can tell your script ran okay-ish when it generates all the methods you need.

Regarding the missing methods, I know it might sound exotic, but where have you cloned your project? There is a catch with hack/update_codegen.sh that it outputs its definitions in the $HOME/github.com/kubescape/storage/pkg directory, provided you installed the dependencies with the go mod vendor method. To you have generated files in this directory, by chance?

XDRAGON2002 commented 10 months ago

I did check this earlier as well, but that doesn't seem to be the case either, any things I should try and troubleshoot?

I was going to take a fresh look at it later again today :)

XDRAGON2002 commented 9 months ago

@vladklokun finally got the codegen working, could you maybe take a look and let me know if I've missed something before I go ahead and resolve the merge conflicts?

Thanks!

codiumai-pr-agent[bot] commented 9 months ago

PR Analysis

How to use

To invoke the PR-Agent, add a comment using one of the following commands: /review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option. /describe: Modify the PR title and description based on the contents of the PR. /improve [--extended]: Suggest improvements to the code in the PR. Extended mode employs several calls, and provides a more thorough feedback. /ask \<QUESTION>: Pose a question about the PR. /update_changelog: Update the changelog based on the PR's contents.

To edit any configuration parameter from configuration.toml, add --config_path=new_value For example: /review --pr_reviewer.extra_instructions="focus on the file: ..." To list the possible configuration parameters, use the /config command.

vladklokun commented 9 months ago

Hi! I finally had a chance to look at the PR. Thank you for your patience.

Type definitions and wiring look good to me.

However, we just merged a PR that includes changes to codegen. Please rebase and try to fix conflicts with the base branch and try to verify that the Custom Resources work. A good start to manually test this would be to create example Custom Resources in the artifacts/{rule,framework,control,...} directory, deploy your APIServer in a cluster using the manifests in the artifacts/example directory and then to create the example Custom Resources you put in the artifacts subdirectories.

XDRAGON2002 commented 9 months ago

Sure!

Will do that and get back to you on this.

Thanks!

XDRAGON2002 commented 8 months ago

@vladklokun have made the required changes! Thanks!

dwertent commented 8 months ago

@XDRAGON2002 Can you please commit the go.sum file as well so the test will pass.

XDRAGON2002 commented 8 months ago

@dwertent Completely forgot about that! Thanks! Done!

XDRAGON2002 commented 8 months ago

This is weird, the tests still failed due to the go.mod/sum dependency issue, I already did push the updated ones though.

Edit: Most probably got it, I was using go1.20 whereas some new packages require 1.21, did the change updated everything and pushed, should pass now.

XDRAGON2002 commented 8 months ago

@vladklokun @dwertent I'm pretty sure the tests will fail again, I can't seem to figure out why it is so.

Any help would be much appreciated!