in internal/controller/teamcity_controller.go [174:198]
func (r *TeamcityReconciler) reconcileCreateOrUpdate(ctx context.Context, builder resource.ResourceBuilder) (ctrl.Result, error) {
log := log.FromContext(ctx)
objectList, err := builder.BuildObjectList()
if err != nil {
return ctrl.Result{}, err
}
for _, object := range objectList {
var operationResult controllerutil.OperationResult
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
var apiError error
operationResult, apiError = controllerutil.CreateOrUpdate(ctx, r.Client, object, func() error {
return builder.Update(object)
})
return apiError
})
if err != nil {
log.V(1).Error(err, fmt.Sprintf("Failed to update object %s %s", object.GetObjectKind().GroupVersionKind().Kind, object.GetName()))
return ctrl.Result{}, err
}
log.V(1).Info(fmt.Sprintf("Status of object %s %s is now %s", object.GetObjectKind().GroupVersionKind().Kind, object.GetName(), operationResult))
}
return ctrl.Result{}, nil
}