Open horis233 opened 4 years ago
@kgcarr I can provide an idea about how to implement the update function.
IsAlreadyExists
error when creating the resources.
err = r.client.Create(context.TODO(), obj)
if err != nil && !errors.IsAlreadyExists(err) {
return fmt.Errorf("could not Create resource: %v", err)
}
IsAlreadyExists
, if the resource is already exist, you can choose to update the resource.
err = r.client.Create(context.TODO(), obj)
if err != nil && !errors.IsAlreadyExists(err) {
return fmt.Errorf("could not Create resource: %v", err)
}
if errors.IsAlreadyExists(err) {
err = r.client.Update(context.TODO(), obj)
if err != nil {
return fmt.Errorf("could not Update resource: %v", err)
}
}
I am sure if all the MongoDB resources are permitted to be updated in the day2 option. You may need to take a look at this.
@kgcarr
Currently, MongoDB operator only supports create and delete function. We need to support update function when users edit MongoDB custom resource.