kubescape / storage

Apache License 2.0
1 stars 6 forks source link

fix: return already exists error #57

Closed vladklokun closed 10 months ago

vladklokun commented 10 months ago

PR Type:

Bug fix


PR Description:

This pull request introduces an 'AlreadyExists' error handling in the generic storage implementation. It adds a new function 'Exists' to check if an object with a given key already exists in the storage. If an attempt is made to create an object that already exists, a 'KeyExistsError' is returned. The changes are covered with corresponding unit tests.


PR Main Files Walkthrough:

files: `pkg/registry/file/storage.go`: Added a new function 'Exists' to check if an object with a given key already exists in the storage. Modified the 'Create' function to return a 'KeyExistsError' if an attempt is made to create an object that already exists. `pkg/registry/file/storage_test.go`: Added a new test 'TestStorageImpl_Exists' to verify the functionality of the 'Exists' function and the error handling in the 'Create' function. `pkg/registry/file/vulnerabilitysummarystorage_test.go`: Minor changes to the test setup, creating a new instance of 'StorageImpl' for each test run.

User Description:

What this PR changes

This commit adds an AlreadyExists error to the generic storage implementaiton.

Clients that rely on the Storage returning this error would now be fixed.

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.

vladklokun commented 10 months ago

This should also trigger a release of v0.0.30, so that a new image will have fixes for both the filename limit and the AlreadyExists error.

For some reason, v0.0.29 did not include the filename limit fix in the built image. To verify this, I built the image manually and checked how the same code that was supposed to be in the v0.0.29 image behaves in the cluster.

github-actions[bot] commented 10 months ago

Summary: