Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Fix flow position with 0 (#205)
Browse files Browse the repository at this point in the history
* Fix flow position with 0

* Fix flow position with 0
  • Loading branch information
juldrixxbis authored Mar 8, 2022
1 parent 83edc14 commit 255d7c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 14 additions & 0 deletions api/v1alpha1/nifidataflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ func (d *NifiDataflowSpec) GetParentProcessGroupID(rootProcessGroupId string) st
}
return d.ParentProcessGroupID
}

func (p *FlowPosition) GetX() int64 {
if p.X == nil || *p.X == 0 {
return 1
}
return *p.X
}

func (p *FlowPosition) GetY() int64 {
if p.Y == nil || *p.Y == 0 {
return 1
}
return *p.Y
}
12 changes: 6 additions & 6 deletions pkg/clientwrappers/dataflow/dataflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ func isVersioningChanged(
// isPostionChanged check if the position of the process group is out of sync.
func isPostionChanged(flow *v1alpha1.NifiDataflow, pgFlowEntity *nigoapi.ProcessGroupEntity) bool {
return flow.Spec.FlowPosition != nil &&
((flow.Spec.FlowPosition.X != nil && float64(*flow.Spec.FlowPosition.X) != pgFlowEntity.Component.Position.X) ||
(flow.Spec.FlowPosition.Y != nil && float64(*flow.Spec.FlowPosition.Y) != pgFlowEntity.Component.Position.Y))
((flow.Spec.FlowPosition.X != nil && float64(flow.Spec.FlowPosition.GetX()) != pgFlowEntity.Component.Position.X) ||
(flow.Spec.FlowPosition.Y != nil && float64(flow.Spec.FlowPosition.GetY()) != pgFlowEntity.Component.Position.Y))
}

// SyncDataflow implements the logic to sync a NifiDataflow with the deployed flow.
Expand Down Expand Up @@ -280,13 +280,13 @@ func SyncDataflow(
if flow.Spec.FlowPosition == nil || flow.Spec.FlowPosition.X == nil {
xPos = pGEntity.Component.Position.X
} else {
xPos = float64(*flow.Spec.FlowPosition.X)
xPos = float64(flow.Spec.FlowPosition.GetX())
}

if flow.Spec.FlowPosition == nil || flow.Spec.FlowPosition.Y == nil {
yPos = pGEntity.Component.Position.Y
} else {
yPos = float64(*flow.Spec.FlowPosition.Y)
yPos = float64(flow.Spec.FlowPosition.GetY())
}

pGEntity.Component.Position = &nigoapi.PositionDto{
Expand Down Expand Up @@ -738,13 +738,13 @@ func updateProcessGroupEntity(
if flow.Spec.FlowPosition == nil || flow.Spec.FlowPosition.X == nil {
xPos = float64(1)
} else {
xPos = float64(*flow.Spec.FlowPosition.X)
xPos = float64(flow.Spec.FlowPosition.GetX())
}

if flow.Spec.FlowPosition == nil || flow.Spec.FlowPosition.Y == nil {
yPos = float64(1)
} else {
yPos = float64(*flow.Spec.FlowPosition.Y)
yPos = float64(flow.Spec.FlowPosition.GetY())
}
}

Expand Down

0 comments on commit 255d7c2

Please sign in to comment.