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

Object Store Compatibility #56

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

Object Store Compatibility #56

wants to merge 12 commits into from

Conversation

uzaxirr
Copy link
Collaborator

@uzaxirr uzaxirr commented Mar 21, 2024

Description of your changes

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

@uzaxirr uzaxirr self-assigned this Mar 21, 2024
@uzaxirr uzaxirr marked this pull request as ready for review March 26, 2024 09:58
@uzaxirr
Copy link
Collaborator Author

uzaxirr commented Apr 3, 2024

Screenshot 2024-04-03 at 2 15 04 PM

Screenshot 2024-04-03 at 2 15 27 PM

Signed-off-by: uzair <uzaxirr@gmail.com>
Signed-off-by: uzair <uzaxirr@gmail.com>
Name: secretName,
}, connectionSecret)
if err != nil {
err = e.kube.Create(ctx, connectionSecret, &client.CreateOptions{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should confirm that we got a NotExists error before we attempt to create

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

return err
}
objectStore, err := e.civoClient.GetObjectStoreByName(os.Spec.Name)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not attempt a Delete directly? If we get a 404/NotFound error, we can consider that a successfull operation as resource doesn't exist- which is what Delete is responsible for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Signed-off-by: uzair <uzaxirr@gmail.com>
Signed-off-by: uzair <uzaxirr@gmail.com>
@@ -0,0 +1,20 @@
package civoobjectstore
Copy link
Collaborator

Choose a reason for hiding this comment

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

call this file as connection.go maybe? Just avoiding using utils

)

const (
errNotCivoObjectStore = "managed resource is not a object store"
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are some useful methods in civogo to help with error assertion. https://github.com/civo/civogo/blob/master/errors.go#L291

civoClient *civocli.CivoClient
}

// nolint
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should avoid using nolint and when we use it, we should have a reason noted for it.

func (c *CivoClient) GetObjectStore(id string) (*civogo.ObjectStore, error) {
objectStore, err := c.civoGoClient.GetObjectStore(id)
if err != nil {
if strings.Contains(err.Error(), "ZeroMatchesError") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two things-

  • Error assertion can be done with civogo
  • We should asserting this in controller, not here.

Signed-off-by: Uzair Ali <72073401+uzaxirr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants