Skip to content

Commit

Permalink
fix(bridge): disable ros bridge on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
tunahanertekin committed Aug 7, 2023
1 parent 7b777fe commit a93c18e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/controllers/robot/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,14 @@ func (r *RobotReconciler) reconcileCheckLoaderJob(ctx context.Context, instance

func (r *RobotReconciler) reconcileCheckROSBridge(ctx context.Context, instance *robotv1alpha1.Robot) error {

if instance.Spec.ROSBridgeTemplate.ROS.Enabled || instance.Spec.ROSBridgeTemplate.ROS2.Enabled {
rosBridgeQuery := &robotv1alpha1.ROSBridge{}
err := r.Get(ctx, *instance.GetROSBridgeMetadata(), rosBridgeQuery)
if err != nil && errors.IsNotFound(err) {
instance.Status.ROSBridgeStatus = robotv1alpha1.ROSBridgeInstanceStatus{}
} else if err != nil {
return err
} else {

rosBridgeQuery := &robotv1alpha1.ROSBridge{}
err := r.Get(ctx, *instance.GetROSBridgeMetadata(), rosBridgeQuery)
if err != nil && errors.IsNotFound(err) {
instance.Status.ROSBridgeStatus = robotv1alpha1.ROSBridgeInstanceStatus{}
} else if err != nil {
return err
} else {
if instance.Spec.ROSBridgeTemplate.ROS2.Enabled {
if !reflect.DeepEqual(instance.Spec.ROSBridgeTemplate, rosBridgeQuery.Spec) {
rosBridgeQuery.Spec = instance.Spec.ROSBridgeTemplate
err = r.Update(ctx, rosBridgeQuery)
Expand All @@ -146,6 +145,11 @@ func (r *RobotReconciler) reconcileCheckROSBridge(ctx context.Context, instance
reference.SetReference(&instance.Status.ROSBridgeStatus.Resource.Reference, rosBridgeQuery.TypeMeta, rosBridgeQuery.ObjectMeta)
instance.Status.ROSBridgeStatus.Status = rosBridgeQuery.Status
instance.Status.ROSBridgeStatus.Connection = rosBridgeQuery.Status.ServiceStatus.URL
} else {
err := r.Delete(ctx, rosBridgeQuery)
if err != nil {
return err
}
}
}

Expand Down

0 comments on commit a93c18e

Please sign in to comment.