Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ukff committed Jan 13, 2025
1 parent 77345f4 commit 201c0d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/btpoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,20 +777,20 @@ func (r *BtpOperatorReconciler) deleteCreationTimestamp(us ...*unstructured.Unst
}

func (r *BtpOperatorReconciler) applyOrUpdateResources(ctx context.Context, us []*unstructured.Unstructured) error {
logger := log.FromContext(ctx)
//logger := log.FromContext(ctx)
for _, u := range us {
preExistingResource := &unstructured.Unstructured{}
preExistingResource.SetGroupVersionKind(u.GroupVersionKind())
if err := r.Get(ctx, client.ObjectKey{Name: u.GetName(), Namespace: u.GetNamespace()}, preExistingResource); err != nil {
if !k8serrors.IsNotFound(err) {
return fmt.Errorf("while trying to get %s %s: %w", u.GetName(), u.GetKind(), err)
}
logger.Info(fmt.Sprintf("applying %s - %s", u.GetKind(), u.GetName()))
//logger.Info(fmt.Sprintf("applying %s - %s", u.GetKind(), u.GetName()))
if err := r.Patch(ctx, u, client.Apply, client.ForceOwnership, client.FieldOwner(operatorName)); err != nil {
return fmt.Errorf("while applying %s %s: %w", u.GetName(), u.GetKind(), err)
}
} else {
logger.Info(fmt.Sprintf("updating %s - %s", u.GetKind(), u.GetName()))
//logger.Info(fmt.Sprintf("updating %s - %s", u.GetKind(), u.GetName()))
u.SetResourceVersion(preExistingResource.GetResourceVersion())
if err := r.Update(ctx, u, client.FieldOwner(operatorName)); err != nil {
return fmt.Errorf("while updating %s %s: %w", u.GetName(), u.GetKind(), err)
Expand Down

0 comments on commit 201c0d0

Please sign in to comment.